@zero2webmaster/starter-kit 0.2.0 → 0.3.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/README.md +14 -15
- package/dist/airtable.d.ts +119 -0
- package/dist/airtable.js +273 -0
- package/dist/brief.d.ts +2 -2
- package/dist/brief.js +11 -4
- package/dist/cli.js +290 -17
- package/dist/confirm.d.ts +16 -4
- package/dist/confirm.js +66 -32
- package/dist/index.d.ts +195 -3
- package/dist/index.js +155 -6
- package/dist/inventory.d.ts +137 -0
- package/dist/inventory.js +258 -0
- package/dist/license.d.ts +97 -0
- package/dist/license.js +474 -0
- package/dist/parse-brief.d.ts +45 -1
- package/dist/parse-brief.js +349 -21
- package/dist/scaffolders/common.d.ts +42 -1
- package/dist/scaffolders/common.js +753 -30
- package/dist/scaffolders/index.d.ts +1 -0
- package/dist/scaffolders/index.js +3 -0
- package/dist/scaffolders/library.js +26 -2
- package/dist/scaffolders/nextjs.d.ts +1 -1
- package/dist/scaffolders/nextjs.js +254 -24
- package/dist/scaffolders/node-service.d.ts +3 -0
- package/dist/scaffolders/node-service.js +320 -0
- package/dist/scaffolders/pro-seo-extension.d.ts +11 -0
- package/dist/scaffolders/pro-seo-extension.js +782 -0
- package/dist/scaffolders/python-service.js +10 -2
- package/dist/scaffolders/wp-plugin.js +8 -8
- package/dist/standards.d.ts +1 -1
- package/dist/standards.js +164 -5
- package/dist/substitute.d.ts +22 -3
- package/dist/substitute.js +19 -5
- package/dist/summary.d.ts +9 -0
- package/dist/summary.js +31 -13
- package/dist/templates.d.ts +43 -57
- package/dist/templates.js +108 -175
- package/dist/with-init.d.ts +32 -0
- package/dist/with-init.js +171 -0
- package/dist/wizard.js +21 -0
- package/dist/writer.d.ts +13 -6
- package/dist/writer.js +119 -21
- package/package.json +2 -1
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
// z2w-starter-kit Neon inventory write-path (project-inventory migration P3).
|
|
2
|
+
//
|
|
3
|
+
// The project inventory is migrating off Airtable onto Neon Postgres (the Neon
|
|
4
|
+
// project "software-projects" / project_id super-feather-66275632, table
|
|
5
|
+
// `projects`, keyed UNIQUE on `slug`). When a project is scaffolded, write its
|
|
6
|
+
// row to Neon so the coordination drift/gap cron and the agents.z2w.us command
|
|
7
|
+
// center can read it without Kerry maintaining an Airtable base. This runs
|
|
8
|
+
// ALONGSIDE the Airtable write during the transition (dual-write); the Airtable
|
|
9
|
+
// write is dropped later at migration phase P6.
|
|
10
|
+
//
|
|
11
|
+
// SAFETY / public-distribution posture: this is a PUBLIC npm package; the
|
|
12
|
+
// inventory DB is Kerry's PRIVATE Neon project. The write is gated entirely on
|
|
13
|
+
// the presence of Z2W_INVENTORY_DATABASE_URL in the environment — a customer
|
|
14
|
+
// who has no connection string never writes anything (resolveInventoryConfig
|
|
15
|
+
// returns null → outcome "skipped", silent). This mirrors the AIRTABLE_WRITE_PAT
|
|
16
|
+
// gate in src/airtable.ts exactly. The call NEVER blocks or fails a scaffold
|
|
17
|
+
// (warn-and-proceed): the row can always be added later, and the READ-side
|
|
18
|
+
// consumers pick it up on their next sweep regardless.
|
|
19
|
+
//
|
|
20
|
+
// Driver: @neondatabase/serverless `neon()` — one-shot HTTP queries, NO
|
|
21
|
+
// connection pooling, so a single scaffold opens no long-lived connection and
|
|
22
|
+
// Neon stays scaled to zero ([[neon-postgres]] discipline). The connection
|
|
23
|
+
// string is never printed.
|
|
24
|
+
//
|
|
25
|
+
// Patterns mirror src/airtable.ts: a pure mapper (buildProjectRow), an env
|
|
26
|
+
// resolver (resolveInventoryConfig), and an orchestrator (registerProjectRowNeon)
|
|
27
|
+
// with a queryImpl / config test seam that never throws. The on-disk
|
|
28
|
+
// "verify, don't assert" coordination check is shared with the Airtable path
|
|
29
|
+
// (scaffoldCarriesCoordinationBlock, imported from ./airtable.js).
|
|
30
|
+
import { neon } from "@neondatabase/serverless";
|
|
31
|
+
import { scaffoldCarriesCoordinationBlock, displayNameFromSlug } from "./airtable.js";
|
|
32
|
+
/** The Neon `projects` table the inventory rows live in. */
|
|
33
|
+
export const INVENTORY_TABLE = "projects";
|
|
34
|
+
/** The conflict key — the `projects/{slug}.md` filename the cron keys on. */
|
|
35
|
+
export const INVENTORY_CONFLICT_KEY = "slug";
|
|
36
|
+
/**
|
|
37
|
+
* Resolve the Neon inventory config from the environment. Returns null when no
|
|
38
|
+
* Z2W_INVENTORY_DATABASE_URL is set — the signal that the Neon write is disabled
|
|
39
|
+
* for this caller (every CLI user who isn't Kerry). Mirrors
|
|
40
|
+
* `resolveAirtableConfig`'s no-op gate exactly.
|
|
41
|
+
*/
|
|
42
|
+
export function resolveInventoryConfig(env = process.env) {
|
|
43
|
+
const databaseUrl = (env["Z2W_INVENTORY_DATABASE_URL"] ?? "").trim();
|
|
44
|
+
if (!databaseUrl)
|
|
45
|
+
return null;
|
|
46
|
+
return { databaseUrl };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Pure mapping from ScaffoldInputs to the Neon `projects` row. Mirrors the
|
|
50
|
+
* decisions in src/airtable.ts `buildProjectFields`, mapped to the FINAL 23-column
|
|
51
|
+
* snake_case schema (column audit executed 2026-06-22). Only columns the CLI can
|
|
52
|
+
* auto-fill at scaffold time are written — manually-curated columns (technology,
|
|
53
|
+
* licensing, notes, research_url, …) are intentionally omitted so the UPSERT's
|
|
54
|
+
* DO UPDATE never clobbers Kerry's hand-entered values.
|
|
55
|
+
*
|
|
56
|
+
* Difference from the Airtable mapper: `project_type` IS written here (the Neon
|
|
57
|
+
* column is plain text and the CLI knows the value, so it earns its place per the
|
|
58
|
+
* column-audit principle "a column earns its place only if the CLI can auto-fill
|
|
59
|
+
* it"). The Airtable mapper omitted it only because that base's Project Type is a
|
|
60
|
+
* single-select whose option names could 422 on first use. `skill_vault_aware` is
|
|
61
|
+
* a real boolean here (Neon column type), not the Airtable "Yes" string.
|
|
62
|
+
*/
|
|
63
|
+
export function buildProjectRow(inputs, opts = {}) {
|
|
64
|
+
const row = {
|
|
65
|
+
slug: inputs.slug,
|
|
66
|
+
project_name: displayNameFromSlug(inputs.slug),
|
|
67
|
+
status: "Active",
|
|
68
|
+
creation_method: "Z2W Starter Kit",
|
|
69
|
+
project_type: inputs.projectType,
|
|
70
|
+
// Write the conventional URL even if `gh repo create` is deferred — the
|
|
71
|
+
// inventory's slug-resolution needs it.
|
|
72
|
+
github_url: `https://github.com/${inputs.githubOrg}/${inputs.slug}`,
|
|
73
|
+
// skill-vault is an always-on standard in every scaffold (ROADMAP Step 15);
|
|
74
|
+
// the Neon column is a real boolean.
|
|
75
|
+
skill_vault_aware: true,
|
|
76
|
+
};
|
|
77
|
+
// Only assert agent_coordination = Registered when the scaffold actually
|
|
78
|
+
// carries the coordination block; otherwise leave it unset for Kerry. When the
|
|
79
|
+
// caller verified the scaffold on disk (coordinationVerified is a boolean),
|
|
80
|
+
// honor it; when it couldn't (undefined), trust the input flag.
|
|
81
|
+
if (inputs.participateInBulletin && (opts.coordinationVerified ?? true)) {
|
|
82
|
+
row["agent_coordination"] = "Registered";
|
|
83
|
+
}
|
|
84
|
+
// Kerry's standing rule: every inventory row carries its instantiation prompt.
|
|
85
|
+
const prompt = inputs.instantiationPrompt?.trim();
|
|
86
|
+
if (prompt) {
|
|
87
|
+
row["project_instantiation_prompt"] = prompt;
|
|
88
|
+
}
|
|
89
|
+
return row;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A well-formed inventory slug: lowercase letters, digits, and hyphens only.
|
|
93
|
+
* This mirrors the coordination bulletin's `projects/{slug}.md` filename
|
|
94
|
+
* convention (the slug IS the filename), and rejects the historical CSV-imported
|
|
95
|
+
* junk the 2026-07-05 registry data-hygiene sweep found — e.g. `"Skill Vault"`
|
|
96
|
+
* (space + capitals) or `"Website - VimeoBunny"`. The CLI's input-side
|
|
97
|
+
* `project_slug` rule is stricter still (`^[a-z][a-z0-9-]{2,49}$`); this is the
|
|
98
|
+
* looser floor the inventory row must clear before it is written.
|
|
99
|
+
*/
|
|
100
|
+
export const INVENTORY_SLUG_RE = /^[a-z0-9-]+$/;
|
|
101
|
+
/**
|
|
102
|
+
* A well-formed GitHub URL: exactly `https://github.com/{owner}/{repo}` with no
|
|
103
|
+
* trailing slash or path. Rejects the malformed values the hygiene sweep found —
|
|
104
|
+
* a missing scheme (`github.com/owner/repo`, `owner/repo`) or a trailing slash
|
|
105
|
+
* (`.../website-aharon/`). Owner/repo allow the GitHub-legal set `[A-Za-z0-9_.-]`.
|
|
106
|
+
*/
|
|
107
|
+
export const INVENTORY_GITHUB_URL_RE = /^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
|
|
108
|
+
/**
|
|
109
|
+
* Validate the CLI-owned fields of a would-be inventory row. Returns a list of
|
|
110
|
+
* human-readable problems (empty = valid). Called before every write so a
|
|
111
|
+
* malformed `slug` / `github_url` can never be UPSERTed into the registry — the
|
|
112
|
+
* prevention half of the 2026-07-05 `z2w-agent-coordination` data-hygiene ask.
|
|
113
|
+
*/
|
|
114
|
+
export function validateProjectRow(row) {
|
|
115
|
+
const problems = [];
|
|
116
|
+
const slug = row["slug"];
|
|
117
|
+
if (typeof slug !== "string" || slug.length === 0) {
|
|
118
|
+
problems.push("slug is missing.");
|
|
119
|
+
}
|
|
120
|
+
else if (!INVENTORY_SLUG_RE.test(slug)) {
|
|
121
|
+
problems.push(`slug "${slug}" is malformed (expected ${INVENTORY_SLUG_RE} — lowercase letters, digits, and hyphens only).`);
|
|
122
|
+
}
|
|
123
|
+
const githubUrl = row["github_url"];
|
|
124
|
+
if (githubUrl !== undefined) {
|
|
125
|
+
if (typeof githubUrl !== "string" || !INVENTORY_GITHUB_URL_RE.test(githubUrl)) {
|
|
126
|
+
problems.push(`github_url "${String(githubUrl)}" is malformed (expected https://github.com/{owner}/{repo}, no trailing slash).`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return problems;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Build the INSERT … ON CONFLICT (slug) DO UPDATE statement from a row. Column
|
|
133
|
+
* names come from `buildProjectRow` (our own code, never user input), so string
|
|
134
|
+
* interpolation of column names is injection-safe; all VALUES are parameterized.
|
|
135
|
+
* The DO UPDATE set list excludes `slug` (the conflict key) and touches only the
|
|
136
|
+
* columns present in `row`, so columns the CLI doesn't manage are never altered.
|
|
137
|
+
* `updated_at` is left to the table's auto-touch trigger.
|
|
138
|
+
*/
|
|
139
|
+
export function buildUpsert(row) {
|
|
140
|
+
const columns = Object.keys(row);
|
|
141
|
+
const placeholders = columns.map((_, i) => `$${i + 1}`);
|
|
142
|
+
const updates = columns
|
|
143
|
+
.filter((col) => col !== INVENTORY_CONFLICT_KEY)
|
|
144
|
+
.map((col) => `${col} = EXCLUDED.${col}`);
|
|
145
|
+
// A row may carry only `slug` in pathological cases; guard the empty SET.
|
|
146
|
+
const conflictClause = updates.length > 0
|
|
147
|
+
? `ON CONFLICT (${INVENTORY_CONFLICT_KEY}) DO UPDATE SET ${updates.join(", ")}`
|
|
148
|
+
: `ON CONFLICT (${INVENTORY_CONFLICT_KEY}) DO NOTHING`;
|
|
149
|
+
const sql = `INSERT INTO ${INVENTORY_TABLE} (${columns.join(", ")}) ` +
|
|
150
|
+
`VALUES (${placeholders.join(", ")}) ` +
|
|
151
|
+
`${conflictClause} ` +
|
|
152
|
+
`RETURNING id, (xmax = 0) AS inserted`;
|
|
153
|
+
const params = columns.map((col) => row[col]);
|
|
154
|
+
return { sql, params, columns };
|
|
155
|
+
}
|
|
156
|
+
/** Build a one-shot HTTP query function from a connection string. */
|
|
157
|
+
function defaultQuery(databaseUrl) {
|
|
158
|
+
const sql = neon(databaseUrl);
|
|
159
|
+
return (text, params) => sql.query(text, params);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* UPSERT the inventory row for a freshly-scaffolded project into Neon.
|
|
163
|
+
* Warn-and-proceed: always resolves (never rejects); the CLI surfaces `message`
|
|
164
|
+
* and continues.
|
|
165
|
+
*
|
|
166
|
+
* - No Z2W_INVENTORY_DATABASE_URL → outcome "skipped" (silent for normal users).
|
|
167
|
+
* - opts.dryRun → outcome "dry-run" (prints the would-be SQL).
|
|
168
|
+
* - success → outcome "upserted" (+ recordId).
|
|
169
|
+
* - query error → outcome "failed" (+ a diagnostic; row NOT written).
|
|
170
|
+
*/
|
|
171
|
+
export async function registerProjectRowNeon(inputs, opts = {}) {
|
|
172
|
+
// "Verify, don't assert": for a participating project with a real scaffold on
|
|
173
|
+
// disk, confirm the coordination block is present before claiming Registered.
|
|
174
|
+
// Skipped for dry-runs (nothing written) and when no targetPath is supplied.
|
|
175
|
+
let coordinationVerified;
|
|
176
|
+
if (inputs.participateInBulletin && opts.targetPath && !opts.dryRun) {
|
|
177
|
+
coordinationVerified = await scaffoldCarriesCoordinationBlock(opts.targetPath, {
|
|
178
|
+
readFileImpl: opts.readFileImpl,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
const row = buildProjectRow(inputs, { coordinationVerified });
|
|
182
|
+
const coordNote = coordinationVerified === false
|
|
183
|
+
? " Note: the coordination block was not found in the scaffold, so " +
|
|
184
|
+
"agent_coordination was left unset for you to fill by hand."
|
|
185
|
+
: "";
|
|
186
|
+
const promptNote = row["project_instantiation_prompt"]
|
|
187
|
+
? ""
|
|
188
|
+
: " Note: no Project Instantiation Prompt was captured for this project — " +
|
|
189
|
+
"add it to the row's project_instantiation_prompt column by hand " +
|
|
190
|
+
"(every inventory row should carry its instantiation prompt).";
|
|
191
|
+
// Prevention half of the 2026-07-05 registry data-hygiene ask: refuse to write
|
|
192
|
+
// a row whose slug or github_url is malformed, so the junk the sweep cleaned up
|
|
193
|
+
// (a `"Skill Vault"` slug, a scheme-less `github.com/...` URL) can never
|
|
194
|
+
// re-accumulate. Warn-and-proceed: this NEVER throws or fails the scaffold —
|
|
195
|
+
// it just declines the bad write and surfaces exactly what to fix. Checked
|
|
196
|
+
// before the dry-run preview too, so a dry-run flags the problem early.
|
|
197
|
+
const problems = validateProjectRow(row);
|
|
198
|
+
if (problems.length > 0) {
|
|
199
|
+
return {
|
|
200
|
+
outcome: "failed",
|
|
201
|
+
row,
|
|
202
|
+
coordinationVerified,
|
|
203
|
+
message: `Neon inventory write skipped — the row failed validation and was NOT ` +
|
|
204
|
+
`written: ${problems.join(" ")} Fix the input and re-run; the scaffold ` +
|
|
205
|
+
`completed normally.`,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
const config = opts.config !== undefined ? opts.config : resolveInventoryConfig(opts.env);
|
|
209
|
+
if (config === null) {
|
|
210
|
+
return {
|
|
211
|
+
outcome: "skipped",
|
|
212
|
+
row,
|
|
213
|
+
coordinationVerified,
|
|
214
|
+
message: "Neon inventory write skipped (no Z2W_INVENTORY_DATABASE_URL set).",
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
const { sql, params, columns } = buildUpsert(row);
|
|
218
|
+
if (opts.dryRun) {
|
|
219
|
+
return {
|
|
220
|
+
outcome: "dry-run",
|
|
221
|
+
row,
|
|
222
|
+
sql,
|
|
223
|
+
coordinationVerified,
|
|
224
|
+
message: `Neon inventory (dry-run): would UPSERT 1 row into ` +
|
|
225
|
+
`${INVENTORY_TABLE}(${columns.join(", ")}) ON CONFLICT (${INVENTORY_CONFLICT_KEY}) ` +
|
|
226
|
+
`DO UPDATE.\n SQL: ${sql}`,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
const query = opts.queryImpl ?? defaultQuery(config.databaseUrl);
|
|
231
|
+
const rows = await query(sql, params);
|
|
232
|
+
const first = rows[0] ?? {};
|
|
233
|
+
const recordId = first["id"];
|
|
234
|
+
// (xmax = 0) is the standard "was this row inserted vs updated" probe;
|
|
235
|
+
// best-effort — purely for a friendlier message.
|
|
236
|
+
const action = first["inserted"] === true ? "created" : "updated";
|
|
237
|
+
return {
|
|
238
|
+
outcome: "upserted",
|
|
239
|
+
row,
|
|
240
|
+
sql,
|
|
241
|
+
recordId,
|
|
242
|
+
coordinationVerified,
|
|
243
|
+
message: `Neon inventory row ${action}${recordId !== undefined ? ` (id ${recordId})` : ""}.` +
|
|
244
|
+
coordNote +
|
|
245
|
+
promptNote,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
catch (err) {
|
|
249
|
+
return {
|
|
250
|
+
outcome: "failed",
|
|
251
|
+
row,
|
|
252
|
+
sql,
|
|
253
|
+
coordinationVerified,
|
|
254
|
+
message: `Neon inventory write failed (${err.message}); the row was ` +
|
|
255
|
+
`NOT written. Scaffold completed normally — add the row by hand or re-run later.`,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export declare const DEFAULT_LICENSE_API_BASE: string;
|
|
2
|
+
export declare const PRODUCT_SLUG = "z2w-starter-kit";
|
|
3
|
+
export declare const DEFAULT_CONFIG_DIR: string;
|
|
4
|
+
export declare const LICENSE_FILE_NAME = "license";
|
|
5
|
+
/** 24h local cache: skip /license/check if last attempt is within this window. */
|
|
6
|
+
export declare const CACHE_TTL_MS: number;
|
|
7
|
+
/** Past this many days of consecutive check failures, the CLI declines paid features. */
|
|
8
|
+
export declare const N_DAY_CEILING = 14;
|
|
9
|
+
/** Past this many days of consecutive check failures, the CLI warns (but still allows). */
|
|
10
|
+
export declare const N_DAY_WARN_THRESHOLD: number;
|
|
11
|
+
export type ServerStatus = "active" | "expired" | "suspended" | "revoked";
|
|
12
|
+
export interface LicenseState {
|
|
13
|
+
version: 1;
|
|
14
|
+
key: string;
|
|
15
|
+
productSlug: string;
|
|
16
|
+
machineId: string;
|
|
17
|
+
lastSuccessfulCheck: string | null;
|
|
18
|
+
lastCheckAttempt: string | null;
|
|
19
|
+
cachedStatus: ServerStatus | null;
|
|
20
|
+
cachedExpiresAt: string | null;
|
|
21
|
+
retryAfter: string | null;
|
|
22
|
+
}
|
|
23
|
+
export type LicenseEvaluationReason = "active" | "expired-snapshot-only" | "suspended-snapshot-only" | "revoked-blocked" | "check-failing-within-grace" | "check-failing-past-warn" | "check-failing-past-ceiling" | "never-checked" | "no-license";
|
|
24
|
+
export interface LicenseEvaluation {
|
|
25
|
+
allowPaidFeatures: boolean;
|
|
26
|
+
allowTemplatesUpdates: boolean;
|
|
27
|
+
reason: LicenseEvaluationReason;
|
|
28
|
+
warning: string | null;
|
|
29
|
+
daysSinceLastCheck: number | null;
|
|
30
|
+
}
|
|
31
|
+
export interface RuntimeOptions {
|
|
32
|
+
/** Override the config directory (tests). Default {@link DEFAULT_CONFIG_DIR}. */
|
|
33
|
+
configDir?: string;
|
|
34
|
+
/** Override the API base URL (tests). Default {@link DEFAULT_LICENSE_API_BASE}. */
|
|
35
|
+
licenseApiBase?: string;
|
|
36
|
+
/** Override the fetch implementation (tests). Default global `fetch`. */
|
|
37
|
+
fetchImpl?: typeof fetch;
|
|
38
|
+
/** Override the clock (tests). Default `() => Date.now()`. */
|
|
39
|
+
now?: () => number;
|
|
40
|
+
/** Override UUID generation (tests). Default `() => crypto.randomUUID()`. */
|
|
41
|
+
uuid?: () => string;
|
|
42
|
+
}
|
|
43
|
+
export declare class LicenseError extends Error {
|
|
44
|
+
constructor(message: string);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Maps stored license state + current time to a paid-feature decision. Pure
|
|
48
|
+
* function — no I/O, no side effects. The runtime check writes new state to
|
|
49
|
+
* disk first and THEN calls this; the unit tests pin every row in the
|
|
50
|
+
* directive §8 failure matrix against this function alone.
|
|
51
|
+
*/
|
|
52
|
+
export declare function evaluateLicense(state: LicenseState | null, now?: number): LicenseEvaluation;
|
|
53
|
+
export declare function loadLicenseState(opts?: RuntimeOptions): Promise<LicenseState | null>;
|
|
54
|
+
export declare function saveLicenseState(state: LicenseState, opts?: RuntimeOptions): Promise<void>;
|
|
55
|
+
export declare function clearLicenseState(opts?: RuntimeOptions): Promise<void>;
|
|
56
|
+
export declare function isValidLicenseKey(key: string): boolean;
|
|
57
|
+
/** Masks a license key for diagnostic display: "Z2W-ABCD-...-WXYZ". */
|
|
58
|
+
export declare function maskKey(key: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Activates a license on this machine. On 2xx, persists state including a
|
|
61
|
+
* fresh `lastSuccessfulCheck`. On error, throws LicenseError without writing.
|
|
62
|
+
*/
|
|
63
|
+
export declare function activateLicense(key: string, opts?: RuntimeOptions): Promise<{
|
|
64
|
+
state: LicenseState;
|
|
65
|
+
status: ServerStatus;
|
|
66
|
+
}>;
|
|
67
|
+
export interface CheckResult {
|
|
68
|
+
state: LicenseState;
|
|
69
|
+
status: ServerStatus | null;
|
|
70
|
+
networkOk: boolean;
|
|
71
|
+
message: string | null;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Calls /license/check and updates state accordingly. Never throws on network
|
|
75
|
+
* failure / 5xx / 429 — bumps `lastCheckAttempt`, persists `retryAfter` if
|
|
76
|
+
* the server sent one, and returns `networkOk: false`. Throws only when no
|
|
77
|
+
* license is configured (callers should handle that ahead of time).
|
|
78
|
+
*
|
|
79
|
+
* Honors a previously-persisted Retry-After by short-circuiting the network
|
|
80
|
+
* call until the persisted deadline passes.
|
|
81
|
+
*/
|
|
82
|
+
export declare function checkLicense(opts?: RuntimeOptions): Promise<CheckResult>;
|
|
83
|
+
/**
|
|
84
|
+
* Deactivates the local license. Attempts to notify the server (so the
|
|
85
|
+
* activation slot frees up) but clears local state even if the server call
|
|
86
|
+
* fails — the user has decided to deactivate, and a stuck server-side
|
|
87
|
+
* activation isn't a reason to block them.
|
|
88
|
+
*/
|
|
89
|
+
export declare function deactivateLicense(opts?: RuntimeOptions): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* The orchestrator paid-feature gates call. Reads stored state; if cache is
|
|
92
|
+
* stale (>24h since last attempt), phones home; runs the pure evaluator
|
|
93
|
+
* against whatever state ends up persisted. Never throws — returns a
|
|
94
|
+
* well-formed evaluation in every case so call sites can switch on
|
|
95
|
+
* `allowPaidFeatures` cleanly.
|
|
96
|
+
*/
|
|
97
|
+
export declare function runtimeLicenseCheck(opts?: RuntimeOptions): Promise<LicenseEvaluation>;
|