@camunda8/cli 4.6.0-alpha.7 → 4.6.1-alpha.1
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 +4 -0
- package/dist/default-plugins/element-template/AGENTS.md +24 -27
- package/dist/default-plugins/element-template/README.md +19 -15
- package/dist/default-plugins/element-template/c8ctl-plugin.js +338 -461
- package/dist/default-plugins/element-template/docs/design.md +38 -75
- package/dist/default-plugins/element-template/package.json +1 -1
- package/dist/vendor/bpmn-element-templates.cjs +4713 -4599
- package/package.json +1 -1
|
@@ -8261,6 +8261,18 @@ var init_dist5 = __esm({
|
|
|
8261
8261
|
import { createRequire as createRequire2 } from "node:module";
|
|
8262
8262
|
import { dirname as dirname3 } from "node:path";
|
|
8263
8263
|
|
|
8264
|
+
// default-plugins/element-template/helpers.ts
|
|
8265
|
+
var import_semver = __toESM(require_semver2(), 1);
|
|
8266
|
+
import {
|
|
8267
|
+
existsSync,
|
|
8268
|
+
readFileSync,
|
|
8269
|
+
realpathSync,
|
|
8270
|
+
renameSync,
|
|
8271
|
+
unlinkSync,
|
|
8272
|
+
writeFileSync
|
|
8273
|
+
} from "node:fs";
|
|
8274
|
+
import { resolve as resolvePath } from "node:path";
|
|
8275
|
+
|
|
8264
8276
|
// default-plugins/element-template/migration/moddle.ts
|
|
8265
8277
|
function isModdleElement(value) {
|
|
8266
8278
|
if (typeof value !== "object" || value === null) {
|
|
@@ -8291,67 +8303,6 @@ function getModdleList(element, name2) {
|
|
|
8291
8303
|
return Array.isArray(value) ? value.filter(isModdleElement) : [];
|
|
8292
8304
|
}
|
|
8293
8305
|
|
|
8294
|
-
// default-plugins/element-template/binding.ts
|
|
8295
|
-
function findExtensionByType(extensionElements, type) {
|
|
8296
|
-
if (!extensionElements) {
|
|
8297
|
-
return void 0;
|
|
8298
|
-
}
|
|
8299
|
-
const values = getModdleList(extensionElements, "values");
|
|
8300
|
-
return values.find((v) => v.$type === type);
|
|
8301
|
-
}
|
|
8302
|
-
function findExtensionContainers(extensionElements) {
|
|
8303
|
-
return {
|
|
8304
|
-
ioMapping: findExtensionByType(extensionElements, "zeebe:IoMapping"),
|
|
8305
|
-
taskHeaders: findExtensionByType(extensionElements, "zeebe:TaskHeaders"),
|
|
8306
|
-
taskDefinition: findExtensionByType(
|
|
8307
|
-
extensionElements,
|
|
8308
|
-
"zeebe:TaskDefinition"
|
|
8309
|
-
),
|
|
8310
|
-
zeebeProperties: findExtensionByType(extensionElements, "zeebe:Properties")
|
|
8311
|
-
};
|
|
8312
|
-
}
|
|
8313
|
-
function resolveBindingTarget(binding, containers) {
|
|
8314
|
-
switch (binding.type) {
|
|
8315
|
-
case "zeebe:input": {
|
|
8316
|
-
const inputs = getModdleList(containers.ioMapping, "inputParameters");
|
|
8317
|
-
const child = inputs.find((p) => p.target === binding.name);
|
|
8318
|
-
return child ? { child, property: "source" } : void 0;
|
|
8319
|
-
}
|
|
8320
|
-
case "zeebe:output": {
|
|
8321
|
-
const outputs = getModdleList(containers.ioMapping, "outputParameters");
|
|
8322
|
-
const child = outputs.find((p) => p.source === binding.source);
|
|
8323
|
-
return child ? { child, property: "target" } : void 0;
|
|
8324
|
-
}
|
|
8325
|
-
case "zeebe:taskHeader": {
|
|
8326
|
-
const headers = getModdleList(containers.taskHeaders, "values");
|
|
8327
|
-
const child = headers.find((h) => h.key === binding.key);
|
|
8328
|
-
return child ? { child, property: "value" } : void 0;
|
|
8329
|
-
}
|
|
8330
|
-
case "zeebe:property": {
|
|
8331
|
-
const props = getModdleList(containers.zeebeProperties, "properties");
|
|
8332
|
-
const child = props.find((p) => p.name === binding.name);
|
|
8333
|
-
return child ? { child, property: "value" } : void 0;
|
|
8334
|
-
}
|
|
8335
|
-
case "zeebe:taskDefinition": {
|
|
8336
|
-
return containers.taskDefinition && binding.property ? { child: containers.taskDefinition, property: binding.property } : void 0;
|
|
8337
|
-
}
|
|
8338
|
-
default:
|
|
8339
|
-
return void 0;
|
|
8340
|
-
}
|
|
8341
|
-
}
|
|
8342
|
-
|
|
8343
|
-
// default-plugins/element-template/helpers.ts
|
|
8344
|
-
var import_semver = __toESM(require_semver2(), 1);
|
|
8345
|
-
import {
|
|
8346
|
-
existsSync,
|
|
8347
|
-
readFileSync,
|
|
8348
|
-
realpathSync,
|
|
8349
|
-
renameSync,
|
|
8350
|
-
unlinkSync,
|
|
8351
|
-
writeFileSync
|
|
8352
|
-
} from "node:fs";
|
|
8353
|
-
import { resolve as resolvePath } from "node:path";
|
|
8354
|
-
|
|
8355
8306
|
// default-plugins/element-template/migration/binding.ts
|
|
8356
8307
|
var BINDING_TYPE_PREFIXES = {
|
|
8357
8308
|
input: "zeebe:input",
|
|
@@ -8376,7 +8327,7 @@ function bindingPath(bindingType, key) {
|
|
|
8376
8327
|
const prefix2 = bindingType === "zeebe:taskHeader" ? "header" : bindingType?.replace("zeebe:", "");
|
|
8377
8328
|
return `${prefix2}:${key}`;
|
|
8378
8329
|
}
|
|
8379
|
-
function
|
|
8330
|
+
function findExtensionByType(extensionElements, type) {
|
|
8380
8331
|
const matches = getModdleList(extensionElements, "values").filter(
|
|
8381
8332
|
(v) => v.$type === type
|
|
8382
8333
|
);
|
|
@@ -8386,20 +8337,20 @@ function findExtensionByType2(extensionElements, type) {
|
|
|
8386
8337
|
);
|
|
8387
8338
|
return matches[0];
|
|
8388
8339
|
}
|
|
8389
|
-
function
|
|
8340
|
+
function findExtensionContainers(extensionElements) {
|
|
8390
8341
|
const containers = {
|
|
8391
|
-
ioMapping:
|
|
8392
|
-
taskHeaders:
|
|
8393
|
-
taskDefinition:
|
|
8342
|
+
ioMapping: findExtensionByType(extensionElements, "zeebe:IoMapping"),
|
|
8343
|
+
taskHeaders: findExtensionByType(extensionElements, "zeebe:TaskHeaders"),
|
|
8344
|
+
taskDefinition: findExtensionByType(
|
|
8394
8345
|
extensionElements,
|
|
8395
8346
|
"zeebe:TaskDefinition"
|
|
8396
8347
|
),
|
|
8397
|
-
zeebeProperties:
|
|
8398
|
-
agentDefinition:
|
|
8348
|
+
zeebeProperties: findExtensionByType(extensionElements, "zeebe:Properties"),
|
|
8349
|
+
agentDefinition: findExtensionByType(
|
|
8399
8350
|
extensionElements,
|
|
8400
8351
|
"zeebe:AgentDefinition"
|
|
8401
8352
|
),
|
|
8402
|
-
adHoc:
|
|
8353
|
+
adHoc: findExtensionByType(extensionElements, "zeebe:AdHoc")
|
|
8403
8354
|
};
|
|
8404
8355
|
for (const [container, list, key, prefix2] of [
|
|
8405
8356
|
[containers.ioMapping, "inputParameters", "target", "input"],
|
|
@@ -8420,7 +8371,7 @@ function findExtensionContainers2(extensionElements) {
|
|
|
8420
8371
|
}
|
|
8421
8372
|
return containers;
|
|
8422
8373
|
}
|
|
8423
|
-
function
|
|
8374
|
+
function resolveBindingTarget(binding, containers) {
|
|
8424
8375
|
switch (binding.type) {
|
|
8425
8376
|
case "zeebe:input": {
|
|
8426
8377
|
const inputs = getModdleList(containers.ioMapping, "inputParameters");
|
|
@@ -9235,157 +9186,30 @@ function parseTemplateJson(content) {
|
|
|
9235
9186
|
}
|
|
9236
9187
|
|
|
9237
9188
|
// default-plugins/element-template/template-ref.ts
|
|
9238
|
-
var
|
|
9239
|
-
import { existsSync as existsSync4, readdirSync, readFileSync as readFileSync3, statSync } from "node:fs";
|
|
9189
|
+
var import_semver3 = __toESM(require_semver2(), 1);
|
|
9190
|
+
import { existsSync as existsSync4, readdirSync as readdirSync2, readFileSync as readFileSync3, statSync as statSync2 } from "node:fs";
|
|
9240
9191
|
import { createRequire } from "node:module";
|
|
9241
9192
|
import { dirname as dirname2, join as join2, resolve as resolvePath3 } from "node:path";
|
|
9242
9193
|
|
|
9243
9194
|
// default-plugins/element-template/cache.ts
|
|
9244
|
-
var
|
|
9195
|
+
var import_semver2 = __toESM(require_semver2(), 1);
|
|
9245
9196
|
import {
|
|
9246
9197
|
closeSync,
|
|
9247
9198
|
existsSync as existsSync2,
|
|
9248
9199
|
mkdirSync,
|
|
9200
|
+
mkdtempSync,
|
|
9249
9201
|
openSync,
|
|
9202
|
+
readdirSync,
|
|
9250
9203
|
readFileSync as readFileSync2,
|
|
9251
9204
|
renameSync as renameSync2,
|
|
9205
|
+
rmSync,
|
|
9206
|
+
statSync,
|
|
9252
9207
|
unlinkSync as unlinkSync2,
|
|
9253
9208
|
writeFileSync as writeFileSync2,
|
|
9254
9209
|
writeSync
|
|
9255
9210
|
} from "node:fs";
|
|
9256
9211
|
import { join } from "node:path";
|
|
9257
|
-
|
|
9258
|
-
// default-plugins/element-template/releases.ts
|
|
9259
|
-
var import_semver2 = __toESM(require_semver2(), 1);
|
|
9260
|
-
import { gunzipSync } from "node:zlib";
|
|
9261
|
-
var DEFAULT_RELEASES_URL = "https://api.github.com/repos/camunda/connectors/releases?per_page=100";
|
|
9262
|
-
var TEMPLATES_ASSET_PREFIX = "connectors-bundle-templates-";
|
|
9263
|
-
var TEMPLATES_ASSET_SUFFIX = ".tar.gz";
|
|
9264
|
-
var RELEASES_FETCH_TIMEOUT_MS = 3e4;
|
|
9265
|
-
var ASSET_FETCH_TIMEOUT_MS = 12e4;
|
|
9266
|
-
var MAX_BUNDLE_BYTES = 128 * 1024 * 1024;
|
|
9267
|
-
var MAX_MINOR_LINES = 4;
|
|
9268
|
-
function getReleasesUrl() {
|
|
9269
|
-
return process.env.C8CTL_CONNECTORS_RELEASES_URL || DEFAULT_RELEASES_URL;
|
|
9270
|
-
}
|
|
9271
|
-
function isReleaseCandidate(version) {
|
|
9272
|
-
const prerelease = import_semver2.default.prerelease(version);
|
|
9273
|
-
if (!prerelease) return false;
|
|
9274
|
-
return prerelease.flatMap((part) => typeof part === "string" ? part.split("-") : []).some((part) => /^rc\d*$/i.test(part));
|
|
9275
|
-
}
|
|
9276
|
-
function findTemplatesAssetUrl(release) {
|
|
9277
|
-
if (!Array.isArray(release.assets)) return null;
|
|
9278
|
-
for (const asset of release.assets) {
|
|
9279
|
-
if (!isRecord(asset)) continue;
|
|
9280
|
-
const { name: name2, browser_download_url: url } = asset;
|
|
9281
|
-
if (typeof name2 !== "string" || typeof url !== "string") continue;
|
|
9282
|
-
if (name2.startsWith(TEMPLATES_ASSET_PREFIX) && name2.endsWith(TEMPLATES_ASSET_SUFFIX)) {
|
|
9283
|
-
return url;
|
|
9284
|
-
}
|
|
9285
|
-
}
|
|
9286
|
-
return null;
|
|
9287
|
-
}
|
|
9288
|
-
function parseReleases(raw) {
|
|
9289
|
-
if (!Array.isArray(raw)) {
|
|
9290
|
-
throw new Error("Connector releases response is not a JSON array");
|
|
9291
|
-
}
|
|
9292
|
-
const releases = [];
|
|
9293
|
-
for (const entry of raw) {
|
|
9294
|
-
if (!isRecord(entry)) continue;
|
|
9295
|
-
if (entry.draft === true) continue;
|
|
9296
|
-
const tag = entry.tag_name;
|
|
9297
|
-
if (typeof tag !== "string") continue;
|
|
9298
|
-
const version = import_semver2.default.valid(tag);
|
|
9299
|
-
if (!version || isReleaseCandidate(version)) continue;
|
|
9300
|
-
const assetUrl = findTemplatesAssetUrl(entry);
|
|
9301
|
-
if (!assetUrl) continue;
|
|
9302
|
-
releases.push({ tag, version, assetUrl });
|
|
9303
|
-
}
|
|
9304
|
-
return releases;
|
|
9305
|
-
}
|
|
9306
|
-
function selectLatestPerMinor(releases) {
|
|
9307
|
-
const latest = /* @__PURE__ */ new Map();
|
|
9308
|
-
for (const release of releases) {
|
|
9309
|
-
const key = `${import_semver2.default.major(release.version)}.${import_semver2.default.minor(release.version)}`;
|
|
9310
|
-
const current = latest.get(key);
|
|
9311
|
-
if (!current || import_semver2.default.gt(release.version, current.version)) {
|
|
9312
|
-
latest.set(key, release);
|
|
9313
|
-
}
|
|
9314
|
-
}
|
|
9315
|
-
return [...latest.values()].sort((a, b) => import_semver2.default.rcompare(a.version, b.version)).slice(0, MAX_MINOR_LINES);
|
|
9316
|
-
}
|
|
9317
|
-
async function fetchConnectorReleases() {
|
|
9318
|
-
const url = getReleasesUrl();
|
|
9319
|
-
const response = await fetch(url, {
|
|
9320
|
-
headers: {
|
|
9321
|
-
"User-Agent": USER_AGENT,
|
|
9322
|
-
Accept: "application/vnd.github+json"
|
|
9323
|
-
},
|
|
9324
|
-
signal: AbortSignal.timeout(RELEASES_FETCH_TIMEOUT_MS)
|
|
9325
|
-
});
|
|
9326
|
-
if (!response.ok) {
|
|
9327
|
-
const hint = response.status === 403 || response.status === 429 ? "\nThe GitHub API rate limit may be exhausted \u2014 retry later, or point C8CTL_CONNECTORS_RELEASES_URL at a mirror of the release listing." : "";
|
|
9328
|
-
throw new Error(
|
|
9329
|
-
`HTTP ${response.status} ${response.statusText} for ${url}${hint}`
|
|
9330
|
-
);
|
|
9331
|
-
}
|
|
9332
|
-
return selectLatestPerMinor(parseReleases(await response.json()));
|
|
9333
|
-
}
|
|
9334
|
-
async function fetchReleaseAsset(url) {
|
|
9335
|
-
const response = await fetch(url, {
|
|
9336
|
-
headers: { "User-Agent": USER_AGENT },
|
|
9337
|
-
signal: AbortSignal.timeout(ASSET_FETCH_TIMEOUT_MS)
|
|
9338
|
-
});
|
|
9339
|
-
if (!response.ok) {
|
|
9340
|
-
throw new Error(
|
|
9341
|
-
`HTTP ${response.status} ${response.statusText} for ${url}`
|
|
9342
|
-
);
|
|
9343
|
-
}
|
|
9344
|
-
return new Uint8Array(await response.arrayBuffer());
|
|
9345
|
-
}
|
|
9346
|
-
var TAR_BLOCK_SIZE = 512;
|
|
9347
|
-
function readTarString(tar, offset, length) {
|
|
9348
|
-
const raw = tar.toString("utf-8", offset, offset + length);
|
|
9349
|
-
const nul = raw.indexOf("\0");
|
|
9350
|
-
return nul === -1 ? raw : raw.slice(0, nul);
|
|
9351
|
-
}
|
|
9352
|
-
function extractJsonEntries(gzipped) {
|
|
9353
|
-
const tar = gunzipSync(gzipped, { maxOutputLength: MAX_BUNDLE_BYTES });
|
|
9354
|
-
const entries = [];
|
|
9355
|
-
let offset = 0;
|
|
9356
|
-
while (offset + TAR_BLOCK_SIZE <= tar.length) {
|
|
9357
|
-
if (tar.subarray(offset, offset + TAR_BLOCK_SIZE).every((b) => b === 0)) {
|
|
9358
|
-
break;
|
|
9359
|
-
}
|
|
9360
|
-
const name2 = readTarString(tar, offset, 100);
|
|
9361
|
-
const prefix2 = readTarString(tar, offset + 345, 155);
|
|
9362
|
-
const sizeField = readTarString(tar, offset + 124, 12).trim();
|
|
9363
|
-
const size = Number.parseInt(sizeField, 8);
|
|
9364
|
-
if (!Number.isFinite(size) || size < 0) {
|
|
9365
|
-
throw new Error(
|
|
9366
|
-
`Malformed tar header (bad size field) at byte ${offset}`
|
|
9367
|
-
);
|
|
9368
|
-
}
|
|
9369
|
-
const typeFlag = String.fromCharCode(tar[offset + 156]);
|
|
9370
|
-
const dataStart = offset + TAR_BLOCK_SIZE;
|
|
9371
|
-
const dataEnd = dataStart + size;
|
|
9372
|
-
if (dataEnd > tar.length) {
|
|
9373
|
-
throw new Error(`Truncated tar entry '${name2}' at byte ${offset}`);
|
|
9374
|
-
}
|
|
9375
|
-
const fullName = prefix2 ? `${prefix2}/${name2}` : name2;
|
|
9376
|
-
if ((typeFlag === "0" || typeFlag === "\0") && fullName.endsWith(".json")) {
|
|
9377
|
-
entries.push({
|
|
9378
|
-
name: fullName,
|
|
9379
|
-
content: tar.toString("utf-8", dataStart, dataEnd)
|
|
9380
|
-
});
|
|
9381
|
-
}
|
|
9382
|
-
offset = dataStart + Math.ceil(size / TAR_BLOCK_SIZE) * TAR_BLOCK_SIZE;
|
|
9383
|
-
}
|
|
9384
|
-
return entries;
|
|
9385
|
-
}
|
|
9386
|
-
|
|
9387
|
-
// default-plugins/element-template/cache.ts
|
|
9388
|
-
var FETCH_CONCURRENCY = 4;
|
|
9212
|
+
var DEFAULT_PACKAGE = "@camunda/connectors-element-templates";
|
|
9389
9213
|
var STALE_AFTER_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
9390
9214
|
var SYNC_LOCK_STALE_AFTER_MS = 60 * 60 * 1e3;
|
|
9391
9215
|
function getCacheDir() {
|
|
@@ -9552,7 +9376,7 @@ function atomicWriteFileSync(target, contents) {
|
|
|
9552
9376
|
throw error3;
|
|
9553
9377
|
}
|
|
9554
9378
|
}
|
|
9555
|
-
function saveCache(templates
|
|
9379
|
+
function saveCache(templates) {
|
|
9556
9380
|
const dir = getCacheDir();
|
|
9557
9381
|
mkdirSync(dir, { recursive: true });
|
|
9558
9382
|
atomicWriteFileSync(
|
|
@@ -9560,9 +9384,7 @@ function saveCache(templates, { stampFetchedAt = true } = {}) {
|
|
|
9560
9384
|
`${JSON.stringify(templates, null, 2)}
|
|
9561
9385
|
`
|
|
9562
9386
|
);
|
|
9563
|
-
|
|
9564
|
-
atomicWriteFileSync(getFetchedAtPath(), String(Date.now()));
|
|
9565
|
-
}
|
|
9387
|
+
atomicWriteFileSync(getFetchedAtPath(), String(Date.now()));
|
|
9566
9388
|
}
|
|
9567
9389
|
function isCacheStale() {
|
|
9568
9390
|
const fetchedAt = loadFetchedAt();
|
|
@@ -9586,52 +9408,139 @@ function nudgeIfStale(logger) {
|
|
|
9586
9408
|
function isTemplateLike(value) {
|
|
9587
9409
|
return isRecord(value) && Array.isArray(value.properties);
|
|
9588
9410
|
}
|
|
9589
|
-
function buildUpstreamRef(
|
|
9590
|
-
return `${
|
|
9591
|
-
}
|
|
9592
|
-
function assetUrlOfRef(ref) {
|
|
9593
|
-
const hash = ref.indexOf("#");
|
|
9594
|
-
return hash === -1 ? ref : ref.slice(0, hash);
|
|
9411
|
+
function buildUpstreamRef(packageRef, fileName) {
|
|
9412
|
+
return `${packageRef}#src/element-templates/${fileName}`;
|
|
9595
9413
|
}
|
|
9596
|
-
|
|
9597
|
-
const
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
} catch {
|
|
9604
|
-
continue;
|
|
9414
|
+
function installTemplates(spec, logger) {
|
|
9415
|
+
const c8ctl12 = globalThis.c8ctl;
|
|
9416
|
+
if (!c8ctl12) throw new Error("c8ctl npm runner is not available.");
|
|
9417
|
+
const cacheDir = getCacheDir();
|
|
9418
|
+
for (const entry of readdirSync(cacheDir, { withFileTypes: true })) {
|
|
9419
|
+
if (entry.name.startsWith(".staging-") && entry.isDirectory()) {
|
|
9420
|
+
rmSync(join(cacheDir, entry.name), { recursive: true, force: true });
|
|
9605
9421
|
}
|
|
9606
|
-
|
|
9607
|
-
|
|
9422
|
+
}
|
|
9423
|
+
const dir = mkdtempSync(join(cacheDir, ".staging-"));
|
|
9424
|
+
try {
|
|
9425
|
+
c8ctl12.npm({
|
|
9426
|
+
args: [
|
|
9427
|
+
"install",
|
|
9428
|
+
spec,
|
|
9429
|
+
"--prefix",
|
|
9430
|
+
dir,
|
|
9431
|
+
"--ignore-scripts",
|
|
9432
|
+
"--no-package-lock"
|
|
9433
|
+
],
|
|
9434
|
+
stdio: "pipe"
|
|
9435
|
+
});
|
|
9436
|
+
const modulesDir = join(dir, "node_modules");
|
|
9437
|
+
const installed = readdirSync(modulesDir, { withFileTypes: true }).filter(
|
|
9438
|
+
(entry) => !entry.name.startsWith(".") && (entry.isDirectory() || entry.isSymbolicLink())
|
|
9439
|
+
).flatMap(
|
|
9440
|
+
(entry) => entry.name.startsWith("@") ? readdirSync(join(modulesDir, entry.name), {
|
|
9441
|
+
withFileTypes: true
|
|
9442
|
+
}).filter((child) => child.isDirectory() || child.isSymbolicLink()).map((child) => join(entry.name, child.name)) : [entry.name]
|
|
9443
|
+
);
|
|
9444
|
+
const packageNames = installed.filter(
|
|
9445
|
+
(name2) => existsSync2(join(modulesDir, name2, "src", "element-templates"))
|
|
9446
|
+
);
|
|
9447
|
+
if (packageNames.length !== 1) {
|
|
9448
|
+
const found = (names) => names.join(", ") || "none";
|
|
9449
|
+
throw new Error(
|
|
9450
|
+
packageNames.length === 0 ? `npm install produced no package with src/element-templates (installed: ${found(installed)}).` : `npm install produced several packages with src/element-templates (${found(packageNames)}). Sync supports a single template package; a package that depends on another template package counts as several.`
|
|
9451
|
+
);
|
|
9608
9452
|
}
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
|
|
9613
|
-
|
|
9453
|
+
const packageDir = join(modulesDir, packageNames[0]);
|
|
9454
|
+
const installedManifest = JSON.parse(
|
|
9455
|
+
readFileSync2(join(packageDir, "package.json"), "utf-8")
|
|
9456
|
+
);
|
|
9457
|
+
if (!isRecord(installedManifest) || typeof installedManifest.name !== "string" || typeof installedManifest.version !== "string" || !import_semver2.default.valid(installedManifest.version)) {
|
|
9458
|
+
throw new Error(
|
|
9459
|
+
"Installed template package has no valid name or version."
|
|
9460
|
+
);
|
|
9461
|
+
}
|
|
9462
|
+
const ref = `npm:${installedManifest.name}@${installedManifest.version}`;
|
|
9463
|
+
const templatesDir = join(packageDir, "src", "element-templates");
|
|
9464
|
+
const templates = [];
|
|
9465
|
+
for (const file of readdirSync(templatesDir, { withFileTypes: true })) {
|
|
9466
|
+
if (!file.name.endsWith(".json")) {
|
|
9467
|
+
continue;
|
|
9468
|
+
}
|
|
9469
|
+
const filePath = join(templatesDir, file.name);
|
|
9470
|
+
if (!statSync(filePath, { throwIfNoEntry: false })?.isFile()) {
|
|
9471
|
+
continue;
|
|
9472
|
+
}
|
|
9473
|
+
let parsed;
|
|
9474
|
+
try {
|
|
9475
|
+
parsed = JSON.parse(readFileSync2(filePath, "utf-8"));
|
|
9476
|
+
} catch (error3) {
|
|
9477
|
+
const detail = error3 instanceof Error ? error3.message : String(error3);
|
|
9478
|
+
throw new Error(
|
|
9479
|
+
`Invalid element template JSON in ${file.name}: ${detail}`
|
|
9480
|
+
);
|
|
9481
|
+
}
|
|
9482
|
+
for (const value of Array.isArray(parsed) ? parsed : [parsed]) {
|
|
9483
|
+
if (isRecord(value) && value.version === void 0) continue;
|
|
9484
|
+
if (!isTemplateLike(value) || typeof value.id !== "string" || typeof value.version !== "number") {
|
|
9485
|
+
logger.warn(`Skipping invalid element template in ${file.name}.`);
|
|
9486
|
+
continue;
|
|
9487
|
+
}
|
|
9488
|
+
value.metadata = {
|
|
9489
|
+
...value.metadata,
|
|
9490
|
+
upstreamRef: buildUpstreamRef(ref, file.name)
|
|
9491
|
+
};
|
|
9492
|
+
templates.push(value);
|
|
9493
|
+
}
|
|
9494
|
+
}
|
|
9495
|
+
if (templates.length === 0) {
|
|
9496
|
+
throw new Error("Package contained no element templates.");
|
|
9497
|
+
}
|
|
9498
|
+
return templates;
|
|
9499
|
+
} finally {
|
|
9500
|
+
rmSync(dir, { recursive: true, force: true });
|
|
9614
9501
|
}
|
|
9615
|
-
|
|
9616
|
-
|
|
9617
|
-
|
|
9502
|
+
}
|
|
9503
|
+
function syncErrorMessage(error3, logger) {
|
|
9504
|
+
if (isRecord(error3) && (Buffer.isBuffer(error3.stderr) || typeof error3.stderr === "string")) {
|
|
9505
|
+
const stderr = String(error3.stderr).trim().replaceAll(/(https?:\/\/)[^/\s@]+@/g, "$1[redacted]@").replaceAll(
|
|
9506
|
+
/([?&](?:token|password|_authToken|key)=)[^&\s]+/gi,
|
|
9507
|
+
"$1[redacted]"
|
|
9618
9508
|
);
|
|
9509
|
+
logger.debug(`npm install stderr: ${stderr}`);
|
|
9510
|
+
if (globalThis.c8ctl?.verbose && stderr) {
|
|
9511
|
+
logger.warn(`npm install stderr: ${stderr}`);
|
|
9512
|
+
}
|
|
9513
|
+
const code = /^npm (?:error|ERR!) code ([A-Z0-9]+)/m.exec(stderr)?.[1];
|
|
9514
|
+
if (code)
|
|
9515
|
+
return `npm install failed (${code}). Check npm registry settings or run with --verbose for details.`;
|
|
9516
|
+
return "npm install failed. Run with --verbose for npm's error details.";
|
|
9619
9517
|
}
|
|
9620
|
-
return
|
|
9518
|
+
return error3 instanceof Error ? error3.message : String(error3);
|
|
9621
9519
|
}
|
|
9622
|
-
|
|
9623
|
-
const
|
|
9624
|
-
const
|
|
9625
|
-
|
|
9626
|
-
|
|
9627
|
-
|
|
9628
|
-
|
|
9629
|
-
|
|
9630
|
-
|
|
9631
|
-
|
|
9520
|
+
function mergeTemplates(fresh, existing, prune) {
|
|
9521
|
+
const templates = [];
|
|
9522
|
+
const seen = /* @__PURE__ */ new Set();
|
|
9523
|
+
for (const tpl of sortTemplates(fresh)) {
|
|
9524
|
+
const key = `${tpl.id}@${tpl.version}`;
|
|
9525
|
+
if (seen.has(key)) continue;
|
|
9526
|
+
seen.add(key);
|
|
9527
|
+
templates.push(tpl);
|
|
9528
|
+
}
|
|
9529
|
+
const fetched = templates.length;
|
|
9530
|
+
let cached = 0;
|
|
9531
|
+
let pruned = 0;
|
|
9532
|
+
for (const tpl of sortTemplates(existing)) {
|
|
9533
|
+
const key = `${tpl.id}@${tpl.version}`;
|
|
9534
|
+
if (seen.has(key)) continue;
|
|
9535
|
+
if (prune) {
|
|
9536
|
+
pruned++;
|
|
9537
|
+
continue;
|
|
9632
9538
|
}
|
|
9633
|
-
|
|
9634
|
-
|
|
9539
|
+
seen.add(key);
|
|
9540
|
+
templates.push(tpl);
|
|
9541
|
+
cached++;
|
|
9542
|
+
}
|
|
9543
|
+
return { templates: sortTemplates(templates), fetched, cached, pruned };
|
|
9635
9544
|
}
|
|
9636
9545
|
function sortTemplates(templates) {
|
|
9637
9546
|
return [...templates].sort((a, b) => {
|
|
@@ -9650,17 +9559,12 @@ async function syncTemplatesLocked({
|
|
|
9650
9559
|
logger,
|
|
9651
9560
|
prune
|
|
9652
9561
|
}) {
|
|
9653
|
-
const
|
|
9654
|
-
|
|
9655
|
-
const releases = await fetchConnectorReleases();
|
|
9656
|
-
if (releases.length === 0) {
|
|
9562
|
+
const spec = process.env.C8CTL_ELEMENT_TEMPLATES_PACKAGE || DEFAULT_PACKAGE;
|
|
9563
|
+
if (spec.startsWith("-")) {
|
|
9657
9564
|
throw new Error(
|
|
9658
|
-
`
|
|
9565
|
+
`Invalid C8CTL_ELEMENT_TEMPLATES_PACKAGE '${spec}': a package spec must not start with '-'.`
|
|
9659
9566
|
);
|
|
9660
9567
|
}
|
|
9661
|
-
logger.info(
|
|
9662
|
-
`Latest release per minor: ${releases.map((r) => r.tag).join(", ")}.`
|
|
9663
|
-
);
|
|
9664
9568
|
let existing;
|
|
9665
9569
|
try {
|
|
9666
9570
|
existing = loadCache() || [];
|
|
@@ -9669,90 +9573,52 @@ async function syncTemplatesLocked({
|
|
|
9669
9573
|
logger.warn(`Corrupt cache \u2014 starting fresh: ${message}`);
|
|
9670
9574
|
existing = [];
|
|
9671
9575
|
}
|
|
9672
|
-
const selectedAssets = new Set(releases.map((r) => r.assetUrl));
|
|
9673
|
-
const cachedByAsset = /* @__PURE__ */ new Map();
|
|
9674
|
-
const staleCached = [];
|
|
9675
|
-
for (const tpl of existing) {
|
|
9676
|
-
const ref = tpl.metadata?.upstreamRef;
|
|
9677
|
-
const asset = ref ? assetUrlOfRef(ref) : void 0;
|
|
9678
|
-
if (asset && selectedAssets.has(asset)) {
|
|
9679
|
-
const bucket = cachedByAsset.get(asset);
|
|
9680
|
-
if (bucket) bucket.push(tpl);
|
|
9681
|
-
else cachedByAsset.set(asset, [tpl]);
|
|
9682
|
-
} else {
|
|
9683
|
-
staleCached.push(tpl);
|
|
9684
|
-
}
|
|
9685
|
-
}
|
|
9686
|
-
const toFetch = releases.filter((r) => !cachedByAsset.has(r.assetUrl));
|
|
9687
|
-
const reusedCount = [...cachedByAsset.values()].reduce(
|
|
9688
|
-
(sum, bucket) => sum + bucket.length,
|
|
9689
|
-
0
|
|
9690
|
-
);
|
|
9691
|
-
logger.info(
|
|
9692
|
-
`${reusedCount > 0 ? `Reusing ${reusedCount} cached templates from ${cachedByAsset.size} bundle(s), ` : ""}downloading ${toFetch.length} bundle(s)...`
|
|
9693
|
-
);
|
|
9694
9576
|
let errors = 0;
|
|
9695
|
-
let
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
|
|
9701
|
-
const templates = await fetchReleaseTemplates(release);
|
|
9702
|
-
fetchedByAsset.set(release.assetUrl, templates);
|
|
9703
|
-
logger.info(
|
|
9704
|
-
` [${myProgress}/${toFetch.length}] ${release.tag} \u2014 ${templates.length} templates`
|
|
9705
|
-
);
|
|
9706
|
-
} catch (error3) {
|
|
9707
|
-
errors += 1;
|
|
9708
|
-
const message = error3 instanceof Error ? error3.message : String(error3);
|
|
9709
|
-
logger.warn(
|
|
9710
|
-
` [${myProgress}/${toFetch.length}] ${release.tag} \u2014 ${message}`
|
|
9711
|
-
);
|
|
9712
|
-
}
|
|
9713
|
-
});
|
|
9714
|
-
const next = [];
|
|
9715
|
-
const seen = /* @__PURE__ */ new Set();
|
|
9716
|
-
let fetched = 0;
|
|
9717
|
-
let cached = 0;
|
|
9718
|
-
const add = (tpl) => {
|
|
9719
|
-
const key = `${tpl.id}@${tpl.version}`;
|
|
9720
|
-
if (seen.has(key)) return false;
|
|
9721
|
-
seen.add(key);
|
|
9722
|
-
next.push(tpl);
|
|
9723
|
-
return true;
|
|
9724
|
-
};
|
|
9725
|
-
for (const release of releases) {
|
|
9726
|
-
const fresh = fetchedByAsset.get(release.assetUrl);
|
|
9727
|
-
const templates = fresh ?? cachedByAsset.get(release.assetUrl) ?? [];
|
|
9728
|
-
for (const tpl of sortTemplates(templates)) {
|
|
9729
|
-
if (!add(tpl)) continue;
|
|
9730
|
-
if (fresh) fetched += 1;
|
|
9731
|
-
else cached += 1;
|
|
9732
|
-
}
|
|
9733
|
-
}
|
|
9734
|
-
const pruning = prune && errors === 0;
|
|
9735
|
-
if (prune && errors > 0) {
|
|
9577
|
+
let fresh = [];
|
|
9578
|
+
logger.info("Installing element templates with npm ...");
|
|
9579
|
+
try {
|
|
9580
|
+
fresh = installTemplates(spec, logger);
|
|
9581
|
+
} catch (error3) {
|
|
9582
|
+
errors = 1;
|
|
9736
9583
|
logger.warn(
|
|
9737
|
-
`
|
|
9584
|
+
`Could not install element templates: ${syncErrorMessage(error3, logger)}`
|
|
9738
9585
|
);
|
|
9739
9586
|
}
|
|
9740
|
-
if (
|
|
9741
|
-
|
|
9742
|
-
|
|
9587
|
+
if (errors > 0) {
|
|
9588
|
+
if (existing.length === 0) {
|
|
9589
|
+
throw new Error(
|
|
9590
|
+
"No element templates could be installed (package install failed). Check the warnings above and retry 'c8ctl element-template sync'."
|
|
9591
|
+
);
|
|
9743
9592
|
}
|
|
9593
|
+
if (prune) {
|
|
9594
|
+
logger.warn(
|
|
9595
|
+
"Skipping prune: package install failed \u2014 cached templates were kept."
|
|
9596
|
+
);
|
|
9597
|
+
}
|
|
9598
|
+
return {
|
|
9599
|
+
total: existing.length,
|
|
9600
|
+
fetched: 0,
|
|
9601
|
+
cached: existing.length,
|
|
9602
|
+
errors,
|
|
9603
|
+
pruned: 0
|
|
9604
|
+
};
|
|
9744
9605
|
}
|
|
9745
|
-
const
|
|
9606
|
+
const {
|
|
9607
|
+
templates: next,
|
|
9608
|
+
fetched: added,
|
|
9609
|
+
cached: retained,
|
|
9610
|
+
pruned
|
|
9611
|
+
} = mergeTemplates(fresh, existing, prune);
|
|
9746
9612
|
if (next.length === 0) {
|
|
9747
9613
|
throw new Error(
|
|
9748
|
-
|
|
9614
|
+
"No element templates could be installed (package was empty). Check the warnings above and retry 'c8ctl element-template sync'."
|
|
9749
9615
|
);
|
|
9750
9616
|
}
|
|
9751
|
-
saveCache(next
|
|
9617
|
+
saveCache(next);
|
|
9752
9618
|
const summary = {
|
|
9753
9619
|
total: next.length,
|
|
9754
|
-
fetched,
|
|
9755
|
-
cached,
|
|
9620
|
+
fetched: added,
|
|
9621
|
+
cached: retained,
|
|
9756
9622
|
errors,
|
|
9757
9623
|
pruned
|
|
9758
9624
|
};
|
|
@@ -9781,12 +9647,12 @@ function pickVersion(templates, { version, executionPlatformVersion } = {}) {
|
|
|
9781
9647
|
}
|
|
9782
9648
|
let candidates = templates.filter((t) => t.version !== void 0);
|
|
9783
9649
|
if (executionPlatformVersion) {
|
|
9784
|
-
const coerced =
|
|
9650
|
+
const coerced = import_semver2.default.coerce(executionPlatformVersion);
|
|
9785
9651
|
if (coerced) {
|
|
9786
9652
|
candidates = candidates.filter((t) => {
|
|
9787
9653
|
const constraint = t.engines?.camunda;
|
|
9788
9654
|
if (!constraint) return true;
|
|
9789
|
-
return
|
|
9655
|
+
return import_semver2.default.satisfies(coerced, constraint);
|
|
9790
9656
|
});
|
|
9791
9657
|
}
|
|
9792
9658
|
}
|
|
@@ -9806,12 +9672,12 @@ function searchTemplates(query, { executionPlatformVersion } = {}) {
|
|
|
9806
9672
|
return name2.includes(q) || description.includes(q) || id.includes(q) || keywords.includes(q);
|
|
9807
9673
|
}).filter((t) => !t.deprecated);
|
|
9808
9674
|
if (executionPlatformVersion) {
|
|
9809
|
-
const coerced =
|
|
9675
|
+
const coerced = import_semver2.default.coerce(executionPlatformVersion);
|
|
9810
9676
|
if (coerced) {
|
|
9811
9677
|
matches = matches.filter((t) => {
|
|
9812
9678
|
const constraint = t.engines?.camunda;
|
|
9813
9679
|
if (!constraint) return true;
|
|
9814
|
-
return
|
|
9680
|
+
return import_semver2.default.satisfies(coerced, constraint);
|
|
9815
9681
|
});
|
|
9816
9682
|
}
|
|
9817
9683
|
}
|
|
@@ -9928,7 +9794,7 @@ async function getExecutionPlatformVersion(xml2, { requireCamunda = false } = {}
|
|
|
9928
9794
|
engineVersion
|
|
9929
9795
|
))
|
|
9930
9796
|
return null;
|
|
9931
|
-
return
|
|
9797
|
+
return import_semver3.default.valid(
|
|
9932
9798
|
/^\d+\.\d+$/.test(engineVersion) ? `${engineVersion}.0` : engineVersion
|
|
9933
9799
|
);
|
|
9934
9800
|
}
|
|
@@ -9943,7 +9809,7 @@ function isEngineCompatible(template, engineVersion) {
|
|
|
9943
9809
|
if (!isRecord(template.engines)) return false;
|
|
9944
9810
|
if (!("camunda" in template.engines)) return true;
|
|
9945
9811
|
const range = template.engines.camunda;
|
|
9946
|
-
return typeof range === "string" && range.trim() !== "" &&
|
|
9812
|
+
return typeof range === "string" && range.trim() !== "" && import_semver3.default.validRange(range) !== null && import_semver3.default.satisfies(engineVersion, range);
|
|
9947
9813
|
}
|
|
9948
9814
|
function isTraversable(value) {
|
|
9949
9815
|
return typeof value === "object" && value !== null;
|
|
@@ -9988,7 +9854,7 @@ function localTemplateDirs(startDir) {
|
|
|
9988
9854
|
}
|
|
9989
9855
|
function isFile(path) {
|
|
9990
9856
|
try {
|
|
9991
|
-
return
|
|
9857
|
+
return statSync2(path).isFile();
|
|
9992
9858
|
} catch {
|
|
9993
9859
|
return false;
|
|
9994
9860
|
}
|
|
@@ -9998,7 +9864,7 @@ function readLocalTemplates(dirs) {
|
|
|
9998
9864
|
for (const dir of dirs) {
|
|
9999
9865
|
let files;
|
|
10000
9866
|
try {
|
|
10001
|
-
files =
|
|
9867
|
+
files = readdirSync2(dir, { recursive: true, withFileTypes: true }).filter((e) => e.name.toLowerCase().endsWith(".json")).map((e) => join2(e.parentPath, e.name)).filter(isFile).sort();
|
|
10002
9868
|
} catch {
|
|
10003
9869
|
continue;
|
|
10004
9870
|
}
|
|
@@ -10168,16 +10034,7 @@ async function loadTemplate(templateArg, {
|
|
|
10168
10034
|
if (!globalThis.c8ctl) throw new Error("c8ctl runtime not initialised");
|
|
10169
10035
|
var c8ctl3 = globalThis.c8ctl;
|
|
10170
10036
|
var require3 = createRequire2(import.meta.url);
|
|
10171
|
-
function forceSetValues(
|
|
10172
|
-
const modeling = modeler.get("modeling");
|
|
10173
|
-
const extensionElements = getModdleElement(
|
|
10174
|
-
element.businessObject,
|
|
10175
|
-
"extensionElements"
|
|
10176
|
-
);
|
|
10177
|
-
if (!extensionElements) {
|
|
10178
|
-
return;
|
|
10179
|
-
}
|
|
10180
|
-
const containers = findExtensionContainers(extensionElements);
|
|
10037
|
+
function forceSetValues(element, elementTemplates, template, setArgs) {
|
|
10181
10038
|
for (const arg of setArgs) {
|
|
10182
10039
|
const { bindingTypeFilter, name: name2, value } = parseSetArg(arg);
|
|
10183
10040
|
const matches = findPropertiesByBindingName(
|
|
@@ -10186,13 +10043,8 @@ function forceSetValues(modeler, element, template, setArgs) {
|
|
|
10186
10043
|
bindingTypeFilter
|
|
10187
10044
|
);
|
|
10188
10045
|
for (const prop of matches) {
|
|
10189
|
-
if (
|
|
10190
|
-
|
|
10191
|
-
const target = resolveBindingTarget(prop.binding, containers);
|
|
10192
|
-
if (target) {
|
|
10193
|
-
modeling.updateModdleProperties(element, target.child, {
|
|
10194
|
-
[target.property]: effectiveValue
|
|
10195
|
-
});
|
|
10046
|
+
if (prop.binding && elementTemplates.isConditionMet(element, template.properties, prop)) {
|
|
10047
|
+
elementTemplates.setPropertyValue(element, prop, value);
|
|
10196
10048
|
}
|
|
10197
10049
|
}
|
|
10198
10050
|
}
|
|
@@ -10221,10 +10073,10 @@ async function applyElementTemplate(xml2, template, elementId, setArgs) {
|
|
|
10221
10073
|
}
|
|
10222
10074
|
const elementTemplates = modeler.get("elementTemplates");
|
|
10223
10075
|
elementTemplates.set([template]);
|
|
10224
|
-
elementTemplates.applyTemplate(element, template);
|
|
10076
|
+
let current = elementTemplates.applyTemplate(element, template) ?? element;
|
|
10225
10077
|
if (setArgs.length > 0) {
|
|
10226
|
-
forceSetValues(
|
|
10227
|
-
elementTemplates.applyTemplate(
|
|
10078
|
+
forceSetValues(current, elementTemplates, template, setArgs);
|
|
10079
|
+
current = elementTemplates.applyTemplate(current, template) ?? current;
|
|
10228
10080
|
}
|
|
10229
10081
|
const result = await modeler.saveXML({ format: true });
|
|
10230
10082
|
return result.xml;
|
|
@@ -10355,6 +10207,51 @@ import { parseArgs as parseArgv } from "node:util";
|
|
|
10355
10207
|
if (!globalThis.c8ctl) throw new Error("c8ctl runtime not initialised");
|
|
10356
10208
|
var c8ctl4 = globalThis.c8ctl;
|
|
10357
10209
|
var require4 = createRequire3(import.meta.url);
|
|
10210
|
+
var ORDERED_LISTS = [
|
|
10211
|
+
["zeebe:IoMapping", "inputParameters"],
|
|
10212
|
+
["zeebe:IoMapping", "outputParameters"],
|
|
10213
|
+
["zeebe:TaskHeaders", "values"],
|
|
10214
|
+
["zeebe:Properties", "properties"]
|
|
10215
|
+
];
|
|
10216
|
+
function entryIdentity(entry) {
|
|
10217
|
+
const id = getModdleString(entry, "target") ?? getModdleString(entry, "source") ?? getModdleString(entry, "key") ?? getModdleString(entry, "name");
|
|
10218
|
+
return `${entry.$type}:${id}`;
|
|
10219
|
+
}
|
|
10220
|
+
function findContainer(element, type) {
|
|
10221
|
+
return getModdleList(
|
|
10222
|
+
getModdleElement(element.businessObject, "extensionElements"),
|
|
10223
|
+
"values"
|
|
10224
|
+
).find((v) => v.$type === type);
|
|
10225
|
+
}
|
|
10226
|
+
function snapshotOrder(element) {
|
|
10227
|
+
const order = /* @__PURE__ */ new Map();
|
|
10228
|
+
for (const [type, prop] of ORDERED_LISTS) {
|
|
10229
|
+
order.set(
|
|
10230
|
+
`${type}/${prop}`,
|
|
10231
|
+
getModdleList(findContainer(element, type), prop).map(entryIdentity)
|
|
10232
|
+
);
|
|
10233
|
+
}
|
|
10234
|
+
return order;
|
|
10235
|
+
}
|
|
10236
|
+
function restoreOrder({
|
|
10237
|
+
element,
|
|
10238
|
+
order,
|
|
10239
|
+
modeling
|
|
10240
|
+
}) {
|
|
10241
|
+
for (const [type, prop] of ORDERED_LISTS) {
|
|
10242
|
+
const container = findContainer(element, type);
|
|
10243
|
+
const before = order.get(`${type}/${prop}`) ?? [];
|
|
10244
|
+
const current = getModdleList(container, prop);
|
|
10245
|
+
const rank = (e) => {
|
|
10246
|
+
const i = before.indexOf(entryIdentity(e));
|
|
10247
|
+
return i === -1 ? before.length : i;
|
|
10248
|
+
};
|
|
10249
|
+
const sorted = [...current].sort((a, b) => rank(a) - rank(b));
|
|
10250
|
+
if (container && sorted.some((e, i) => e !== current[i])) {
|
|
10251
|
+
modeling.updateModdleProperties(element, container, { [prop]: sorted });
|
|
10252
|
+
}
|
|
10253
|
+
}
|
|
10254
|
+
}
|
|
10358
10255
|
function extractTemplateFlag(args) {
|
|
10359
10256
|
const { tokens } = parseArgv({
|
|
10360
10257
|
args,
|
|
@@ -10405,80 +10302,6 @@ For a custom template, place it under .camunda/element-templates/ next to the BP
|
|
|
10405
10302
|
);
|
|
10406
10303
|
}
|
|
10407
10304
|
}
|
|
10408
|
-
async function planEdit(modeler, elementId, setArgs, templateArg, searchDir) {
|
|
10409
|
-
const elementRegistry = modeler.get("elementRegistry");
|
|
10410
|
-
const element = elementRegistry.get(elementId);
|
|
10411
|
-
if (!element) {
|
|
10412
|
-
throw new Error(`Element "${elementId}" not found in the BPMN diagram`);
|
|
10413
|
-
}
|
|
10414
|
-
const templateId = getModdleString(element.businessObject, "modelerTemplate");
|
|
10415
|
-
if (!templateId) {
|
|
10416
|
-
throw new Error(
|
|
10417
|
-
`Element "${elementId}" has no element template applied (no zeebe:modelerTemplate attribute). Use 'apply' to apply one first.`
|
|
10418
|
-
);
|
|
10419
|
-
}
|
|
10420
|
-
const templateVersion = getModdleNumber(
|
|
10421
|
-
element.businessObject,
|
|
10422
|
-
"modelerTemplateVersion"
|
|
10423
|
-
);
|
|
10424
|
-
if (templateVersion === void 0) {
|
|
10425
|
-
throw new Error(
|
|
10426
|
-
`Element "${elementId}" has zeebe:modelerTemplate="${templateId}" but no recorded zeebe:modelerTemplateVersion. 'edit' requires a pinned version to resolve the exact template that was applied \u2014 use 'apply' with an explicit template reference instead.`
|
|
10427
|
-
);
|
|
10428
|
-
}
|
|
10429
|
-
const template = await resolveEditTemplate(
|
|
10430
|
-
templateArg,
|
|
10431
|
-
templateId,
|
|
10432
|
-
templateVersion,
|
|
10433
|
-
searchDir
|
|
10434
|
-
);
|
|
10435
|
-
const extensionElements = getModdleElement(
|
|
10436
|
-
element.businessObject,
|
|
10437
|
-
"extensionElements"
|
|
10438
|
-
);
|
|
10439
|
-
const containers = findExtensionContainers(extensionElements);
|
|
10440
|
-
const writesByChild = /* @__PURE__ */ new Map();
|
|
10441
|
-
for (const arg of setArgs) {
|
|
10442
|
-
const { bindingTypeFilter, name: name2, value } = parseSetArg(arg);
|
|
10443
|
-
const matches = findPropertiesByBindingName(
|
|
10444
|
-
template.properties,
|
|
10445
|
-
name2,
|
|
10446
|
-
bindingTypeFilter
|
|
10447
|
-
);
|
|
10448
|
-
let materialized = false;
|
|
10449
|
-
for (const prop of matches) {
|
|
10450
|
-
if (!prop.binding) continue;
|
|
10451
|
-
const effectiveValue = maybePrependFeel(prop, value);
|
|
10452
|
-
if (prop.choices) {
|
|
10453
|
-
validateDropdownValue(prop, name2, effectiveValue);
|
|
10454
|
-
}
|
|
10455
|
-
const target = resolveBindingTarget(prop.binding, containers);
|
|
10456
|
-
if (target) {
|
|
10457
|
-
materialized = true;
|
|
10458
|
-
let byProperty = writesByChild.get(target.child);
|
|
10459
|
-
if (!byProperty) {
|
|
10460
|
-
byProperty = /* @__PURE__ */ new Map();
|
|
10461
|
-
writesByChild.set(target.child, byProperty);
|
|
10462
|
-
}
|
|
10463
|
-
byProperty.set(target.property, {
|
|
10464
|
-
child: target.child,
|
|
10465
|
-
property: target.property,
|
|
10466
|
-
value: effectiveValue
|
|
10467
|
-
});
|
|
10468
|
-
}
|
|
10469
|
-
}
|
|
10470
|
-
if (!materialized) {
|
|
10471
|
-
throw new Error(
|
|
10472
|
-
`Property "${name2}" has no existing value on this element to edit (its condition may not be met, its binding type isn't supported by 'edit', or the template was never fully applied). Use 'apply --set ${name2}=...' to materialize it first.`
|
|
10473
|
-
);
|
|
10474
|
-
}
|
|
10475
|
-
}
|
|
10476
|
-
const writes = [];
|
|
10477
|
-
for (const byProperty of writesByChild.values()) {
|
|
10478
|
-
writes.push(...byProperty.values());
|
|
10479
|
-
}
|
|
10480
|
-
return { element, template, writes };
|
|
10481
|
-
}
|
|
10482
10305
|
async function editSubcommand(args) {
|
|
10483
10306
|
const logger = c8ctl4.getLogger();
|
|
10484
10307
|
installStdoutEpipeHandler();
|
|
@@ -10515,21 +10338,81 @@ async function editSubcommand(args) {
|
|
|
10515
10338
|
}
|
|
10516
10339
|
const vendorPath = resolveVendorBundle();
|
|
10517
10340
|
const vendor = require4(vendorPath);
|
|
10518
|
-
const {
|
|
10341
|
+
const {
|
|
10342
|
+
Modeler,
|
|
10343
|
+
CloudElementTemplatesCoreModule,
|
|
10344
|
+
ZeebeModdleExtension,
|
|
10345
|
+
HeadlessTextRendererModule
|
|
10346
|
+
} = vendor;
|
|
10519
10347
|
const modeler = new Modeler({
|
|
10520
|
-
additionalModules: [
|
|
10348
|
+
additionalModules: [
|
|
10349
|
+
HeadlessTextRendererModule,
|
|
10350
|
+
CloudElementTemplatesCoreModule
|
|
10351
|
+
],
|
|
10521
10352
|
moddleExtensions: { zeebe: ZeebeModdleExtension }
|
|
10522
10353
|
});
|
|
10523
|
-
|
|
10354
|
+
const searchDir = bpmnFilePath ? dirname4(input.source) : process.cwd();
|
|
10355
|
+
let template;
|
|
10524
10356
|
try {
|
|
10525
10357
|
await modeler.importXML(input.xml);
|
|
10526
|
-
|
|
10527
|
-
|
|
10528
|
-
|
|
10529
|
-
|
|
10358
|
+
const elementRegistry = modeler.get("elementRegistry");
|
|
10359
|
+
const element = elementRegistry.get(elementId);
|
|
10360
|
+
if (!element) {
|
|
10361
|
+
throw new Error(`Element "${elementId}" not found in the BPMN diagram`);
|
|
10362
|
+
}
|
|
10363
|
+
const templateId = getModdleString(
|
|
10364
|
+
element.businessObject,
|
|
10365
|
+
"modelerTemplate"
|
|
10366
|
+
);
|
|
10367
|
+
if (!templateId) {
|
|
10368
|
+
throw new Error(
|
|
10369
|
+
`Element "${elementId}" has no element template applied (no zeebe:modelerTemplate attribute). Use 'apply' to apply one first.`
|
|
10370
|
+
);
|
|
10371
|
+
}
|
|
10372
|
+
const templateVersion = getModdleNumber(
|
|
10373
|
+
element.businessObject,
|
|
10374
|
+
"modelerTemplateVersion"
|
|
10375
|
+
);
|
|
10376
|
+
if (templateVersion === void 0) {
|
|
10377
|
+
throw new Error(
|
|
10378
|
+
`Element "${elementId}" has zeebe:modelerTemplate="${templateId}" but no recorded zeebe:modelerTemplateVersion. 'edit' requires a pinned version to resolve the exact template that was applied \u2014 use 'apply' with an explicit template reference instead.`
|
|
10379
|
+
);
|
|
10380
|
+
}
|
|
10381
|
+
template = await resolveEditTemplate(
|
|
10530
10382
|
templateArg,
|
|
10531
|
-
|
|
10383
|
+
templateId,
|
|
10384
|
+
templateVersion,
|
|
10385
|
+
searchDir
|
|
10532
10386
|
);
|
|
10387
|
+
const elementTemplates = modeler.get("elementTemplates");
|
|
10388
|
+
const order = snapshotOrder(element);
|
|
10389
|
+
for (const arg of parsed.setArgs) {
|
|
10390
|
+
const { bindingTypeFilter, name: name2, value } = parseSetArg(arg);
|
|
10391
|
+
const matches = findPropertiesByBindingName(
|
|
10392
|
+
template.properties,
|
|
10393
|
+
name2,
|
|
10394
|
+
bindingTypeFilter
|
|
10395
|
+
);
|
|
10396
|
+
const active = matches.filter(
|
|
10397
|
+
(prop) => prop.binding && elementTemplates.isConditionMet(element, template.properties, prop)
|
|
10398
|
+
);
|
|
10399
|
+
if (active.length === 0) {
|
|
10400
|
+
throw new Error(
|
|
10401
|
+
`Property "${name2}" cannot be edited on this element: its condition is not met or it has no binding. Set the property its condition depends on first (in the same edit, earlier in the --set order).`
|
|
10402
|
+
);
|
|
10403
|
+
}
|
|
10404
|
+
for (const prop of active) {
|
|
10405
|
+
if (prop.choices) {
|
|
10406
|
+
validateDropdownValue(prop, name2, value);
|
|
10407
|
+
}
|
|
10408
|
+
const invalid = elementTemplates.validateProperty(value, prop);
|
|
10409
|
+
if (invalid) {
|
|
10410
|
+
throw new Error(`Invalid value for "${name2}": ${invalid}`);
|
|
10411
|
+
}
|
|
10412
|
+
elementTemplates.setPropertyValue(element, prop, value);
|
|
10413
|
+
}
|
|
10414
|
+
}
|
|
10415
|
+
restoreOrder({ element, order, modeling: modeler.get("modeling") });
|
|
10533
10416
|
} catch (error3) {
|
|
10534
10417
|
const message = error3 instanceof Error ? error3.message : String(error3);
|
|
10535
10418
|
throw new Error(`Error editing element: ${message}`);
|
|
@@ -10539,9 +10422,9 @@ async function editSubcommand(args) {
|
|
|
10539
10422
|
dryRun: true,
|
|
10540
10423
|
command: "element-template edit",
|
|
10541
10424
|
template: {
|
|
10542
|
-
id:
|
|
10543
|
-
name:
|
|
10544
|
-
version:
|
|
10425
|
+
id: template.id,
|
|
10426
|
+
name: template.name,
|
|
10427
|
+
version: template.version
|
|
10545
10428
|
},
|
|
10546
10429
|
elementId,
|
|
10547
10430
|
source: input.source,
|
|
@@ -10566,12 +10449,6 @@ async function editSubcommand(args) {
|
|
|
10566
10449
|
}
|
|
10567
10450
|
return;
|
|
10568
10451
|
}
|
|
10569
|
-
const modeling = modeler.get("modeling");
|
|
10570
|
-
for (const write of plan.writes) {
|
|
10571
|
-
modeling.updateModdleProperties(plan.element, write.child, {
|
|
10572
|
-
[write.property]: write.value
|
|
10573
|
-
});
|
|
10574
|
-
}
|
|
10575
10452
|
const result = await modeler.saveXML({ format: true });
|
|
10576
10453
|
const resultXml = result.xml;
|
|
10577
10454
|
if (writePath) {
|
|
@@ -11259,7 +11136,7 @@ var AD_HOC_PROPERTIES = [
|
|
|
11259
11136
|
"outputElement"
|
|
11260
11137
|
];
|
|
11261
11138
|
function enumerateElementValues(extensionElements) {
|
|
11262
|
-
const containers =
|
|
11139
|
+
const containers = findExtensionContainers(extensionElements);
|
|
11263
11140
|
const out = [];
|
|
11264
11141
|
const push = (bindingType, key, value) => {
|
|
11265
11142
|
if (key === void 0 || value === void 0) {
|
|
@@ -12462,7 +12339,7 @@ function applyApplication(modeler, catalog, element, application, mapWrites = []
|
|
|
12462
12339
|
)
|
|
12463
12340
|
);
|
|
12464
12341
|
let current = modeler.elementTemplates.applyTemplate(element, clone) ?? element;
|
|
12465
|
-
const containers =
|
|
12342
|
+
const containers = findExtensionContainers(
|
|
12466
12343
|
getExtensionElements(current.businessObject)
|
|
12467
12344
|
);
|
|
12468
12345
|
for (const w of writes) {
|
|
@@ -12475,7 +12352,7 @@ function applyApplication(modeler, catalog, element, application, mapWrites = []
|
|
|
12475
12352
|
if (!property.binding) {
|
|
12476
12353
|
continue;
|
|
12477
12354
|
}
|
|
12478
|
-
const target =
|
|
12355
|
+
const target = resolveBindingTarget(property.binding, containers);
|
|
12479
12356
|
if (target) {
|
|
12480
12357
|
modeler.modeling.updateModdleProperties(current, target.child, {
|
|
12481
12358
|
[target.property]: normalizeDestinationValue(property, w.value)
|
|
@@ -13653,18 +13530,18 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
|
|
|
13653
13530
|
const selected2 = selectElements(modeler, templateId, elementId);
|
|
13654
13531
|
const valuesOf2 = (element) => enumerateElementValues(getExtensionElements(element.businessObject));
|
|
13655
13532
|
redaction.values = selected2.flatMap(({ element }) => valuesOf2(element));
|
|
13656
|
-
const
|
|
13533
|
+
const pool = templatePool(
|
|
13657
13534
|
bpmnFilePath ? dirname6(resolvePath4(bpmnFilePath)) : process.cwd()
|
|
13658
13535
|
);
|
|
13659
|
-
const localVersions =
|
|
13536
|
+
const localVersions = pool.localOf(templateId).map((t) => t.version ?? 0);
|
|
13660
13537
|
if (selected2.some(
|
|
13661
13538
|
({ element }) => !localVersions.includes(
|
|
13662
13539
|
readAppliedTemplate(element.businessObject)?.version ?? 0
|
|
13663
13540
|
)
|
|
13664
13541
|
)) {
|
|
13665
|
-
|
|
13542
|
+
pool.cache();
|
|
13666
13543
|
}
|
|
13667
|
-
const lineages = (ids) => migrationTemplates(
|
|
13544
|
+
const lineages = (ids) => migrationTemplates(pool.pool(ids)).filter((t) => ids.includes(t.id));
|
|
13668
13545
|
redaction.templates = lineages([templateId]);
|
|
13669
13546
|
const toRef = parseTemplateRef(parsed.to);
|
|
13670
13547
|
if (toRef?.kind === "id") {
|
|
@@ -13680,7 +13557,7 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
|
|
|
13680
13557
|
templateId,
|
|
13681
13558
|
to: parsed.to,
|
|
13682
13559
|
executionPlatformVersion: engineVersion,
|
|
13683
|
-
templatePool:
|
|
13560
|
+
templatePool: pool
|
|
13684
13561
|
});
|
|
13685
13562
|
redaction.templates = [...lineages([templateId, target.id]), target];
|
|
13686
13563
|
const targetRecipe = recipe ?? embeddedRecipe(target);
|
|
@@ -13692,12 +13569,12 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
|
|
|
13692
13569
|
);
|
|
13693
13570
|
const hasFallback = changes.length > floors.length;
|
|
13694
13571
|
const localCompatibleVersions = compatibleTemplates(
|
|
13695
|
-
|
|
13572
|
+
pool.localOf(templateId),
|
|
13696
13573
|
engineVersion
|
|
13697
13574
|
).flatMap((t) => t.id === templateId ? [t.version ?? 0] : []);
|
|
13698
13575
|
const newestLocal = Math.max(-1, ...localCompatibleVersions);
|
|
13699
13576
|
const localLatest = latestOf(
|
|
13700
|
-
compatibleTemplates(
|
|
13577
|
+
compatibleTemplates(pool.localOf(templateId), engineVersion),
|
|
13701
13578
|
templateId
|
|
13702
13579
|
);
|
|
13703
13580
|
let localRecipe;
|
|
@@ -13717,10 +13594,10 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
|
|
|
13717
13594
|
);
|
|
13718
13595
|
return !hasFallback && floors.some((floor) => floor > newestLocal && floor > reached);
|
|
13719
13596
|
})) {
|
|
13720
|
-
|
|
13597
|
+
pool.cache();
|
|
13721
13598
|
}
|
|
13722
13599
|
const sourceLatest = target.id === templateId ? void 0 : latestOf(
|
|
13723
|
-
compatibleTemplates(
|
|
13600
|
+
compatibleTemplates(pool.pool([templateId]), engineVersion).filter(
|
|
13724
13601
|
(t) => t.id === templateId
|
|
13725
13602
|
),
|
|
13726
13603
|
templateId
|
|
@@ -13741,10 +13618,10 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
|
|
|
13741
13618
|
if (stepVersions.some(
|
|
13742
13619
|
(v) => v > lowestApplied && !localVersions.includes(v) && !(target.id === templateId && (target.version ?? 0) === v)
|
|
13743
13620
|
)) {
|
|
13744
|
-
|
|
13621
|
+
pool.cache();
|
|
13745
13622
|
}
|
|
13746
13623
|
const cache = compatibleTemplates(
|
|
13747
|
-
|
|
13624
|
+
pool.pool([templateId, target.id]),
|
|
13748
13625
|
engineVersion
|
|
13749
13626
|
);
|
|
13750
13627
|
const templates = resolveCatalog(
|
|
@@ -14164,7 +14041,7 @@ var metadata = {
|
|
|
14164
14041
|
commands: {
|
|
14165
14042
|
"element-template": {
|
|
14166
14043
|
description: "Apply, inspect, and export Camunda element templates",
|
|
14167
|
-
helpDescription: "Apply Camunda element templates to BPMN elements, inspect template metadata and properties, search the out-of-the-box template catalogue, export raw template JSON, and manage the local template cache.\n\n<template> is a local path, an https:// URL, or a template id (optionally @<version>). An id is looked up in .camunda/element-templates/ (next to the BPMN file, or in the current directory, or any parent of either) and in Desktop Modeler's resources/element-templates/ before the OOTB cache.\n\napply --set name=value targets a property by binding name (run `get-properties` to discover names). Pass --set multiple times to set multiple properties. Prefix with a binding type (input | output | header | property | taskDefinition) when the same name is bound across multiple types \u2014 e.g. --set input:correlationKey=order-42.\n\nedit --set name=value updates a property on an element that already has a template applied, without re-running template application \u2014 it never resets other template-owned content (including hand-customized extension values a template doesn't fully control) and doesn't need a <template> argument (it reads zeebe:modelerTemplate/-Version off the element and resolves it from .camunda/element-templates/ next to the BPMN file or a parent directory, then the OOTB cache). Pass --template <template> to point at a custom template explicitly; it must match the element's recorded id/version.
|
|
14044
|
+
helpDescription: "Apply Camunda element templates to BPMN elements, inspect template metadata and properties, search the out-of-the-box template catalogue, export raw template JSON, and manage the local template cache.\n\n<template> is a local path, an https:// URL, or a template id (optionally @<version>). An id is looked up in .camunda/element-templates/ (next to the BPMN file, or in the current directory, or any parent of either) and in Desktop Modeler's resources/element-templates/ before the OOTB cache.\n\napply --set name=value targets a property by binding name (run `get-properties` to discover names). Pass --set multiple times to set multiple properties. Prefix with a binding type (input | output | header | property | taskDefinition) when the same name is bound across multiple types \u2014 e.g. --set input:correlationKey=order-42.\n\nedit --set name=value updates a property on an element that already has a template applied, without re-running template application \u2014 it never resets other template-owned content (including hand-customized extension values a template doesn't fully control) and doesn't need a <template> argument (it reads zeebe:modelerTemplate/-Version off the element and resolves it from .camunda/element-templates/ next to the BPMN file or a parent directory, then the OOTB cache). Pass --template <template> to point at a custom template explicitly; it must match the element's recorded id/version. A property whose condition is not met is rejected; --set args apply in order, so set the property a condition depends on first (e.g. --set method=POST --set body=...). Values are checked against the property's constraints (notEmpty, pattern, length, dropdown choices).\n\nupdate <template-id> moves every element that uses that template to its latest compatible version, or to the template given with --to <template>[@<n>] (an id, path or URL; an id resolves as above, local templates first); pass an element id to update only that element. Values the target binds under another key are moved when it carries a migration recipe (metadata.migratesFrom) or one is passed with --recipe <file>; --map <from>=<to> moves a value per element when no recipe covers it; the rest carry over by key. A report lists what was dropped, added, moved and changed. --dry-run previews the migration and writes nothing; it exits 1 when an element would fail to migrate or the write would need --allow-lossy. The file is written once, and only if every element migrates.\n\nFEEL values: properties with feel=required always store a FEEL expression (prefixed with `=`). For those properties, c8ctl auto-prepends `=` when it is missing, so `--set key=orderId` writes `=orderId` to the BPMN \u2014 equivalent to `--set key==orderId`. Properties with feel=optional keep the value verbatim; you must supply the `=` prefix yourself when you want to write a FEEL expression for those. Boolean and Number inputs/outputs (and any Boolean/Number property declaring feel) are stored as FEEL, as the Modeler does \u2014 `--set timeout=30` writes `=30`. Three forms for feel=required properties:\n --set key='=value' canonical: single-quoted FEEL value (explicit =)\n --set 'key==value' compact: whole argument single-quoted (explicit =)\n --set key=value shorthand: = auto-prepended (feel=required only)\nLeading/trailing whitespace is stripped from values, and whitespace immediately after a FEEL `=` prefix is also stripped, so `--set 'key== value'` is equivalent to `--set 'key==value'`.",
|
|
14168
14045
|
subcommands: [
|
|
14169
14046
|
{
|
|
14170
14047
|
name: "search",
|