@walkeros/cli 4.3.1-next-1784373088875 → 4.3.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/dist/index.d.ts CHANGED
@@ -218,6 +218,15 @@ interface BundleStats {
218
218
  * payload by construction.
219
219
  */
220
220
  declare function buildDataPayload(flowSettings: Flow): Record<string, unknown>;
221
+ /**
222
+ * Generate a stage 2 entry file for wrapping an ALREADY-embedded skeleton.
223
+ *
224
+ * Unlike `generateWebEntry`, this variant imports `__configData` from the
225
+ * skeleton (instead of inlining a `dataPayload` string). Used by the
226
+ * publish-time `wrapSkeleton` helper, which runs on a stage 1 skeleton
227
+ * produced via `bundle({ skipWrapper: true })` — those skeletons already
228
+ * export `__configData` alongside `wireConfig` and `startFlow`.
229
+ */
221
230
  /**
222
231
  * Preview activation wiring. When present and enabled, the generated entry
223
232
  * imports the activator from core and lets it decide whether a preview bundle
@@ -9837,8 +9846,6 @@ interface components {
9837
9846
  flowId: string;
9838
9847
  flowSettingsId: string;
9839
9848
  projectId: string;
9840
- /** @example k9x2m4p7abcd */
9841
- token: string;
9842
9849
  /** Format: uri */
9843
9850
  bundleUrl: string;
9844
9851
  activationUrl: string | null;
@@ -9893,17 +9900,33 @@ interface components {
9893
9900
  serverFlowName: string | null;
9894
9901
  serverEndpoint: string | null;
9895
9902
  web: components['schemas']['ObserveSessionWeb'];
9903
+ server: components['schemas']['ObserveSessionServer'];
9904
+ /** Format: date-time */
9905
+ expiresAt: string;
9906
+ recordsReceived: number;
9896
9907
  createdBy: string;
9897
9908
  /** Format: date-time */
9898
9909
  createdAt: string;
9899
9910
  };
9900
9911
  ObserveSessionWeb: {
9901
- previewId: string;
9902
- token: string;
9912
+ /** Format: uri */
9913
+ activationUrl: string | null;
9914
+ credential: string;
9903
9915
  previewEnabled: boolean;
9904
9916
  /** Format: uri */
9905
9917
  bundleUrl: string;
9906
9918
  } | null;
9919
+ ObserveSessionServer: {
9920
+ /** Format: uri */
9921
+ endpoint: string | null;
9922
+ env: components['schemas']['ObserveSessionServerEnv'];
9923
+ } | null;
9924
+ ObserveSessionServerEnv: {
9925
+ /** Format: uri */
9926
+ WALKEROS_OBSERVER_URL: string;
9927
+ WALKEROS_DEPLOYMENT_ID: string;
9928
+ WALKEROS_INGEST_TOKEN: string;
9929
+ };
9907
9930
  ObserveSessionJourneysResponse: {
9908
9931
  /** @example ses_abc123xyz456 */
9909
9932
  sessionId: string;
@@ -9921,7 +9944,12 @@ interface components {
9921
9944
  CreateObserveSessionRequest: {
9922
9945
  settingsName: string;
9923
9946
  force?: boolean;
9947
+ replace?: boolean;
9948
+ level?: components['schemas']['ObserveLevel'];
9949
+ origins?: string[];
9924
9950
  };
9951
+ /** @enum {string} */
9952
+ ObserveLevel: 'off' | 'standard' | 'trace';
9925
9953
  ObserveSessionHeartbeatResponse: {
9926
9954
  /** @enum {boolean} */
9927
9955
  ok: true;
@@ -11511,24 +11539,13 @@ interface WrapSkeletonOptions {
11511
11539
  * passing both throws.
11512
11540
  */
11513
11541
  previewGrantTargets?: string[];
11514
- /**
11515
- * Browser-only: telemetry wiring. When provided, the wrapped bundle
11516
- * installs an observer built via `createTelemetryObserver` onto
11517
- * `collector.observers` and forwards FlowState records to `observerUrl`
11518
- * using `createBatchedPoster`.
11519
- *
11520
- * Omit (or pass `level: 'off'`) to ship a bundle with zero telemetry
11521
- * plumbing. Mutually exclusive with `observe`.
11522
- */
11523
- telemetry?: TelemetryBundleOptions;
11524
11542
  /**
11525
11543
  * Browser-only: STATIC observe connect config baked onto the startFlow
11526
11544
  * config. PUBLIC values only (`url` + `binding`, plus optional
11527
11545
  * `flowId`/`level`/`sample` scoping); the runtime connect module reads the
11528
11546
  * per-session credential out-of-band at boot via the `elbObserve` slot.
11529
- * This is the preview-artifact observation wiring: unlike `telemetry`, it
11530
- * bakes no ingest token into the emitted bytes. Mutually exclusive with
11531
- * `telemetry`.
11547
+ * This is the preview-artifact observation wiring: it bakes no ingest
11548
+ * token into the emitted bytes.
11532
11549
  */
11533
11550
  observe?: ObserveWeb;
11534
11551
  /**
@@ -11540,39 +11557,6 @@ interface WrapSkeletonOptions {
11540
11557
  /** Fine-grained minification options, forwarded to esbuild. */
11541
11558
  minifyOptions?: MinifyOptions;
11542
11559
  }
11543
- /**
11544
- * @deprecated Bakes a plaintext ingest token into the emitted (world-readable)
11545
- * bundle bytes. Use `WrapSkeletonOptions.observe` instead: it bakes only
11546
- * public connect values and the per-session credential arrives out-of-band at
11547
- * boot via the `elbObserve` slot. Its only production caller is the app's
11548
- * preview wrap, which moves to `observe` in F3'; this bake path is then
11549
- * retired.
11550
- */
11551
- interface TelemetryBundleOptions {
11552
- /** Absolute ingest URL. POST receives JSON array of FlowState. */
11553
- observerUrl: string;
11554
- /**
11555
- * Full deployment-scoped trace endpoint, e.g.
11556
- * `https://observer.example.com/trace/<deploymentId>`. Baked into the bundle
11557
- * and polled verbatim; the browser never constructs it from a base.
11558
- *
11559
- * Optional: when omitted, the bundle wires the observer at a fixed `level`
11560
- * with no polling. Suits short-lived, URL-opted-in sessions (e.g. a preview
11561
- * at `level: 'trace'`).
11562
- */
11563
- traceUrl?: string;
11564
- /** Deployment-scoped plaintext token. Sent as `Authorization: Bearer`. */
11565
- ingestToken: string;
11566
- /** Used as the `flowId` on every emitted FlowState. */
11567
- flowId: string;
11568
- /**
11569
- * Baseline verbosity. Default 'standard'. Even an 'off' baseline is wired
11570
- * (as a supplier) so the runtime trace poll can flip it to trace.
11571
- */
11572
- level?: 'off' | 'standard' | 'trace';
11573
- /** Deterministic sample fraction in [0, 1]. Default 1. */
11574
- sample?: number;
11575
- }
11576
11560
  declare function wrapSkeleton(options: WrapSkeletonOptions): Promise<void>;
11577
11561
 
11578
11562
  declare function createApiClient(): openapi_fetch.Client<paths, `${string}/${string}`>;
package/dist/index.js CHANGED
@@ -3269,12 +3269,21 @@ export default async function(context = {}) {
3269
3269
  function readObserveConnect(flowSettings, logger) {
3270
3270
  const observe = flowSettings.config?.observe;
3271
3271
  if (!observe) return void 0;
3272
- const { url, binding } = observe;
3272
+ const { url, binding, level, sample } = observe;
3273
3273
  if (url === void 0 && binding === void 0) return void 0;
3274
3274
  const trimmedUrl = typeof url === "string" ? url.trim() : "";
3275
3275
  const trimmedBinding = typeof binding === "string" ? binding.trim() : "";
3276
3276
  if (trimmedUrl !== "" && trimmedBinding !== "") {
3277
- return { url: trimmedUrl, binding: trimmedBinding };
3277
+ return {
3278
+ url: trimmedUrl,
3279
+ binding: trimmedBinding,
3280
+ // Same JSON-borne prudence as the pair: only known-shaped public
3281
+ // values reach the emitted literal.
3282
+ ...level === "off" || level === "standard" || level === "trace" ? { level } : {},
3283
+ // Sample is a fraction in [0, 1] per the Flow.Observe contract; the
3284
+ // range test also drops NaN and the infinities.
3285
+ ...typeof sample === "number" && sample >= 0 && sample <= 1 ? { sample } : {}
3286
+ };
3278
3287
  }
3279
3288
  const missing = [
3280
3289
  ...trimmedUrl === "" ? ["url"] : [],
@@ -3297,11 +3306,6 @@ function emitObserveAssignment(observe) {
3297
3306
  config.observe = ${JSON.stringify(literal)};`;
3298
3307
  }
3299
3308
  function generateWebEntry(stage1Path, dataPayload, options = {}) {
3300
- if (options.observe !== void 0 && options.telemetry !== void 0) {
3301
- throw new Error(
3302
- "generateWebEntry: `observe` (bake-nothing connect module) and `telemetry` (baked ingest token) are mutually exclusive observer wirings. Pass `observe` alone; the per-session credential arrives out-of-band at boot instead of being baked."
3303
- );
3304
- }
3305
3309
  const assignments = [];
3306
3310
  if (options.windowCollector) {
3307
3311
  assignments.push(
@@ -3322,30 +3326,13 @@ function generateWebEntry(stage1Path, dataPayload, options = {}) {
3322
3326
  }` : "";
3323
3327
  const stage1Specifier = toFileImportSpecifier(stage1Path);
3324
3328
  const observeBlock = options.observe ? emitObserveAssignment(options.observe) : "";
3325
- const telemetryImport = options.telemetry ? `
3326
- import { createBatchedPoster as __cbp, createTelemetryObserver as __cto } from '@walkeros/core';` : "";
3327
- const telemetryBlock = options.telemetry ? `
3328
- // --- Telemetry wiring ---
3329
- {
3330
- const __emit = __cbp({
3331
- url: ${JSON.stringify(options.telemetry.observerUrl)},
3332
- token: ${JSON.stringify(options.telemetry.ingestToken)},
3333
- });
3334
- const __observer = __cto(__emit, {
3335
- flowId: ${JSON.stringify(options.telemetry.flowId)},
3336
- level: ${JSON.stringify(options.telemetry.level ?? "standard")},
3337
- sample: ${JSON.stringify(options.telemetry.sample ?? 1)},
3338
- });
3339
- collector.observers.add(__observer);
3340
- collector.observeLevel = function () { return ${JSON.stringify(options.telemetry.level ?? "standard")}; };
3341
- }` : "";
3342
- return `import { startFlow, wireConfig } from '${stage1Specifier}';${telemetryImport}
3329
+ return `import { startFlow, wireConfig } from '${stage1Specifier}';
3343
3330
 
3344
3331
  const __configData = ${dataPayload};
3345
3332
 
3346
3333
  (async () => {
3347
3334
  const config = wireConfig(__configData);${envBlock}${observeBlock}
3348
- const { collector, elb } = await startFlow(config);${telemetryBlock}${assignmentCode}
3335
+ const { collector, elb } = await startFlow(config);${assignmentCode}
3349
3336
  })();`;
3350
3337
  }
3351
3338
  function generateWrapEntry(stage1Path, options = {}) {
@@ -3361,11 +3348,6 @@ function generateWrapEntry(stage1Path, options = {}) {
3361
3348
  "generateWrapEntry: `preview` (host activator) and `previewGrantTargets` (preview-artifact injection) are mutually exclusive. A host bundle activates a preview; an artifact injects its grant. Pass at most one."
3362
3349
  );
3363
3350
  }
3364
- if (options.observe !== void 0 && options.telemetry !== void 0) {
3365
- throw new Error(
3366
- "generateWrapEntry: `observe` (bake-nothing connect module) and `telemetry` (baked ingest token) are mutually exclusive observer wirings. Pass `observe` alone; the per-session credential arrives out-of-band at boot instead of being baked."
3367
- );
3368
- }
3369
3351
  const preview = options.preview;
3370
3352
  const previewEnabled = !!preview?.enabled;
3371
3353
  const previewImport = previewEnabled ? `import { browserSwapActivator } from '@walkeros/core';
@@ -3418,93 +3400,12 @@ ${grantTargets.map((key) => {
3418
3400
  }
3419
3401
  }` : "";
3420
3402
  const stage1Specifier = toFileImportSpecifier(stage1Path);
3421
- const hasPoll = !!options.telemetry?.traceUrl;
3422
- const telemetryImport = options.telemetry ? hasPoll ? `
3423
- import { createBatchedPoster as __cbp, createTelemetryObserver as __cto, resolveTelemetryOptions as __cto_resolve } from '@walkeros/core';` : `
3424
- import { createBatchedPoster as __cbp, createTelemetryObserver as __cto } from '@walkeros/core';` : "";
3425
- const telemetryPoller = options.telemetry && hasPoll ? `
3426
- let __traceUntil = null;
3427
- let __tracePollInFlight = false;
3428
- function __pollTrace() {
3429
- if (typeof fetch === 'undefined' || __tracePollInFlight) return;
3430
- __tracePollInFlight = true;
3431
- // Bound each poll so a stalled trace endpoint can't pin the in-flight guard
3432
- // forever (and stack concurrent fetches via setInterval).
3433
- var __ctrl = typeof AbortController !== 'undefined' ? new AbortController() : null;
3434
- var __t = __ctrl ? setTimeout(function () { __ctrl.abort(); }, 10000) : null;
3435
- fetch(${JSON.stringify(options.telemetry.traceUrl)}, {
3436
- headers: { Authorization: ${JSON.stringify(`Bearer ${options.telemetry.ingestToken}`)} },
3437
- signal: __ctrl ? __ctrl.signal : undefined,
3438
- })
3439
- .then(function (__res) {
3440
- if (!__res || __res.status !== 200) return;
3441
- return __res.json().then(function (__body) {
3442
- if (!__body || typeof __body !== 'object') return;
3443
- var __value = __body.traceUntil;
3444
- // Mirror the server poller: set on a non-empty string, clear on null,
3445
- // leave unchanged on anything else. The null path is the disable case
3446
- // (stop a trace early) and MUST be honored so web deployments can be
3447
- // turned off without waiting for the old timestamp to lapse.
3448
- if (typeof __value === 'string' && __value.length > 0) {
3449
- __traceUntil = __value;
3450
- } else if (__value === null) {
3451
- __traceUntil = null;
3452
- }
3453
- });
3454
- })
3455
- .catch(function () {})
3456
- .finally(function () {
3457
- if (__t) clearTimeout(__t);
3458
- __tracePollInFlight = false;
3459
- });
3460
- }
3461
- ` : "";
3462
- const telemetryBlock = options.telemetry ? hasPoll ? `
3463
- // --- Telemetry wiring ---
3464
- {
3465
- const __emit = __cbp({
3466
- url: ${JSON.stringify(options.telemetry.observerUrl)},
3467
- token: ${JSON.stringify(options.telemetry.ingestToken)},
3468
- });
3469
- // Single resolver drives both the observer projection and observeLevel so
3470
- // the reported level can never drift from what the observer emits.
3471
- const __resolveTelemetry = () => __cto_resolve({
3472
- flowId: ${JSON.stringify(options.telemetry.flowId)},
3473
- observe: {
3474
- level: ${JSON.stringify(options.telemetry.level ?? "standard")},
3475
- sample: ${JSON.stringify(options.telemetry.sample ?? 1)},
3476
- },
3477
- traceUntil: __traceUntil,
3478
- });
3479
- const __observer = __cto(__emit, __resolveTelemetry);
3480
- collector.observers.add(__observer);
3481
- collector.observeLevel = function () {
3482
- const __opts = __resolveTelemetry();
3483
- return __opts ? __opts.level : 'off';
3484
- };
3485
- __pollTrace();
3486
- setInterval(__pollTrace, 15000 + Math.floor(Math.random() * 5000));
3487
- }` : `
3488
- // --- Telemetry wiring ---
3489
- {
3490
- const __emit = __cbp({
3491
- url: ${JSON.stringify(options.telemetry.observerUrl)},
3492
- token: ${JSON.stringify(options.telemetry.ingestToken)},
3493
- });
3494
- const __observer = __cto(__emit, {
3495
- flowId: ${JSON.stringify(options.telemetry.flowId)},
3496
- level: ${JSON.stringify(options.telemetry.level ?? "standard")},
3497
- sample: ${JSON.stringify(options.telemetry.sample ?? 1)},
3498
- });
3499
- collector.observers.add(__observer);
3500
- collector.observeLevel = function () { return ${JSON.stringify(options.telemetry.level ?? "standard")}; };
3501
- }` : "";
3502
3403
  const observeBlock = options.observe ? emitObserveAssignment(options.observe) : "";
3503
- return `${previewImport}import { startFlow, wireConfig, __configData } from '${stage1Specifier}';${telemetryImport}
3504
- ${telemetryPoller}
3404
+ return `${previewImport}import { startFlow, wireConfig, __configData } from '${stage1Specifier}';
3405
+
3505
3406
  (async () => {${previewBlock}
3506
3407
  const config = wireConfig(__configData);${envBlock}${previewGrantBlock}${observeBlock}
3507
- const { collector, elb } = await startFlow(config);${telemetryBlock}${assignmentCode}
3408
+ const { collector, elb } = await startFlow(config);${assignmentCode}
3508
3409
  })();`;
3509
3410
  }
3510
3411
  function singleQuoteLiteral(value) {
@@ -8348,7 +8249,7 @@ function validateMapping(input) {
8348
8249
  // src/commands/validate/validators/entry.ts
8349
8250
  import Ajv from "ajv";
8350
8251
  import { fetchPackageSchema } from "@walkeros/core";
8351
- var CLIENT_HEADER = "walkeros-cli/4.3.1-next-1784373088875";
8252
+ var CLIENT_HEADER = "walkeros-cli/4.3.1";
8352
8253
  var SECTIONS = ["destinations", "sources", "transformers"];
8353
8254
  function resolveEntry(path20, flowConfig) {
8354
8255
  const flows = flowConfig.flows;
@@ -8913,8 +8814,8 @@ import createClient from "openapi-fetch";
8913
8814
  init_config_file();
8914
8815
  import { createHash } from "crypto";
8915
8816
  import semver4 from "semver";
8916
- var bakedContractVersion = true ? "3.1.0" : PLACEHOLDER;
8917
- var bakedContractHash = true ? "d3753dd02864fc19892f74a6a9afddb2081fc7a3f249991a681ae6c5540be650" : "";
8817
+ var bakedContractVersion = true ? "4.0.0" : PLACEHOLDER;
8818
+ var bakedContractHash = true ? "79c9e2d3bd2a72f1a95ba52742c4acdfe446c3835d5d169654f94e95da0e545e" : "";
8918
8819
  function isRecord3(value) {
8919
8820
  return value !== null && typeof value === "object" && !Array.isArray(value);
8920
8821
  }
@@ -10227,11 +10128,6 @@ async function wrapSkeleton(options) {
10227
10128
  "wrapSkeleton: `preview` (host activator) and `previewGrantTargets` (preview-artifact injection) are mutually exclusive. Pass at most one."
10228
10129
  );
10229
10130
  }
10230
- if (options.observe && options.telemetry) {
10231
- throw new Error(
10232
- "wrapSkeleton: `observe` (bake-nothing connect module) and `telemetry` (baked ingest token) are mutually exclusive. Pass `observe` alone; the per-session credential arrives out-of-band at boot instead of being baked."
10233
- );
10234
- }
10235
10131
  if (options.preview && (typeof options.preview.previewOrigin !== "string" || !/^[a-z0-9.-]+$/.test(options.preview.previewOrigin))) {
10236
10132
  throw new Error(
10237
10133
  `Invalid previewOrigin "${options.preview.previewOrigin}". Must be a bare hostname matching /^[a-z0-9.-]+$/.`
@@ -10243,23 +10139,12 @@ async function wrapSkeleton(options) {
10243
10139
  const absoluteSkeletonPath = path19.resolve(skeletonPath);
10244
10140
  const skeletonText = await fs18.readFile(absoluteSkeletonPath, "utf-8");
10245
10141
  const devExternals = extractDevExternals(skeletonText);
10246
- const tInput = options.telemetry;
10247
- const tLevel = tInput?.level ?? "standard";
10248
- const telemetry = tInput ? {
10249
- observerUrl: tInput.observerUrl,
10250
- ingestToken: tInput.ingestToken,
10251
- flowId: tInput.flowId,
10252
- level: tLevel,
10253
- ...tInput.traceUrl !== void 0 ? { traceUrl: tInput.traceUrl } : {},
10254
- ...tInput.sample !== void 0 ? { sample: tInput.sample } : {}
10255
- } : void 0;
10256
10142
  const entryText = platform === "browser" ? generateWrapEntry(absoluteSkeletonPath, {
10257
10143
  ...windowCollector ? { windowCollector } : {},
10258
10144
  ...windowElb ? { windowElb } : {},
10259
10145
  ...options.preview ? { preview: options.preview } : {},
10260
10146
  ...options.previewGrantTargets ? { previewGrantTargets: options.previewGrantTargets } : {},
10261
10147
  platform,
10262
- ...telemetry ? { telemetry } : {},
10263
10148
  ...options.observe ? { observe: options.observe } : {}
10264
10149
  }) : generateWrapEntryServer(absoluteSkeletonPath);
10265
10150
  const entryDir = await fs18.mkdtemp(path19.join(os3.tmpdir(), "walkeros-wrap-"));
@@ -10273,7 +10158,7 @@ async function wrapSkeleton(options) {
10273
10158
  format: "esm",
10274
10159
  platform,
10275
10160
  outfile: outputPath,
10276
- // Resolve `@walkeros/core` (used by the telemetry block) from the CLI
10161
+ // Resolve `@walkeros/core` (used by the preview activator) from the CLI
10277
10162
  // package's own dependency tree and the workspace root. Without this,
10278
10163
  // esbuild looks under the temp entryDir which has no node_modules.
10279
10164
  // The wrap step always runs from inside the CLI process; both the