@walkeros/cli 4.3.0 → 4.3.1-next-1784373088875

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
@@ -1,4 +1,4 @@
1
- import { Flow, PreviewKey, Elb, Ingest, WalkerOS, Simulation } from '@walkeros/core';
1
+ import { Flow, PreviewKey, Elb, Ingest, WalkerOS, Simulation, ObserveWeb } from '@walkeros/core';
2
2
  export { Flow } from '@walkeros/core';
3
3
  import { BuildOptions as BuildOptions$1 } from 'esbuild';
4
4
  import { z } from '@walkeros/core/dev';
@@ -11518,9 +11518,19 @@ interface WrapSkeletonOptions {
11518
11518
  * using `createBatchedPoster`.
11519
11519
  *
11520
11520
  * Omit (or pass `level: 'off'`) to ship a bundle with zero telemetry
11521
- * plumbing.
11521
+ * plumbing. Mutually exclusive with `observe`.
11522
11522
  */
11523
11523
  telemetry?: TelemetryBundleOptions;
11524
+ /**
11525
+ * Browser-only: STATIC observe connect config baked onto the startFlow
11526
+ * config. PUBLIC values only (`url` + `binding`, plus optional
11527
+ * `flowId`/`level`/`sample` scoping); the runtime connect module reads the
11528
+ * 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`.
11532
+ */
11533
+ observe?: ObserveWeb;
11524
11534
  /**
11525
11535
  * esbuild target. @default 'es2018' for browser, 'node18' for node.
11526
11536
  */
@@ -11530,6 +11540,14 @@ interface WrapSkeletonOptions {
11530
11540
  /** Fine-grained minification options, forwarded to esbuild. */
11531
11541
  minifyOptions?: MinifyOptions;
11532
11542
  }
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
+ */
11533
11551
  interface TelemetryBundleOptions {
11534
11552
  /** Absolute ingest URL. POST receives JSON array of FlowState. */
11535
11553
  observerUrl: string;
package/dist/index.js CHANGED
@@ -2506,7 +2506,8 @@ ${dataDeclaration}`;
2506
2506
  const stage2Entry = (buildOptions.platform || "node") === "browser" ? generateWebEntry(stage1Path, dataPayload, {
2507
2507
  windowCollector: buildOptions.windowCollector,
2508
2508
  windowElb: buildOptions.windowElb,
2509
- platform: buildOptions.platform
2509
+ platform: buildOptions.platform,
2510
+ observe: readObserveConnect(flowSettings, logger)
2510
2511
  }) : generateServerEntry(stage1Path, dataPayload);
2511
2512
  const stage2EntryPath = path12.join(TEMP_DIR, "stage2.mjs");
2512
2513
  await fs11.writeFile(stage2EntryPath, stage2Entry);
@@ -3265,7 +3266,42 @@ export default async function(context = {}) {
3265
3266
  return { ...result, httpHandler: httpSource ? httpSource.httpHandler : undefined };
3266
3267
  }`;
3267
3268
  }
3269
+ function readObserveConnect(flowSettings, logger) {
3270
+ const observe = flowSettings.config?.observe;
3271
+ if (!observe) return void 0;
3272
+ const { url, binding } = observe;
3273
+ if (url === void 0 && binding === void 0) return void 0;
3274
+ const trimmedUrl = typeof url === "string" ? url.trim() : "";
3275
+ const trimmedBinding = typeof binding === "string" ? binding.trim() : "";
3276
+ if (trimmedUrl !== "" && trimmedBinding !== "") {
3277
+ return { url: trimmedUrl, binding: trimmedBinding };
3278
+ }
3279
+ const missing = [
3280
+ ...trimmedUrl === "" ? ["url"] : [],
3281
+ ...trimmedBinding === "" ? ["binding"] : []
3282
+ ].join(" and ");
3283
+ logger?.warn(
3284
+ `config.observe has no effect: missing or empty ${missing}. Observe connect wiring was skipped; set both config.observe.url and config.observe.binding to non-empty public values.`
3285
+ );
3286
+ return void 0;
3287
+ }
3288
+ function emitObserveAssignment(observe) {
3289
+ const literal = {
3290
+ url: observe.url,
3291
+ binding: observe.binding,
3292
+ ...observe.flowId !== void 0 ? { flowId: observe.flowId } : {},
3293
+ ...observe.level !== void 0 ? { level: observe.level } : {},
3294
+ ...observe.sample !== void 0 ? { sample: observe.sample } : {}
3295
+ };
3296
+ return `
3297
+ config.observe = ${JSON.stringify(literal)};`;
3298
+ }
3268
3299
  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
+ }
3269
3305
  const assignments = [];
3270
3306
  if (options.windowCollector) {
3271
3307
  assignments.push(
@@ -3285,6 +3321,7 @@ function generateWebEntry(stage1Path, dataPayload, options = {}) {
3285
3321
  }
3286
3322
  }` : "";
3287
3323
  const stage1Specifier = toFileImportSpecifier(stage1Path);
3324
+ const observeBlock = options.observe ? emitObserveAssignment(options.observe) : "";
3288
3325
  const telemetryImport = options.telemetry ? `
3289
3326
  import { createBatchedPoster as __cbp, createTelemetryObserver as __cto } from '@walkeros/core';` : "";
3290
3327
  const telemetryBlock = options.telemetry ? `
@@ -3307,7 +3344,7 @@ import { createBatchedPoster as __cbp, createTelemetryObserver as __cto } from '
3307
3344
  const __configData = ${dataPayload};
3308
3345
 
3309
3346
  (async () => {
3310
- const config = wireConfig(__configData);${envBlock}
3347
+ const config = wireConfig(__configData);${envBlock}${observeBlock}
3311
3348
  const { collector, elb } = await startFlow(config);${telemetryBlock}${assignmentCode}
3312
3349
  })();`;
3313
3350
  }
@@ -3324,6 +3361,11 @@ function generateWrapEntry(stage1Path, options = {}) {
3324
3361
  "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."
3325
3362
  );
3326
3363
  }
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
+ }
3327
3369
  const preview = options.preview;
3328
3370
  const previewEnabled = !!preview?.enabled;
3329
3371
  const previewImport = previewEnabled ? `import { browserSwapActivator } from '@walkeros/core';
@@ -3457,10 +3499,11 @@ function __pollTrace() {
3457
3499
  collector.observers.add(__observer);
3458
3500
  collector.observeLevel = function () { return ${JSON.stringify(options.telemetry.level ?? "standard")}; };
3459
3501
  }` : "";
3502
+ const observeBlock = options.observe ? emitObserveAssignment(options.observe) : "";
3460
3503
  return `${previewImport}import { startFlow, wireConfig, __configData } from '${stage1Specifier}';${telemetryImport}
3461
3504
  ${telemetryPoller}
3462
3505
  (async () => {${previewBlock}
3463
- const config = wireConfig(__configData);${envBlock}${previewGrantBlock}
3506
+ const config = wireConfig(__configData);${envBlock}${previewGrantBlock}${observeBlock}
3464
3507
  const { collector, elb } = await startFlow(config);${telemetryBlock}${assignmentCode}
3465
3508
  })();`;
3466
3509
  }
@@ -8305,7 +8348,7 @@ function validateMapping(input) {
8305
8348
  // src/commands/validate/validators/entry.ts
8306
8349
  import Ajv from "ajv";
8307
8350
  import { fetchPackageSchema } from "@walkeros/core";
8308
- var CLIENT_HEADER = "walkeros-cli/4.3.0";
8351
+ var CLIENT_HEADER = "walkeros-cli/4.3.1-next-1784373088875";
8309
8352
  var SECTIONS = ["destinations", "sources", "transformers"];
8310
8353
  function resolveEntry(path20, flowConfig) {
8311
8354
  const flows = flowConfig.flows;
@@ -10184,6 +10227,11 @@ async function wrapSkeleton(options) {
10184
10227
  "wrapSkeleton: `preview` (host activator) and `previewGrantTargets` (preview-artifact injection) are mutually exclusive. Pass at most one."
10185
10228
  );
10186
10229
  }
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
+ }
10187
10235
  if (options.preview && (typeof options.preview.previewOrigin !== "string" || !/^[a-z0-9.-]+$/.test(options.preview.previewOrigin))) {
10188
10236
  throw new Error(
10189
10237
  `Invalid previewOrigin "${options.preview.previewOrigin}". Must be a bare hostname matching /^[a-z0-9.-]+$/.`
@@ -10211,7 +10259,8 @@ async function wrapSkeleton(options) {
10211
10259
  ...options.preview ? { preview: options.preview } : {},
10212
10260
  ...options.previewGrantTargets ? { previewGrantTargets: options.previewGrantTargets } : {},
10213
10261
  platform,
10214
- ...telemetry ? { telemetry } : {}
10262
+ ...telemetry ? { telemetry } : {},
10263
+ ...options.observe ? { observe: options.observe } : {}
10215
10264
  }) : generateWrapEntryServer(absoluteSkeletonPath);
10216
10265
  const entryDir = await fs18.mkdtemp(path19.join(os3.tmpdir(), "walkeros-wrap-"));
10217
10266
  const entryPath = path19.join(entryDir, "flow.mjs");