@camunda8/cli 3.2.0-alpha.2 → 3.2.0-alpha.4

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.
Files changed (79) hide show
  1. package/CONTEXT.md +7 -15
  2. package/EXAMPLES.md +233 -1
  3. package/README.md +44 -177
  4. package/dist/command-dispatch.js +1 -1
  5. package/dist/command-dispatch.js.map +1 -1
  6. package/dist/command-registry.d.ts +19 -7
  7. package/dist/command-registry.d.ts.map +1 -1
  8. package/dist/command-registry.js +47 -7
  9. package/dist/command-registry.js.map +1 -1
  10. package/dist/commands/deploy.d.ts +13 -0
  11. package/dist/commands/deploy.d.ts.map +1 -0
  12. package/dist/commands/deploy.js +91 -0
  13. package/dist/commands/deploy.js.map +1 -0
  14. package/dist/{deployments.d.ts → commands/helpers/deploy-helpers.d.ts} +49 -12
  15. package/dist/commands/helpers/deploy-helpers.d.ts.map +1 -0
  16. package/dist/{deployments.js → commands/helpers/deploy-helpers.js} +16 -97
  17. package/dist/commands/helpers/deploy-helpers.js.map +1 -0
  18. package/dist/commands/identity-authorizations.d.ts +0 -13
  19. package/dist/commands/identity-authorizations.d.ts.map +1 -1
  20. package/dist/commands/identity-authorizations.js +1 -1
  21. package/dist/commands/identity-authorizations.js.map +1 -1
  22. package/dist/commands/identity.d.ts +1 -21
  23. package/dist/commands/identity.d.ts.map +1 -1
  24. package/dist/commands/identity.js +7 -8
  25. package/dist/commands/identity.js.map +1 -1
  26. package/dist/commands/profiles.d.ts +0 -32
  27. package/dist/commands/profiles.d.ts.map +1 -1
  28. package/dist/commands/profiles.js +5 -36
  29. package/dist/commands/profiles.js.map +1 -1
  30. package/dist/commands/watch.d.ts.map +1 -1
  31. package/dist/commands/watch.js +2 -2
  32. package/dist/commands/watch.js.map +1 -1
  33. package/dist/default-plugins/bpmn/c8ctl-plugin.js +7374 -137
  34. package/dist/default-plugins/bpmn/package.json +8 -1
  35. package/dist/default-plugins/element-template/c8ctl-plugin.js +10194 -248
  36. package/dist/default-plugins/element-template/package.json +11 -1
  37. package/dist/default-plugins/feel/c8ctl-plugin.js +14030 -584
  38. package/dist/default-plugins/feel/package.json +4 -1
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +16 -9
  41. package/dist/index.js.map +1 -1
  42. package/dist/resource-extensions.d.ts.map +1 -0
  43. package/dist/resource-extensions.js.map +1 -0
  44. package/dist/vendor/bpmnlint.cjs +25907 -0
  45. package/package.json +11 -13
  46. package/dist/commands/resource-extensions.d.ts.map +0 -1
  47. package/dist/commands/resource-extensions.js.map +0 -1
  48. package/dist/default-plugins/bpmn/c8ctl-plugin.js.map +0 -1
  49. package/dist/default-plugins/bpmn/format.js +0 -64
  50. package/dist/default-plugins/bpmn/format.js.map +0 -1
  51. package/dist/default-plugins/bpmn/lint.js +0 -323
  52. package/dist/default-plugins/bpmn/lint.js.map +0 -1
  53. package/dist/default-plugins/element-template/c8ctl-plugin.js.map +0 -1
  54. package/dist/default-plugins/element-template/commands/apply.js +0 -337
  55. package/dist/default-plugins/element-template/commands/apply.js.map +0 -1
  56. package/dist/default-plugins/element-template/commands/get-properties.js +0 -350
  57. package/dist/default-plugins/element-template/commands/get-properties.js.map +0 -1
  58. package/dist/default-plugins/element-template/commands/get.js +0 -107
  59. package/dist/default-plugins/element-template/commands/get.js.map +0 -1
  60. package/dist/default-plugins/element-template/commands/info.js +0 -196
  61. package/dist/default-plugins/element-template/commands/info.js.map +0 -1
  62. package/dist/default-plugins/element-template/commands/search.js +0 -106
  63. package/dist/default-plugins/element-template/commands/search.js.map +0 -1
  64. package/dist/default-plugins/element-template/commands/sync.js +0 -36
  65. package/dist/default-plugins/element-template/commands/sync.js.map +0 -1
  66. package/dist/default-plugins/element-template/helpers.js +0 -515
  67. package/dist/default-plugins/element-template/helpers.js.map +0 -1
  68. package/dist/default-plugins/element-template/marketplace.js +0 -597
  69. package/dist/default-plugins/element-template/marketplace.js.map +0 -1
  70. package/dist/default-plugins/element-template/template-ref.js +0 -243
  71. package/dist/default-plugins/element-template/template-ref.js.map +0 -1
  72. package/dist/default-plugins/feel/c8ctl-plugin.js.map +0 -1
  73. package/dist/default-plugins/hello-world/README.md +0 -161
  74. package/dist/default-plugins/hello-world/c8ctl-plugin.js +0 -69
  75. package/dist/default-plugins/hello-world/package.json +0 -8
  76. package/dist/deployments.d.ts.map +0 -1
  77. package/dist/deployments.js.map +0 -1
  78. /package/dist/{commands/resource-extensions.d.ts → resource-extensions.d.ts} +0 -0
  79. /package/dist/{commands/resource-extensions.js → resource-extensions.js} +0 -0
@@ -1,597 +0,0 @@
1
- /**
2
- * Marketplace OOTB element-template index.
3
- *
4
- * Source: GET https://marketplace.cloud.camunda.io/api/v1/ootb-connectors
5
- * → { [id]: [{ version, ref, engine: { camunda: "^8.x" } }, ...] }
6
- *
7
- * Each `ref` is a commit-pinned raw.githubusercontent.com URL → immutable.
8
- * We download every ref once, inline the templates into a single
9
- * `templates.json` cache file, and inject `metadata.upstreamRef = <ref>` so
10
- * subsequent syncs can skip already-cached entries (matches Modeler's
11
- * approach in `app/lib/template-updater/util.js`).
12
- */
13
- import { closeSync, existsSync, mkdirSync, openSync, readFileSync, renameSync, unlinkSync, writeFileSync, writeSync, } from "node:fs";
14
- import { join } from "node:path";
15
- import semver from "semver";
16
- import { isRecord, USER_AGENT } from "./helpers.js";
17
- const DEFAULT_OOTB_URL = "https://marketplace.cloud.camunda.io/api/v1/ootb-connectors";
18
- const FETCH_CONCURRENCY = 12;
19
- const STALE_AFTER_MS = 7 * 24 * 60 * 60 * 1000; // 7 days
20
- const FETCH_TIMEOUT_MS = 30_000; // 30 s per HTTP request
21
- // Backstop for ghost locks left by PID-recycled crashed syncs. Kept
22
- // well above realistic sync runtimes so a live but slow sync's lock
23
- // is never reclaimed.
24
- const SYNC_LOCK_STALE_AFTER_MS = 60 * 60 * 1000; // 60 minutes
25
- // ---------------------------------------------------------------------------
26
- // Paths
27
- // ---------------------------------------------------------------------------
28
- export function getMarketplaceUrl() {
29
- return process.env.C8CTL_OOTB_ELEMENT_TEMPLATES_URL || DEFAULT_OOTB_URL;
30
- }
31
- export function getCacheDir() {
32
- if (!globalThis.c8ctl?.getUserDataDir) {
33
- throw new Error("c8ctl runtime is not available; cannot resolve element-template cache dir.");
34
- }
35
- return join(globalThis.c8ctl.getUserDataDir(), "element-templates");
36
- }
37
- function getCachePath() {
38
- return join(getCacheDir(), "templates.json");
39
- }
40
- function getFetchedAtPath() {
41
- return join(getCacheDir(), "fetched-at");
42
- }
43
- function getSyncLockPath() {
44
- return join(getCacheDir(), ".sync.lock");
45
- }
46
- /**
47
- * Read `error.code` if the thrown value carries one. Errors from the
48
- * `node:fs` and `node:process` APIs all set `code` to a `string`; this
49
- * narrows safely without an `as NodeJS.ErrnoException` cast.
50
- */
51
- function getErrorCode(error) {
52
- if (isRecord(error) && typeof error.code === "string") {
53
- return error.code;
54
- }
55
- return undefined;
56
- }
57
- function isProcessAlive(pid) {
58
- try {
59
- // Signal 0 doesn't deliver a signal — it just tests permission /
60
- // existence. ESRCH means the PID is gone.
61
- process.kill(pid, 0);
62
- return true;
63
- }
64
- catch (error) {
65
- // EPERM means the process exists but we lack permission — still alive.
66
- return getErrorCode(error) === "EPERM";
67
- }
68
- }
69
- function readLockPayload(path) {
70
- try {
71
- const raw = readFileSync(path, "utf-8");
72
- const parsed = JSON.parse(raw);
73
- if (isRecord(parsed) &&
74
- typeof parsed.pid === "number" &&
75
- typeof parsed.startedAt === "number") {
76
- return { pid: parsed.pid, startedAt: parsed.startedAt };
77
- }
78
- }
79
- catch {
80
- // Unreadable / unparsable lock counts as stale.
81
- }
82
- return null;
83
- }
84
- function tryCreateLock(path, payload) {
85
- try {
86
- const fd = openSync(path, "wx", 0o644);
87
- try {
88
- writeSync(fd, JSON.stringify(payload));
89
- }
90
- finally {
91
- closeSync(fd);
92
- }
93
- return true;
94
- }
95
- catch (error) {
96
- if (getErrorCode(error) === "EEXIST") {
97
- return false;
98
- }
99
- throw error;
100
- }
101
- }
102
- /**
103
- * Acquire the sync lock or throw with a user-actionable message.
104
- *
105
- * The lock is a regular file at `<cacheDir>/.sync.lock` holding
106
- * `{pid, startedAt}` JSON. We use `openSync("wx")` for atomic create —
107
- * two concurrent attempts cannot both win on the same filesystem.
108
- *
109
- * If an existing lock is from a dead PID or older than
110
- * `SYNC_LOCK_STALE_AFTER_MS`, we treat it as stale, log, and retry
111
- * the create once. A persistent EEXIST after that is a real race with
112
- * another live sync — surface it.
113
- */
114
- function acquireSyncLock(logger) {
115
- const dir = getCacheDir();
116
- mkdirSync(dir, { recursive: true });
117
- const path = getSyncLockPath();
118
- const payload = {
119
- pid: process.pid,
120
- startedAt: Date.now(),
121
- };
122
- if (tryCreateLock(path, payload)) {
123
- return;
124
- }
125
- const existing = readLockPayload(path);
126
- const age = existing ? Date.now() - existing.startedAt : Infinity;
127
- const stale = existing === null ||
128
- !isProcessAlive(existing.pid) ||
129
- age > SYNC_LOCK_STALE_AFTER_MS;
130
- if (stale) {
131
- if (existing) {
132
- logger.warn(`Removed stale sync lock from pid ${existing.pid} (age ${Math.round(age / 1000)}s).`);
133
- }
134
- try {
135
- unlinkSync(path);
136
- }
137
- catch {
138
- // Someone else may have just cleaned it up — fine, we'll retry below.
139
- }
140
- if (tryCreateLock(path, payload)) {
141
- return;
142
- }
143
- }
144
- const detail = existing
145
- ? `pid ${existing.pid}, started ${new Date(existing.startedAt).toISOString()}`
146
- : "unknown owner";
147
- throw new Error(`Another sync is in progress (${detail}). ` +
148
- `Wait for it to finish or remove ${path} if you're sure no other sync is running.`);
149
- }
150
- function releaseSyncLock() {
151
- try {
152
- unlinkSync(getSyncLockPath());
153
- }
154
- catch {
155
- // Best-effort — the lock may already be gone if a signal handler
156
- // raced with the normal `finally`.
157
- }
158
- }
159
- /**
160
- * Run `body` while the sync lock is held. Installs signal handlers
161
- * so the lock is released on SIGINT/SIGTERM (otherwise a Ctrl-C
162
- * during sync would orphan the lockfile, leaving the next run to
163
- * wait the stale window). Only the lock-release handlers we add are
164
- * removed in `finally`; any pre-existing listeners are left untouched.
165
- */
166
- async function withSyncLock(logger, body) {
167
- acquireSyncLock(logger);
168
- const signals = ["SIGINT", "SIGTERM", "SIGHUP"];
169
- const handlers = new Map();
170
- for (const sig of signals) {
171
- const handler = () => {
172
- releaseSyncLock();
173
- // Re-raise the signal with the default action so the process
174
- // actually exits with the expected status. Remove our listener
175
- // first so we don't recurse.
176
- process.removeListener(sig, handler);
177
- process.kill(process.pid, sig);
178
- };
179
- handlers.set(sig, handler);
180
- process.on(sig, handler);
181
- }
182
- try {
183
- return await body();
184
- }
185
- finally {
186
- for (const [sig, handler] of handlers) {
187
- process.removeListener(sig, handler);
188
- }
189
- releaseSyncLock();
190
- }
191
- }
192
- // ---------------------------------------------------------------------------
193
- // Cache I/O
194
- // ---------------------------------------------------------------------------
195
- function isTemplateArray(value) {
196
- return (Array.isArray(value) &&
197
- value.every((item) => isRecord(item) && Array.isArray(item.properties)));
198
- }
199
- export function loadCache() {
200
- const path = getCachePath();
201
- if (!existsSync(path))
202
- return null;
203
- let parsed;
204
- try {
205
- parsed = JSON.parse(readFileSync(path, "utf-8"));
206
- }
207
- catch (error) {
208
- const message = error instanceof Error ? error.message : String(error);
209
- throw new Error(`Element template cache is corrupt at ${path}: ${message}`);
210
- }
211
- if (!Array.isArray(parsed)) {
212
- throw new Error(`Element template cache is corrupt at ${path}: expected an array`);
213
- }
214
- if (!isTemplateArray(parsed)) {
215
- throw new Error(`Element template cache is corrupt at ${path}: entries must be template objects with a properties array`);
216
- }
217
- return parsed;
218
- }
219
- function loadFetchedAt() {
220
- const path = getFetchedAtPath();
221
- if (!existsSync(path))
222
- return null;
223
- const value = readFileSync(path, "utf-8").trim();
224
- const ms = Number(value);
225
- return Number.isFinite(ms) ? ms : null;
226
- }
227
- /**
228
- * Write `contents` to `target` via a sibling temp file + atomic
229
- * `renameSync`. Readers either see the old file or the new file —
230
- * never a truncated mid-write state. POSIX `rename` is atomic on the
231
- * same filesystem (which a sibling in the same directory always is).
232
- */
233
- function atomicWriteFileSync(target, contents) {
234
- const tmp = `${target}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
235
- try {
236
- writeFileSync(tmp, contents, "utf-8");
237
- renameSync(tmp, target);
238
- }
239
- catch (error) {
240
- try {
241
- unlinkSync(tmp);
242
- }
243
- catch {
244
- // Best-effort cleanup — the original error is the one that matters.
245
- }
246
- throw error;
247
- }
248
- }
249
- function saveCache(templates) {
250
- const dir = getCacheDir();
251
- mkdirSync(dir, { recursive: true });
252
- atomicWriteFileSync(getCachePath(), `${JSON.stringify(templates, null, 2)}\n`);
253
- atomicWriteFileSync(getFetchedAtPath(), String(Date.now()));
254
- }
255
- export function isCacheStale() {
256
- const fetchedAt = loadFetchedAt();
257
- if (fetchedAt === null)
258
- return true;
259
- return Date.now() - fetchedAt > STALE_AFTER_MS;
260
- }
261
- export function getCacheAgeDays() {
262
- const fetchedAt = loadFetchedAt();
263
- if (fetchedAt === null)
264
- return null;
265
- return Math.floor((Date.now() - fetchedAt) / (24 * 60 * 60 * 1000));
266
- }
267
- export function nudgeIfStale(logger) {
268
- if (!existsSync(getCachePath()))
269
- return;
270
- if (!isCacheStale())
271
- return;
272
- const days = getCacheAgeDays();
273
- const ageText = days === null ? "stale" : `${days} day${days === 1 ? "" : "s"} old`;
274
- logger.warn(`Element template cache is ${ageText}. ` +
275
- "Run 'c8ctl element-template sync' to refresh.");
276
- }
277
- // ---------------------------------------------------------------------------
278
- // HTTP
279
- // ---------------------------------------------------------------------------
280
- async function fetchJson(url) {
281
- const response = await fetch(url, {
282
- headers: { "User-Agent": USER_AGENT },
283
- signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
284
- });
285
- if (!response.ok) {
286
- throw new Error(`HTTP ${response.status} ${response.statusText} for ${url}`);
287
- }
288
- return response.json();
289
- }
290
- async function fetchIndex() {
291
- const raw = await fetchJson(getMarketplaceUrl());
292
- if (!isRecord(raw)) {
293
- throw new Error("Marketplace index is not a JSON object");
294
- }
295
- // Trust the upstream shape — schema-validated at the marketplace.
296
- const result = {};
297
- for (const [id, value] of Object.entries(raw)) {
298
- if (!Array.isArray(value))
299
- continue;
300
- const entries = [];
301
- for (const entry of value) {
302
- if (!isRecord(entry))
303
- continue;
304
- entries.push({
305
- version: typeof entry.version === "number" ? entry.version : undefined,
306
- ref: typeof entry.ref === "string" ? entry.ref : undefined,
307
- engine: isRecord(entry.engine)
308
- ? {
309
- camunda: typeof entry.engine.camunda === "string"
310
- ? entry.engine.camunda
311
- : undefined,
312
- }
313
- : undefined,
314
- });
315
- }
316
- result[id] = entries;
317
- }
318
- return result;
319
- }
320
- function isTemplateLike(value) {
321
- return isRecord(value) && Array.isArray(value.properties);
322
- }
323
- async function fetchTemplate(url) {
324
- const raw = await fetchJson(url);
325
- if (!isTemplateLike(raw)) {
326
- throw new Error(`Fetched template at ${url} did not match expected shape`);
327
- }
328
- return raw;
329
- }
330
- // ---------------------------------------------------------------------------
331
- // Sync
332
- // ---------------------------------------------------------------------------
333
- /**
334
- * Run `fn` over `items` with at most `concurrency` in flight.
335
- * Each fn() must handle its own errors — exceptions abort the pool.
336
- */
337
- async function pool(items, concurrency, fn) {
338
- const queue = items.slice();
339
- const workers = Array.from({ length: Math.min(concurrency, queue.length) }, async () => {
340
- while (queue.length > 0) {
341
- const item = queue.shift();
342
- if (item === undefined)
343
- break;
344
- await fn(item);
345
- }
346
- });
347
- await Promise.all(workers);
348
- }
349
- /**
350
- * Flatten the marketplace index `{ id: [{version, ref, engine}] }` into a flat
351
- * list of `{ id, version, ref, engine }` entries, dropping legacy entries with
352
- * no `version`.
353
- */
354
- function flattenIndex(index) {
355
- const entries = [];
356
- for (const [id, versions] of Object.entries(index)) {
357
- for (const entry of versions) {
358
- if (entry.version === undefined || entry.ref === undefined)
359
- continue;
360
- entries.push({
361
- id,
362
- version: entry.version,
363
- ref: entry.ref,
364
- engine: entry.engine,
365
- });
366
- }
367
- }
368
- return entries;
369
- }
370
- /**
371
- * Sync the cache with the marketplace.
372
- *
373
- * - Always re-fetches the index.
374
- * - Fetches refs that aren't already cached (matches by `metadata.upstreamRef`).
375
- * - With `prune: true`, drops cached entries whose `upstreamRef` is no longer
376
- * in the fresh index.
377
- *
378
- * Per-template fetch failures are logged + counted but do not abort the run.
379
- *
380
- * Returns a summary `{ total, fetched, cached, errors, pruned }`.
381
- */
382
- export async function syncTemplates({ logger, prune = false, }) {
383
- return withSyncLock(logger, () => syncTemplatesLocked({ logger, prune }));
384
- }
385
- async function syncTemplatesLocked({ logger, prune, }) {
386
- logger.info(`Fetching index from ${getMarketplaceUrl()} ...`);
387
- const index = await fetchIndex();
388
- const entries = flattenIndex(index);
389
- logger.info(`Index has ${entries.length} template versions across ${Object.keys(index).length} connectors.`);
390
- let existing;
391
- try {
392
- existing = loadCache() || [];
393
- }
394
- catch (error) {
395
- const message = error instanceof Error ? error.message : String(error);
396
- logger.warn(`Corrupt cache — starting fresh: ${message}`);
397
- existing = [];
398
- }
399
- const byUpstreamRef = new Map();
400
- for (const tpl of existing) {
401
- const ref = tpl.metadata?.upstreamRef;
402
- if (ref)
403
- byUpstreamRef.set(ref, tpl);
404
- }
405
- const freshRefs = new Set(entries.map((e) => e.ref));
406
- const toFetch = entries.filter((e) => !byUpstreamRef.has(e.ref));
407
- logger.info(`${byUpstreamRef.size > 0
408
- ? `Reusing ${entries.length - toFetch.length} cached, `
409
- : ""}fetching ${toFetch.length} new...`);
410
- let fetched = 0;
411
- let errors = 0;
412
- let progress = 0;
413
- const fetchedTemplates = [];
414
- await pool(toFetch, FETCH_CONCURRENCY, async (entry) => {
415
- progress += 1;
416
- const myProgress = progress;
417
- const label = `${entry.id}@${entry.version}`;
418
- try {
419
- const template = await fetchTemplate(entry.ref);
420
- template.metadata = template.metadata || {};
421
- template.metadata.upstreamRef = entry.ref;
422
- fetchedTemplates.push(template);
423
- fetched += 1;
424
- logger.info(` [${myProgress}/${toFetch.length}] ${label}`);
425
- }
426
- catch (error) {
427
- errors += 1;
428
- const message = error instanceof Error ? error.message : String(error);
429
- logger.warn(` [${myProgress}/${toFetch.length}] ${label} — ${message}`);
430
- }
431
- });
432
- // Build the new cache: keep cached entries that are still in the index,
433
- // plus everything we just fetched. Sort fetched entries by id+version so
434
- // cache order (and therefore search result order) is deterministic
435
- // regardless of network timing.
436
- fetchedTemplates.sort((a, b) => {
437
- const idCmp = (a.id ?? "").localeCompare(b.id ?? "");
438
- if (idCmp !== 0)
439
- return idCmp;
440
- return (a.version ?? 0) - (b.version ?? 0);
441
- });
442
- const next = [];
443
- for (const tpl of existing) {
444
- const ref = tpl.metadata?.upstreamRef;
445
- if (ref && freshRefs.has(ref)) {
446
- next.push(tpl);
447
- }
448
- }
449
- next.push(...fetchedTemplates);
450
- // `pruned` = cached entries whose upstreamRef no longer appears in the
451
- // fresh index (or that never had one). The "without --prune" branch
452
- // below preserves these entries; with --prune we drop them, and the
453
- // summary line reports that count to the user.
454
- let pruned = 0;
455
- if (prune) {
456
- pruned = existing.filter((t) => {
457
- const ref = t.metadata?.upstreamRef;
458
- return ref === undefined || !freshRefs.has(ref);
459
- }).length;
460
- }
461
- // Without --prune, keep templates whose upstreamRef vanished from the index
462
- // (e.g. user wants to retain an older version that was removed upstream).
463
- if (!prune) {
464
- for (const tpl of existing) {
465
- const ref = tpl.metadata?.upstreamRef;
466
- if (ref && !freshRefs.has(ref) && !next.includes(tpl)) {
467
- next.push(tpl);
468
- }
469
- }
470
- }
471
- saveCache(next);
472
- const summary = {
473
- total: next.length,
474
- fetched,
475
- cached: entries.length - toFetch.length,
476
- errors,
477
- pruned,
478
- };
479
- logger.info(`Sync complete: ${summary.fetched} fetched, ${summary.cached} cached` +
480
- `${summary.errors > 0 ? `, ${summary.errors} errors` : ""}` +
481
- `${prune ? `, ${summary.pruned} pruned` : ""}.`);
482
- return summary;
483
- }
484
- /**
485
- * Sentinel error message used by all subcommands that need the cache
486
- * present. Phrased as a directive so callers don't have to invent
487
- * their own copy.
488
- */
489
- export const CACHE_NOT_FOUND_MESSAGE = "Element template cache not found. Run 'c8ctl element-template sync' to download it first.";
490
- /**
491
- * Throw a uniform error when the cache is missing. We deliberately do
492
- * NOT auto-bootstrap — bootstrap progress goes to stdout via
493
- * `logger.info`, which would corrupt any pipe the caller has set up
494
- * (apply | bpmn lint, get > template.json, ...). Sync is one explicit
495
- * command and the error tells the user to run it.
496
- */
497
- export function requireCachePresent() {
498
- if (existsSync(getCachePath())) {
499
- return;
500
- }
501
- throw new Error(CACHE_NOT_FOUND_MESSAGE);
502
- }
503
- // ---------------------------------------------------------------------------
504
- // Lookup & search
505
- // ---------------------------------------------------------------------------
506
- /**
507
- * Return all cached templates matching `id`. Empty if none.
508
- */
509
- export function findById(id) {
510
- const cache = loadCache();
511
- if (!cache)
512
- return [];
513
- return cache.filter((t) => t.id === id);
514
- }
515
- /**
516
- * Pick the template version best matching the BPMN's executionPlatformVersion.
517
- *
518
- * - If `version` is given: exact `version` match required.
519
- * - If `executionPlatformVersion` is given: highest `version` whose
520
- * `engines.camunda` is satisfied by `coerce(executionPlatformVersion)`.
521
- * Templates without `engines.camunda` are treated as compatible with any
522
- * version (legacy fallback).
523
- * - Otherwise: highest `version`.
524
- *
525
- * Returns `null` if no candidate matches.
526
- */
527
- export function pickVersion(templates, { version, executionPlatformVersion } = {}) {
528
- if (templates.length === 0)
529
- return null;
530
- if (version !== undefined) {
531
- const exact = templates.find((t) => Number(t.version) === Number(version));
532
- return exact || null;
533
- }
534
- let candidates = templates.filter((t) => t.version !== undefined);
535
- if (executionPlatformVersion) {
536
- const coerced = semver.coerce(executionPlatformVersion);
537
- if (coerced) {
538
- candidates = candidates.filter((t) => {
539
- const constraint = t.engines?.camunda;
540
- if (!constraint)
541
- return true;
542
- return semver.satisfies(coerced, constraint);
543
- });
544
- }
545
- }
546
- if (candidates.length === 0)
547
- return null;
548
- return candidates.reduce((best, cur) => Number(cur.version) > Number(best.version) ? cur : best);
549
- }
550
- /**
551
- * Substring search on name + description + keywords (case-insensitive).
552
- * Mirrors Modeler's discovery path. Deprecated versions are excluded
553
- * before the per-id latest-version reduction so that if the newest
554
- * version of a connector is deprecated, the latest non-deprecated
555
- * version is still discoverable.
556
- */
557
- export function searchTemplates(query, { executionPlatformVersion } = {}) {
558
- const cache = loadCache() || [];
559
- const q = query.toLowerCase();
560
- let matches = cache
561
- .filter((t) => {
562
- const name = (t.name || "").toLowerCase();
563
- const description = (t.description || "").toLowerCase();
564
- const id = (t.id || "").toLowerCase();
565
- const keywords = (t.keywords ?? []).map((k) => k.toLowerCase()).join(" ");
566
- return (name.includes(q) ||
567
- description.includes(q) ||
568
- id.includes(q) ||
569
- keywords.includes(q));
570
- })
571
- // Filter deprecated before per-id reduction so the latest
572
- // non-deprecated version surfaces when the newest is deprecated.
573
- .filter((t) => !t.deprecated);
574
- if (executionPlatformVersion) {
575
- const coerced = semver.coerce(executionPlatformVersion);
576
- if (coerced) {
577
- matches = matches.filter((t) => {
578
- const constraint = t.engines?.camunda;
579
- if (!constraint)
580
- return true;
581
- return semver.satisfies(coerced, constraint);
582
- });
583
- }
584
- }
585
- // Reduce to the latest version per id.
586
- const byId = new Map();
587
- for (const t of matches) {
588
- if (t.id === undefined)
589
- continue;
590
- const existing = byId.get(t.id);
591
- if (!existing || Number(t.version || 0) > Number(existing.version || 0)) {
592
- byId.set(t.id, t);
593
- }
594
- }
595
- return [...byId.values()];
596
- }
597
- //# sourceMappingURL=marketplace.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"marketplace.js","sourceRoot":"","sources":["../../../default-plugins/element-template/marketplace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACN,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,UAAU,EACV,aAAa,EACb,SAAS,GACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EA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