rebilder 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +7 -1
- package/dist/bin.js +18 -5
- package/dist/bin.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +18 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -129,7 +129,7 @@ declare function createNodeRuntime(): CliRuntime;
|
|
|
129
129
|
*/
|
|
130
130
|
|
|
131
131
|
/** Kept in step with package.json by a test, so a stale constant cannot ship. */
|
|
132
|
-
declare const CLI_VERSION = "0.
|
|
132
|
+
declare const CLI_VERSION = "0.5.0";
|
|
133
133
|
declare function runCli(argv: readonly string[], runtime: CliRuntime): Promise<ExitCode>;
|
|
134
134
|
|
|
135
135
|
/**
|
|
@@ -438,6 +438,11 @@ declare const TELEMETRY_LINES: readonly string[];
|
|
|
438
438
|
* framework did they pick" would be exactly the telemetry the README says we do
|
|
439
439
|
* not collect, wearing a helpful hat.
|
|
440
440
|
*
|
|
441
|
+
* REPORTING IS WIRED IN THE GENERATED FILE, NOT IN THE CLI. The scaffold sends
|
|
442
|
+
* gateway events to the merchant's own Console from the merchant's server, and
|
|
443
|
+
* only once they set REBILDER_API_KEY. Leaving `onEvent` commented out meant
|
|
444
|
+
* free installs never reached a Console; the quickstart docs had the same bug.
|
|
445
|
+
*
|
|
441
446
|
* THE DETECTION IS PRINTED. Every scaffold says how it decided (`"next found in
|
|
442
447
|
* package.json dependencies"`), because a wrong guess with a visible reason is a
|
|
443
448
|
* thirty-second fix and a wrong guess with no reason is a bug report. `--framework`
|
package/dist/index.js
CHANGED
|
@@ -466,12 +466,26 @@ async function runInit(command, runtime) {
|
|
|
466
466
|
}
|
|
467
467
|
return { ...SCAFFOLDS[framework], framework, detection };
|
|
468
468
|
}
|
|
469
|
+
var INGEST_ORIGIN = "https://api.rebilder.com";
|
|
470
|
+
var CONSOLE_INSTALL_URL = "https://rebilder.com/console/install";
|
|
469
471
|
var SHARED_NOTES = [
|
|
470
472
|
"The resolvers return your source of truth. Every substantive value \u2014 price, stock, hours, policy text \u2014 comes from these fields; the gateway never invents one.",
|
|
471
|
-
"The Apache-2.0 SDK serves without a Rebilder account or subscription.
|
|
473
|
+
"The Apache-2.0 SDK serves without a Rebilder account or subscription.",
|
|
474
|
+
`Reporting is wired in. Install \`@rebilder/events\`, create a free account, then set REBILDER_STORE_ID and REBILDER_API_KEY from ${CONSOLE_INSTALL_URL}. Without the key, nothing is sent.`,
|
|
472
475
|
`Run \`rebilder check <url>\` before and after to see what changed. Sending a Markdown copy from the page address is D2.1 (${DEFAULT_RULESET.weights["machine-representation.negotiated-response"] ?? 0} points) and unlocks D2.3 and D2.4.`
|
|
473
476
|
];
|
|
474
477
|
var CONFIG_BODY = `import type { GatewayConfig } from '@rebilder/gateway'
|
|
478
|
+
import { createHttpEventSink } from '@rebilder/events'
|
|
479
|
+
|
|
480
|
+
// Reports agent visits to your Rebilder Console. Free accounts include it.
|
|
481
|
+
// Copy both values from ${CONSOLE_INSTALL_URL} into your environment.
|
|
482
|
+
// Without REBILDER_API_KEY, nothing is sent.
|
|
483
|
+
const env = (name: string): string | undefined =>
|
|
484
|
+
(globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env?.[name]
|
|
485
|
+
const apiKey = env('REBILDER_API_KEY')
|
|
486
|
+
|
|
487
|
+
// Module scope, not per request: the sink batches (20 events, or every 2s).
|
|
488
|
+
const sink = apiKey ? createHttpEventSink({ url: '${INGEST_ORIGIN}', apiKey }) : null
|
|
475
489
|
|
|
476
490
|
/**
|
|
477
491
|
* Wiring to YOUR source of truth. Each resolver takes a URL and returns the
|
|
@@ -481,7 +495,7 @@ var CONFIG_BODY = `import type { GatewayConfig } from '@rebilder/gateway'
|
|
|
481
495
|
* call except a cache. Anything slower belongs in a build step.
|
|
482
496
|
*/
|
|
483
497
|
export const gatewayConfig: GatewayConfig = {
|
|
484
|
-
storeId: 'TODO-your-store-id',
|
|
498
|
+
storeId: env('REBILDER_STORE_ID') ?? 'TODO-your-store-id',
|
|
485
499
|
sources: {
|
|
486
500
|
// TODO: return your product fields, or null when the URL is not a PDP.
|
|
487
501
|
product: async (url) => {
|
|
@@ -490,8 +504,7 @@ export const gatewayConfig: GatewayConfig = {
|
|
|
490
504
|
},
|
|
491
505
|
// TODO: policies, catalog, document, collection \u2014 add the ones you have.
|
|
492
506
|
},
|
|
493
|
-
|
|
494
|
-
// onEvent: (event) => { void event },
|
|
507
|
+
onEvent: (event) => sink?.emit(event),
|
|
495
508
|
}
|
|
496
509
|
`;
|
|
497
510
|
function scaffold(suggestedPath, mount, notes) {
|
|
@@ -1812,7 +1825,7 @@ function helpText(topic) {
|
|
|
1812
1825
|
}
|
|
1813
1826
|
|
|
1814
1827
|
// src/cli.ts
|
|
1815
|
-
var CLI_VERSION = "0.
|
|
1828
|
+
var CLI_VERSION = "0.5.0";
|
|
1816
1829
|
async function runCli(argv, runtime) {
|
|
1817
1830
|
const caps = detectCapabilities({
|
|
1818
1831
|
env: runtime.env,
|