@cellarnode/ui 0.185.1 → 0.187.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/dist/brand/brand-generation-api.d.ts +44 -0
- package/dist/brand/brand-generation-api.d.ts.map +1 -0
- package/dist/brand/brand-generation-api.js +2 -0
- package/dist/brand/brand-generation-api.js.map +1 -0
- package/dist/brand/brand-generation-client.d.ts +28 -0
- package/dist/brand/brand-generation-client.d.ts.map +1 -0
- package/dist/brand/brand-generation-client.js +107 -0
- package/dist/brand/brand-generation-client.js.map +1 -0
- package/dist/brand/brand-generation-copy.d.ts +44 -0
- package/dist/brand/brand-generation-copy.d.ts.map +1 -0
- package/dist/brand/brand-generation-copy.js +70 -0
- package/dist/brand/brand-generation-copy.js.map +1 -0
- package/dist/brand/brand-generation-fixtures.d.ts +32 -0
- package/dist/brand/brand-generation-fixtures.d.ts.map +1 -0
- package/dist/brand/brand-generation-fixtures.js +88 -0
- package/dist/brand/brand-generation-fixtures.js.map +1 -0
- package/dist/brand/brand-generation-flow.d.ts +34 -0
- package/dist/brand/brand-generation-flow.d.ts.map +1 -0
- package/dist/brand/brand-generation-flow.js +34 -0
- package/dist/brand/brand-generation-flow.js.map +1 -0
- package/dist/brand/brand-generation-keys.d.ts +16 -0
- package/dist/brand/brand-generation-keys.d.ts.map +1 -0
- package/dist/brand/brand-generation-keys.js +16 -0
- package/dist/brand/brand-generation-keys.js.map +1 -0
- package/dist/brand/brand-generation-progress.d.ts +27 -0
- package/dist/brand/brand-generation-progress.d.ts.map +1 -0
- package/dist/brand/brand-generation-progress.js +61 -0
- package/dist/brand/brand-generation-progress.js.map +1 -0
- package/dist/brand/brand-generation-recovery-error.d.ts +8 -0
- package/dist/brand/brand-generation-recovery-error.d.ts.map +1 -0
- package/dist/brand/brand-generation-recovery-error.js +7 -0
- package/dist/brand/brand-generation-recovery-error.js.map +1 -0
- package/dist/brand/brand-generation-response.d.ts +86 -0
- package/dist/brand/brand-generation-response.d.ts.map +1 -0
- package/dist/brand/brand-generation-response.js +261 -0
- package/dist/brand/brand-generation-response.js.map +1 -0
- package/dist/brand/brand-generation-sse-parser.d.ts +14 -0
- package/dist/brand/brand-generation-sse-parser.d.ts.map +1 -0
- package/dist/brand/brand-generation-sse-parser.js +92 -0
- package/dist/brand/brand-generation-sse-parser.js.map +1 -0
- package/dist/brand/brand-generation-steps.d.ts +4 -0
- package/dist/brand/brand-generation-steps.d.ts.map +1 -0
- package/dist/brand/brand-generation-steps.js +29 -0
- package/dist/brand/brand-generation-steps.js.map +1 -0
- package/dist/brand/brand-generation-surface.d.ts +50 -0
- package/dist/brand/brand-generation-surface.d.ts.map +1 -0
- package/dist/brand/brand-generation-surface.js +25 -0
- package/dist/brand/brand-generation-surface.js.map +1 -0
- package/dist/brand/brand-generation-url.d.ts +6 -0
- package/dist/brand/brand-generation-url.d.ts.map +1 -0
- package/dist/brand/brand-generation-url.js +4 -0
- package/dist/brand/brand-generation-url.js.map +1 -0
- package/dist/brand/index.d.ts +20 -0
- package/dist/brand/index.d.ts.map +1 -1
- package/dist/brand/index.js +15 -0
- package/dist/brand/index.js.map +1 -1
- package/dist/brand/resume-brand-generation.d.ts +17 -0
- package/dist/brand/resume-brand-generation.d.ts.map +1 -0
- package/dist/brand/resume-brand-generation.js +22 -0
- package/dist/brand/resume-brand-generation.js.map +1 -0
- package/dist/brand/use-brand-generation-discovery.d.ts +14 -0
- package/dist/brand/use-brand-generation-discovery.d.ts.map +1 -0
- package/dist/brand/use-brand-generation-discovery.js +61 -0
- package/dist/brand/use-brand-generation-discovery.js.map +1 -0
- package/dist/brand/use-brand-generation-transport.d.ts +16 -0
- package/dist/brand/use-brand-generation-transport.d.ts.map +1 -0
- package/dist/brand/use-brand-generation-transport.js +182 -0
- package/dist/brand/use-brand-generation-transport.js.map +1 -0
- package/dist/brand/use-brand-generation.d.ts +35 -0
- package/dist/brand/use-brand-generation.d.ts.map +1 -0
- package/dist/brand/use-brand-generation.js +225 -0
- package/dist/brand/use-brand-generation.js.map +1 -0
- package/dist/brand/use-org-scoped-state.d.ts +3 -0
- package/dist/brand/use-org-scoped-state.d.ts.map +1 -0
- package/dist/brand/use-org-scoped-state.js +22 -0
- package/dist/brand/use-org-scoped-state.js.map +1 -0
- package/dist/components/multi-step-loader.d.ts +4 -0
- package/dist/components/multi-step-loader.d.ts.map +1 -1
- package/dist/components/multi-step-loader.js +4 -3
- package/dist/components/multi-step-loader.js.map +1 -1
- package/dist/profile/business-details.d.ts +3 -1
- package/dist/profile/business-details.d.ts.map +1 -1
- package/dist/profile/business-details.js +2 -2
- package/dist/profile/business-details.js.map +1 -1
- package/dist/profile/certifications-card.d.ts +3 -1
- package/dist/profile/certifications-card.d.ts.map +1 -1
- package/dist/profile/certifications-card.js +2 -2
- package/dist/profile/certifications-card.js.map +1 -1
- package/dist/profile/importer-profile-view.d.ts +88 -0
- package/dist/profile/importer-profile-view.d.ts.map +1 -0
- package/dist/profile/importer-profile-view.js +87 -0
- package/dist/profile/importer-profile-view.js.map +1 -0
- package/dist/profile/index.d.ts +1 -0
- package/dist/profile/index.d.ts.map +1 -1
- package/dist/profile/index.js +1 -0
- package/dist/profile/index.js.map +1 -1
- package/dist/profile/market-reach.d.ts +3 -1
- package/dist/profile/market-reach.d.ts.map +1 -1
- package/dist/profile/market-reach.js +2 -2
- package/dist/profile/market-reach.js.map +1 -1
- package/dist/profile/profile-hero.d.ts +3 -1
- package/dist/profile/profile-hero.d.ts.map +1 -1
- package/dist/profile/profile-hero.js +3 -2
- package/dist/profile/profile-hero.js.map +1 -1
- package/dist/realtime/job-status/schemas.d.ts +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { BrandGenerationActiveResult, BrandGenerationContext, BrandGenerationJob, BrandGenerationStartResponse } from "./brand-generation-response.js";
|
|
2
|
+
/**
|
|
3
|
+
* The transport-agnostic seam of the shared generation flow. A consumer
|
|
4
|
+
* supplies one implementation; the hook never touches `fetch` for these calls.
|
|
5
|
+
* Producer wraps its generated openapi client; importer uses
|
|
6
|
+
* `createBrandGenerationClient`. Both talk to the same backend endpoints.
|
|
7
|
+
*
|
|
8
|
+
* Every method rejects on failure (the hook maps a rejection to its error
|
|
9
|
+
* kind) and resolves already-parsed values.
|
|
10
|
+
*/
|
|
11
|
+
export interface BrandGenerationApi {
|
|
12
|
+
/** `POST /brand-profiles/generate/`. Retry is a start with amended context. */
|
|
13
|
+
start(homepageUrl: string, context?: BrandGenerationContext): Promise<BrandGenerationStartResponse>;
|
|
14
|
+
/** `GET /brand-profiles/generate/active?includeTerminal=`. */
|
|
15
|
+
getActive(includeTerminal?: boolean): Promise<BrandGenerationActiveResult>;
|
|
16
|
+
/** `GET /brand-profiles/generate/{jobId}`. */
|
|
17
|
+
getStatus(jobId: string): Promise<BrandGenerationJob>;
|
|
18
|
+
/** `PUT /brand-profiles/generate/{jobId}/cancel`. */
|
|
19
|
+
cancel(jobId: string): Promise<BrandGenerationJob>;
|
|
20
|
+
/** `PUT /brand-profiles/generate/{jobId}/prioritize-url`. */
|
|
21
|
+
prioritizeUrl(jobId: string, url: string): Promise<BrandGenerationJob>;
|
|
22
|
+
/** `PUT /brand-profiles/generate/{jobId}/accept`. */
|
|
23
|
+
accept(jobId: string): Promise<BrandGenerationJob>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* How the SSE stream (`GET /brand-profiles/generate/{jobId}/stream`) is opened.
|
|
27
|
+
*
|
|
28
|
+
* - Bearer mode: pass `getAccessToken`. A `null` token means "no session
|
|
29
|
+
* token available", which degrades to polling exactly like producer.
|
|
30
|
+
* - Cookie mode: omit `getAccessToken`; the stream is opened with
|
|
31
|
+
* `credentials: "include"` and no Authorization header.
|
|
32
|
+
*/
|
|
33
|
+
export interface BrandGenerationStreamConfig {
|
|
34
|
+
/** API origin, no trailing slash needed (e.g. `http://localhost:4000`). */
|
|
35
|
+
readonly baseUrl: string;
|
|
36
|
+
readonly getAccessToken?: () => Promise<string | null>;
|
|
37
|
+
/** Defaults to the global `fetch`. */
|
|
38
|
+
readonly fetch?: typeof fetch;
|
|
39
|
+
/** Idle ms before a silent stream is abandoned for polling. Default 15000. */
|
|
40
|
+
readonly idleTimeoutMs?: number;
|
|
41
|
+
/** Status poll interval while degraded. Default 2000. */
|
|
42
|
+
readonly pollIntervalMs?: number;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=brand-generation-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-api.d.ts","sourceRoot":"","sources":["../../src/brand/brand-generation-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,sBAAsB,EACtB,kBAAkB,EAClB,4BAA4B,EAC7B,MAAM,6BAA6B,CAAC;AAErC;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IACjC,+EAA+E;IAC/E,KAAK,CACH,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,4BAA4B,CAAC,CAAC;IACzC,8DAA8D;IAC9D,SAAS,CAAC,eAAe,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAC3E,8CAA8C;IAC9C,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACtD,qDAAqD;IACrD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACnD,6DAA6D;IAC7D,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACvE,qDAAqD;IACrD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACpD;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,2BAA2B;IAC1C,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACvD,sCAAsC;IACtC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IAC9B,8EAA8E;IAC9E,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,yDAAyD;IACzD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-api.js","sourceRoot":"","sources":["../../src/brand/brand-generation-api.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { BrandGenerationApi } from "./brand-generation-api.js";
|
|
2
|
+
/** A non-2xx answer from a generation endpoint. */
|
|
3
|
+
export declare class BrandGenerationRequestError extends Error {
|
|
4
|
+
readonly status: number;
|
|
5
|
+
readonly code: string;
|
|
6
|
+
constructor(status: number, code: string, message: string);
|
|
7
|
+
}
|
|
8
|
+
export interface BrandGenerationClientOptions {
|
|
9
|
+
/** API origin (e.g. `http://localhost:4000`). */
|
|
10
|
+
readonly baseUrl: string;
|
|
11
|
+
/** Bearer token source. Omit for cookie auth (`credentials: "include"`). */
|
|
12
|
+
readonly getAccessToken?: () => Promise<string | null>;
|
|
13
|
+
/**
|
|
14
|
+
* Defaults to the global `fetch`. Pass the consumer's authenticated fetch
|
|
15
|
+
* (the one that refreshes an expired session) here: it owns refresh. With
|
|
16
|
+
* `getAccessToken` the client additionally retries ONCE on a 401, asking
|
|
17
|
+
* `getAccessToken` for a fresh token, so a consumer whose token getter
|
|
18
|
+
* refreshes needs no custom fetch.
|
|
19
|
+
*/
|
|
20
|
+
readonly fetch?: typeof fetch;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The shared HTTP implementation of {@link BrandGenerationApi}. It parses every
|
|
24
|
+
* response with the same strict parsers producer uses, so a wire drift fails
|
|
25
|
+
* the same way in every consumer instead of rendering a half-valid job.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createBrandGenerationClient(options: BrandGenerationClientOptions): BrandGenerationApi;
|
|
28
|
+
//# sourceMappingURL=brand-generation-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-client.d.ts","sourceRoot":"","sources":["../../src/brand/brand-generation-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AASjE,mDAAmD;AACnD,qBAAa,2BAA4B,SAAQ,KAAK;IAElD,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM;gBADZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;CAKlB;AAED,MAAM,WAAW,4BAA4B;IAC3C,iDAAiD;IACjD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,4EAA4E;IAC5E,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACvD;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CAC/B;AAyBD;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,4BAA4B,GACpC,kBAAkB,CA+EpB"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { BrandGenerationResponseError, parseActiveEnvelope, parseJob, parseStart, } from "./brand-generation-response.js";
|
|
2
|
+
/** A non-2xx answer from a generation endpoint. */
|
|
3
|
+
export class BrandGenerationRequestError extends Error {
|
|
4
|
+
status;
|
|
5
|
+
code;
|
|
6
|
+
constructor(status, code, message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.name = "BrandGenerationRequestError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function isRecord(value) {
|
|
14
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
15
|
+
}
|
|
16
|
+
function errorFields(body, fallback) {
|
|
17
|
+
if (!isRecord(body))
|
|
18
|
+
return { code: "UNKNOWN", message: fallback };
|
|
19
|
+
const nested = isRecord(body.error) ? body.error : body;
|
|
20
|
+
return {
|
|
21
|
+
code: typeof nested.code === "string" ? nested.code : "UNKNOWN",
|
|
22
|
+
message: typeof nested.message === "string"
|
|
23
|
+
? nested.message
|
|
24
|
+
: typeof body.message === "string"
|
|
25
|
+
? body.message
|
|
26
|
+
: fallback,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function toWireContext(context) {
|
|
30
|
+
const { focusUrls, ...rest } = context;
|
|
31
|
+
return focusUrls === undefined ? rest : { ...rest, focusUrls: [...focusUrls] };
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The shared HTTP implementation of {@link BrandGenerationApi}. It parses every
|
|
35
|
+
* response with the same strict parsers producer uses, so a wire drift fails
|
|
36
|
+
* the same way in every consumer instead of rendering a half-valid job.
|
|
37
|
+
*/
|
|
38
|
+
export function createBrandGenerationClient(options) {
|
|
39
|
+
const base = options.baseUrl.replace(/\/+$/, "");
|
|
40
|
+
async function request(method, path, fallback, body) {
|
|
41
|
+
const doFetch = options.fetch ?? fetch;
|
|
42
|
+
const send = async (token) => {
|
|
43
|
+
const headers = { Accept: "application/json" };
|
|
44
|
+
if (body !== undefined)
|
|
45
|
+
headers["Content-Type"] = "application/json";
|
|
46
|
+
if (token)
|
|
47
|
+
headers.Authorization = `Bearer ${token}`;
|
|
48
|
+
return doFetch(`${base}${path}`, {
|
|
49
|
+
method,
|
|
50
|
+
headers,
|
|
51
|
+
...(options.getAccessToken ? {} : { credentials: "include" }),
|
|
52
|
+
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
let response = await send(options.getAccessToken ? await options.getAccessToken() : undefined);
|
|
56
|
+
if (response.status === 401 && options.getAccessToken) {
|
|
57
|
+
// The token may have expired between read and send; ask again (a
|
|
58
|
+
// refreshing getter returns a new one) and retry exactly once.
|
|
59
|
+
response = await send(await options.getAccessToken());
|
|
60
|
+
}
|
|
61
|
+
if (response.status === 204)
|
|
62
|
+
return { status: 204, data: undefined };
|
|
63
|
+
let parsed;
|
|
64
|
+
try {
|
|
65
|
+
parsed = await response.json();
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
parsed = undefined;
|
|
69
|
+
}
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
const { code, message } = errorFields(parsed, fallback);
|
|
72
|
+
throw new BrandGenerationRequestError(response.status, code, message);
|
|
73
|
+
}
|
|
74
|
+
return { status: response.status, data: parsed };
|
|
75
|
+
}
|
|
76
|
+
async function job(method, path, fallback, body) {
|
|
77
|
+
const { status, data } = await request(method, path, fallback, body);
|
|
78
|
+
const parsed = parseJob(data, false);
|
|
79
|
+
if (parsed === null)
|
|
80
|
+
throw new BrandGenerationResponseError(status);
|
|
81
|
+
return parsed;
|
|
82
|
+
}
|
|
83
|
+
const jobPath = (jobId) => `/brand-profiles/generate/${encodeURIComponent(jobId)}`;
|
|
84
|
+
return {
|
|
85
|
+
async start(homepageUrl, context) {
|
|
86
|
+
const { status, data } = await request("POST", "/brand-profiles/generate/", "Failed to start brand generation", context === undefined ? { homepageUrl } : { homepageUrl, context: toWireContext(context) });
|
|
87
|
+
const start = parseStart(data);
|
|
88
|
+
if (start === null)
|
|
89
|
+
throw new BrandGenerationResponseError(status);
|
|
90
|
+
return start;
|
|
91
|
+
},
|
|
92
|
+
async getActive(includeTerminal = false) {
|
|
93
|
+
const { status, data } = await request("GET", `/brand-profiles/generate/active?includeTerminal=${includeTerminal}`, "Failed to get active brand generation");
|
|
94
|
+
if (status === 204)
|
|
95
|
+
return { job: null, eligibility: null };
|
|
96
|
+
const result = parseActiveEnvelope(data);
|
|
97
|
+
if (result === null)
|
|
98
|
+
throw new BrandGenerationResponseError(status);
|
|
99
|
+
return result;
|
|
100
|
+
},
|
|
101
|
+
getStatus: (jobId) => job("GET", jobPath(jobId), "Failed to get job status"),
|
|
102
|
+
cancel: (jobId) => job("PUT", `${jobPath(jobId)}/cancel`, "Failed to cancel brand generation"),
|
|
103
|
+
prioritizeUrl: (jobId, url) => job("PUT", `${jobPath(jobId)}/prioritize-url`, "Failed to prioritize URL", { url }),
|
|
104
|
+
accept: (jobId) => job("PUT", `${jobPath(jobId)}/accept`, "Failed to accept brand generation"),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=brand-generation-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-client.js","sourceRoot":"","sources":["../../src/brand/brand-generation-client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,EACnB,QAAQ,EACR,UAAU,GAEX,MAAM,6BAA6B,CAAC;AAErC,mDAAmD;AACnD,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IAEzC;IACA;IAFX,YACW,MAAc,EACd,IAAY,EACrB,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAJN,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QAIrB,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;IAC5C,CAAC;CACF;AAiBD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,WAAW,CAAC,IAAa,EAAE,QAAgB;IAClD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;I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AAG,MAAM,OAAO,CACpC,KAAK,EACL,mDAAmD,eAAe,EAAE,EACpE,uCAAuC,CACxC,CAAC;YACF,IAAI,MAAM,KAAK,GAAG;gBAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;YAC5D,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;YACzC,IAAI,MAAM,KAAK,IAAI;gBAAE,MAAM,IAAI,4BAA4B,CAAC,MAAM,CAAC,CAAC;YACpE,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,0BAA0B,CAAC;QAC5E,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,mCAAmC,CAAC;QAC9F,aAAa,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAC5B,GAAG,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,0BAA0B,EAAE,EAAE,GAAG,EAAE,CAAC;QACrF,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,mCAAmC,CAAC;KAC/F,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type BrandProfilePageChecklistCopy } from "../components/brand-profile-page-checklist.js";
|
|
2
|
+
import type { MultiStepLoaderCopy } from "../components/multi-step-loader.js";
|
|
3
|
+
import type { BrandGenerationErrorKind } from "./brand-generation-keys.js";
|
|
4
|
+
import type { BrandGenerationRecoveryCopy } from "./brand-generation-recovery-copy.js";
|
|
5
|
+
import type { BrandPersona } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Every string `BrandGenerationProgress` / `BrandGenerationSurface` render.
|
|
8
|
+
* The package does not do i18n: a consumer passes already translated strings
|
|
9
|
+
* (producer through `t()`), or relies on the English defaults below.
|
|
10
|
+
*/
|
|
11
|
+
export interface BrandGenerationCopy {
|
|
12
|
+
readonly title: string;
|
|
13
|
+
readonly subtitle: string;
|
|
14
|
+
readonly transportDegraded: string;
|
|
15
|
+
readonly cancelAction: string;
|
|
16
|
+
readonly eligibilityUnavailable: string;
|
|
17
|
+
/** Sub-label on a re-crawl pass, e.g. "pass 2". */
|
|
18
|
+
readonly passLabel: (pass: number) => string;
|
|
19
|
+
/** Rail labels keyed by generation phase. */
|
|
20
|
+
readonly phaseLabels: Readonly<Record<"mapping" | "selecting" | "crawling" | "consolidating" | "finalizing", string>>;
|
|
21
|
+
readonly errors: Readonly<Record<BrandGenerationErrorKind, string>>;
|
|
22
|
+
readonly checklist: BrandProfilePageChecklistCopy;
|
|
23
|
+
/** Step rail: the live-region announcement and the list's accessible name. */
|
|
24
|
+
readonly stepper: Required<MultiStepLoaderCopy>;
|
|
25
|
+
/** Accessible name of the placeholder rail shown before the first phase. */
|
|
26
|
+
readonly loadingStepsLabel: string;
|
|
27
|
+
/** Merged over `DEFAULT_BRAND_GENERATION_RECOVERY_COPY`. */
|
|
28
|
+
readonly recovery: BrandGenerationRecoveryCopy;
|
|
29
|
+
/** Shown when recovering an in-progress job failed (`discoveryError`). */
|
|
30
|
+
readonly recoveryFailed: string;
|
|
31
|
+
/** Review-step actions of `BrandGenerationSurface`. */
|
|
32
|
+
readonly acceptAction: string;
|
|
33
|
+
readonly acceptingAction: string;
|
|
34
|
+
readonly dismissAction: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Default copy for a persona. Importer and distributor orgs are the "importer"
|
|
38
|
+
* persona; they read their own company website, so the wording says so. Every
|
|
39
|
+
* other string is shared, which is the point: one flow, two voices, no drift.
|
|
40
|
+
*/
|
|
41
|
+
export declare function defaultBrandGenerationCopy(persona?: BrandPersona): BrandGenerationCopy;
|
|
42
|
+
/** Overlay a consumer's partial copy on the persona defaults. */
|
|
43
|
+
export declare function resolveBrandGenerationCopy(persona: BrandPersona, copy?: Partial<BrandGenerationCopy>): BrandGenerationCopy;
|
|
44
|
+
//# sourceMappingURL=brand-generation-copy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-copy.d.ts","sourceRoot":"","sources":["../../src/brand/brand-generation-copy.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AACpF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;IACxC,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7C,6CAA6C;IAC7C,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAC5B,MAAM,CAAC,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,eAAe,GAAG,YAAY,EAAE,MAAM,CAAC,CACtF,CAAC;IACF,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC,CAAC;IACpE,QAAQ,CAAC,SAAS,EAAE,6BAA6B,CAAC;IAClD,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAC;IAChD,4EAA4E;IAC5E,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,2BAA2B,CAAC;IAC/C,0EAA0E;IAC1E,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,uDAAuD;IACvD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AA2CD;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,YAAyB,GACjC,mBAAmB,CAQrB;AAED,iEAAiE;AACjE,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,YAAY,EACrB,IAAI,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAClC,mBAAmB,CAYrB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { defaultBrandProfilePageChecklistCopy, } from "../components/brand-profile-page-checklist.js";
|
|
2
|
+
const PRODUCER_COPY = {
|
|
3
|
+
title: "Generating Brand Profile",
|
|
4
|
+
subtitle: "We are analyzing your website to build a complete brand profile.",
|
|
5
|
+
transportDegraded: "Live updates degraded, refreshing every 2s",
|
|
6
|
+
cancelAction: "Cancel",
|
|
7
|
+
eligibilityUnavailable: "Generation is unavailable right now. Try again later or create your profile manually.",
|
|
8
|
+
passLabel: (pass) => `pass ${pass}`,
|
|
9
|
+
phaseLabels: {
|
|
10
|
+
mapping: "Mapping your website",
|
|
11
|
+
selecting: "Choosing pages to read",
|
|
12
|
+
crawling: "Crawling and reading pages",
|
|
13
|
+
consolidating: "Consolidating information",
|
|
14
|
+
finalizing: "Saving draft",
|
|
15
|
+
},
|
|
16
|
+
errors: {
|
|
17
|
+
start: "Could not start generation. Try again.",
|
|
18
|
+
cancel: "Could not cancel generation. Try again.",
|
|
19
|
+
prioritize: "Could not prioritize this page. Try again.",
|
|
20
|
+
accept: "Could not accept profile. Try again.",
|
|
21
|
+
resume: "Could not resume generation. Try again.",
|
|
22
|
+
},
|
|
23
|
+
checklist: defaultBrandProfilePageChecklistCopy,
|
|
24
|
+
stepper: {
|
|
25
|
+
announceLabel: (current, total, label) => `Step ${current} of ${total}: ${label}`,
|
|
26
|
+
stepsLabel: "Process steps",
|
|
27
|
+
},
|
|
28
|
+
loadingStepsLabel: "Loading steps",
|
|
29
|
+
recovery: {
|
|
30
|
+
failedHeading: "Generation Failed",
|
|
31
|
+
failedBody: "An unknown error occurred.",
|
|
32
|
+
retryAction: "Retry",
|
|
33
|
+
createManuallyAction: "Cancel",
|
|
34
|
+
cancelAction: "Cancel",
|
|
35
|
+
},
|
|
36
|
+
recoveryFailed: "Could not recover an in-progress generation. Refresh the page to try again.",
|
|
37
|
+
acceptAction: "Accept Profile",
|
|
38
|
+
acceptingAction: "Accepting...",
|
|
39
|
+
dismissAction: "Dismiss",
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Default copy for a persona. Importer and distributor orgs are the "importer"
|
|
43
|
+
* persona; they read their own company website, so the wording says so. Every
|
|
44
|
+
* other string is shared, which is the point: one flow, two voices, no drift.
|
|
45
|
+
*/
|
|
46
|
+
export function defaultBrandGenerationCopy(persona = "producer") {
|
|
47
|
+
if (persona === "importer") {
|
|
48
|
+
return {
|
|
49
|
+
...PRODUCER_COPY,
|
|
50
|
+
subtitle: "We are analyzing your company website to build a complete brand profile.",
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return PRODUCER_COPY;
|
|
54
|
+
}
|
|
55
|
+
/** Overlay a consumer's partial copy on the persona defaults. */
|
|
56
|
+
export function resolveBrandGenerationCopy(persona, copy) {
|
|
57
|
+
const base = defaultBrandGenerationCopy(persona);
|
|
58
|
+
if (!copy)
|
|
59
|
+
return base;
|
|
60
|
+
return {
|
|
61
|
+
...base,
|
|
62
|
+
...copy,
|
|
63
|
+
phaseLabels: { ...base.phaseLabels, ...copy.phaseLabels },
|
|
64
|
+
errors: { ...base.errors, ...copy.errors },
|
|
65
|
+
checklist: { ...base.checklist, ...copy.checklist },
|
|
66
|
+
stepper: { ...base.stepper, ...copy.stepper },
|
|
67
|
+
recovery: { ...base.recovery, ...copy.recovery },
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=brand-generation-copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-copy.js","sourceRoot":"","sources":["../../src/brand/brand-generation-copy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oCAAoC,GAErC,MAAM,4CAA4C,CAAC;AAuCpD,MAAM,aAAa,GAAwB;IACzC,KAAK,EAAE,0BAA0B;IACjC,QAAQ,EAAE,kEAAkE;IAC5E,iBAAiB,EAAE,4CAA4C;IAC/D,YAAY,EAAE,QAAQ;IACtB,sBAAsB,EACpB,uFAAuF;IACzF,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,IAAI,EAAE;IACnC,WAAW,EAAE;QACX,OAAO,EAAE,sBAAsB;QAC/B,SAAS,EAAE,wBAAwB;QACnC,QAAQ,EAAE,4BAA4B;QACtC,aAAa,EAAE,2BAA2B;QAC1C,UAAU,EAAE,cAAc;KAC3B;IACD,MAAM,EAAE;QACN,KAAK,EAAE,wCAAwC;QAC/C,MAAM,EAAE,yCAAyC;QACjD,UAAU,EAAE,4CAA4C;QACxD,MAAM,EAAE,sCAAsC;QAC9C,MAAM,EAAE,yCAAyC;KAClD;IACD,SAAS,EAAE,oCAAoC;IAC/C,OAAO,EAAE;QACP,aAAa,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,QAAQ,OAAO,OAAO,KAAK,KAAK,KAAK,EAAE;QACjF,UAAU,EAAE,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|
+
import type { BrandGenerationApi } from "./brand-generation-api.js";
|
|
2
|
+
import type { BrandGenerationEligibility, BrandGenerationJob, BrandGenerationJobProgress } from "./brand-generation-response.js";
|
|
3
|
+
/** Fixtures for the generation flow's tests and stories. Not a public export. */
|
|
4
|
+
export declare const IDLE_ELIGIBILITY: BrandGenerationEligibility;
|
|
5
|
+
export declare function makeJob(overrides?: Partial<BrandGenerationJob>): BrandGenerationJob;
|
|
6
|
+
export declare function makeProgress(phase: NonNullable<BrandGenerationJobProgress["phase"]>, extra?: Partial<BrandGenerationJobProgress>): BrandGenerationJobProgress;
|
|
7
|
+
/** One `text/event-stream` frame for a job update. */
|
|
8
|
+
export declare function sseFrame(update: Record<string, unknown>): string;
|
|
9
|
+
export interface FakeStream {
|
|
10
|
+
/** The `fetch` to inject. Records every call in `calls`. */
|
|
11
|
+
readonly fetch: typeof fetch;
|
|
12
|
+
readonly calls: {
|
|
13
|
+
url: string;
|
|
14
|
+
init: RequestInit | undefined;
|
|
15
|
+
}[];
|
|
16
|
+
/** Push a frame to the open stream. */
|
|
17
|
+
push(frame: string): void;
|
|
18
|
+
/** End the open stream normally (without a terminal update). */
|
|
19
|
+
end(): void;
|
|
20
|
+
/** Error the open stream mid-read. */
|
|
21
|
+
fail(error: Error): void;
|
|
22
|
+
/** True once the consumer aborted the open request. */
|
|
23
|
+
readonly aborted: () => boolean;
|
|
24
|
+
}
|
|
25
|
+
/** A controllable SSE endpoint: one open stream per `fetch` call, driven by the test. */
|
|
26
|
+
export declare function createFakeStream(options?: {
|
|
27
|
+
status?: number;
|
|
28
|
+
fetchError?: Error;
|
|
29
|
+
}): FakeStream;
|
|
30
|
+
/** A `BrandGenerationApi` whose every method is a configurable stub. */
|
|
31
|
+
export declare function createFakeApi(overrides?: Partial<BrandGenerationApi>): BrandGenerationApi;
|
|
32
|
+
//# sourceMappingURL=brand-generation-fixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-fixtures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oCZ;AAED,wEAAwE;AACxE,wBAAgB,aAAa,CAAC,SAAS,GAAE,OAAO,CAAC,kBAAkB,CAAM,GAAG,kBAAkB,CAW7F"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/** Fixtures for the generation flow's tests and stories. Not a public export. */
|
|
2
|
+
export const IDLE_ELIGIBILITY = {
|
|
3
|
+
canStart: true,
|
|
4
|
+
reason: null,
|
|
5
|
+
nextEligibleAt: null,
|
|
6
|
+
lastUsefulDraftAt: null,
|
|
7
|
+
retriesRemainingToday: 3,
|
|
8
|
+
};
|
|
9
|
+
export function makeJob(overrides = {}) {
|
|
10
|
+
return {
|
|
11
|
+
id: "job-1",
|
|
12
|
+
workflowId: "wf-1",
|
|
13
|
+
status: "running",
|
|
14
|
+
progress: {},
|
|
15
|
+
error: null,
|
|
16
|
+
createdAt: "2026-10-01T10:00:00.000Z",
|
|
17
|
+
updatedAt: "2026-10-01T10:00:00.000Z",
|
|
18
|
+
...overrides,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function makeProgress(phase, extra = {}) {
|
|
22
|
+
return { phase, ...extra };
|
|
23
|
+
}
|
|
24
|
+
/** One `text/event-stream` frame for a job update. */
|
|
25
|
+
export function sseFrame(update) {
|
|
26
|
+
return `data: ${JSON.stringify(update)}\n\n`;
|
|
27
|
+
}
|
|
28
|
+
/** A closed or aborted stream rejects further writes; a test driving it after that is a no-op. */
|
|
29
|
+
function safely(action) {
|
|
30
|
+
try {
|
|
31
|
+
action();
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// stream already closed or errored
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** A controllable SSE endpoint: one open stream per `fetch` call, driven by the test. */
|
|
38
|
+
export function createFakeStream(options = {}) {
|
|
39
|
+
const calls = [];
|
|
40
|
+
let controller = null;
|
|
41
|
+
let wasAborted = false;
|
|
42
|
+
const encoder = new TextEncoder();
|
|
43
|
+
const fakeFetch = ((input, init) => {
|
|
44
|
+
calls.push({ url: String(input), init });
|
|
45
|
+
if (options.fetchError)
|
|
46
|
+
return Promise.reject(options.fetchError);
|
|
47
|
+
init?.signal?.addEventListener("abort", () => {
|
|
48
|
+
wasAborted = true;
|
|
49
|
+
try {
|
|
50
|
+
controller?.error(new DOMException("aborted", "AbortError"));
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// stream already closed
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
const body = new ReadableStream({
|
|
57
|
+
start(c) {
|
|
58
|
+
controller = c;
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
return Promise.resolve(new Response(body, {
|
|
62
|
+
status: options.status ?? 200,
|
|
63
|
+
headers: { "Content-Type": "text/event-stream" },
|
|
64
|
+
}));
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
fetch: fakeFetch,
|
|
68
|
+
calls,
|
|
69
|
+
push: (frame) => safely(() => controller?.enqueue(encoder.encode(frame))),
|
|
70
|
+
end: () => safely(() => controller?.close()),
|
|
71
|
+
fail: (error) => safely(() => controller?.error(error)),
|
|
72
|
+
aborted: () => wasAborted,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** A `BrandGenerationApi` whose every method is a configurable stub. */
|
|
76
|
+
export function createFakeApi(overrides = {}) {
|
|
77
|
+
const idle = { job: null, eligibility: IDLE_ELIGIBILITY };
|
|
78
|
+
return {
|
|
79
|
+
start: async () => ({ jobId: "job-1", workflowId: "wf-1", reused: false }),
|
|
80
|
+
getActive: async () => idle,
|
|
81
|
+
getStatus: async () => makeJob(),
|
|
82
|
+
cancel: async () => makeJob({ status: "cancelled", outcome: "cancelled" }),
|
|
83
|
+
prioritizeUrl: async () => makeJob(),
|
|
84
|
+
accept: async () => makeJob({ status: "completed" }),
|
|
85
|
+
...overrides,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=brand-generation-fixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-fixtures.js","sourceRoot":"","sources":["../../src/brand/brand-generation-fixtures.ts"],"names":[],"mappings":"AAQA,iFAAiF;AAEjF,MAAM,CAAC,MAAM,gBAAgB,GAA+B;IAC1D,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,IAAI;IACZ,cAAc,EAAE,IAAI;IACpB,iBAAiB,EAAE,IAAI;IACvB,qBAAqB,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,UAAU,OAAO,CAAC,YAAyC,EAAE;IACjE,OAAO;QACL,EAAE,EAAE,OAAO;QACX,UAAU,EAAE,MAAM;QAClB,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,EAAE;QACZ,KAAK,EAAE,IAAI;QACX,SAAS,EAAE,0BAA0B;QACrC,SAAS,EAAE,0BAA0B;QACrC,GAAG,SAAS;KACb,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,KAAuD,EACvD,QAA6C,EAAE;IAE/C,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CAAC;AAC7B,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,QAAQ,CAAC,MAA+B;IACtD,OAAO,SAAS,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC;AAC/C,CAAC;AAED,kGAAkG;AAClG,SAAS,MAAM,CAAC,MAAkB;IAChC,IAAI,CAAC;QACH,MAAM,EAAE,CAAC;IACX,CAAC;IAAC,MAAM,CAAC;QACP,mCAAmC;IACrC,CAAC;AACH,CAAC;AAgBD,yFAAyF;AACzF,MAAM,UAAU,gBAAgB,CAC9B,UAAmD,EAAE;IAErD,MAAM,KAAK,GAAwB,EAAE,CAAC;IACtC,IAAI,UAAU,GAAuD,IAAI,CAAC;IAC1E,IAAI,UAAU,GAAG,KAAK,CAAC;IACvB,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,MAAM,SAAS,GAAG,CAAC,CAAC,KAAwB,EAAE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CAAC,KAAK,CAAC,CAAC;QACvD,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU;KAC1B,CAAC;AACJ,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,aAAa,CAAC,YAAyC,EAAE;IACvE,MAAM,IAAI,GAAgC,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;IACvF,OAAO;QACL,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAC1E,SAAS,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;QAC3B,SAAS,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,EAAE;QAChC,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;QAC1E,aAAa,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,EAAE;QACpC,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;QACpD,GAAG,SAAS;KACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { BrandGenerationJob } from "./brand-generation-response.js";
|
|
2
|
+
interface BrandGenerationFlowInput<TProfile extends {
|
|
3
|
+
readonly status?: string;
|
|
4
|
+
}, TDraft extends {
|
|
5
|
+
readonly generatedFromJobId?: string | null;
|
|
6
|
+
}> {
|
|
7
|
+
readonly brandGeneration: {
|
|
8
|
+
readonly job: BrandGenerationJob | null;
|
|
9
|
+
readonly isGenerating: boolean;
|
|
10
|
+
};
|
|
11
|
+
readonly profile: TProfile | null | undefined;
|
|
12
|
+
readonly draftProfile: TDraft | null | undefined;
|
|
13
|
+
readonly profileError: boolean;
|
|
14
|
+
readonly draftError: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Decides whether the page is inside the generation flow (progress, recovery or
|
|
18
|
+
* draft review) or showing the settled profile. Pure, so every consumer derives
|
|
19
|
+
* the same answer from the same hook state and queries.
|
|
20
|
+
*/
|
|
21
|
+
export declare function deriveBrandGenerationFlow<TProfile extends {
|
|
22
|
+
readonly status?: string;
|
|
23
|
+
}, TDraft extends {
|
|
24
|
+
readonly generatedFromJobId?: string | null;
|
|
25
|
+
}>({ brandGeneration, profile, draftProfile, profileError, draftError, }: BrandGenerationFlowInput<TProfile, TDraft>): {
|
|
26
|
+
generatedDraftProfile: TDraft | null;
|
|
27
|
+
terminalDraftProfile: TDraft | null;
|
|
28
|
+
terminalJobOwnsDraft: boolean;
|
|
29
|
+
recoveredDraft: boolean;
|
|
30
|
+
inGenerationFlow: boolean;
|
|
31
|
+
workspaceProfile: TProfile | TDraft | null | undefined;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=brand-generation-flow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-flow.d.ts","sourceRoot":"","sources":["../../src/brand/brand-generation-flow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,UAAU,wBAAwB,CAChC,QAAQ,SAAS;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAC7C,MAAM,SAAS;IAAE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE;IAE9D,QAAQ,CAAC,eAAe,EAAE;QACxB,QAAQ,CAAC,GAAG,EAAE,kBAAkB,GAAG,IAAI,CAAC;QACxC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;KAChC,CAAC;IACF,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACjD,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,SAAS;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAC7C,MAAM,SAAS;IAAE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAC9D,EACA,eAAe,EACf,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,UAAU,GACX,EAAE,wBAAwB,CAAC,QAAQ,EAAE,MAAM,CAAC;;;;;;;EA8B5C"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isTerminalStatus } from "./brand-generation-keys.js";
|
|
2
|
+
/**
|
|
3
|
+
* Decides whether the page is inside the generation flow (progress, recovery or
|
|
4
|
+
* draft review) or showing the settled profile. Pure, so every consumer derives
|
|
5
|
+
* the same answer from the same hook state and queries.
|
|
6
|
+
*/
|
|
7
|
+
export function deriveBrandGenerationFlow({ brandGeneration, profile, draftProfile, profileError, draftError, }) {
|
|
8
|
+
const generatedDraftProfile = draftProfile?.generatedFromJobId ? draftProfile : null;
|
|
9
|
+
const activeJob = brandGeneration.job && !isTerminalStatus(brandGeneration.job.status)
|
|
10
|
+
? brandGeneration.job
|
|
11
|
+
: null;
|
|
12
|
+
const terminalDraftProfile = generatedDraftProfile;
|
|
13
|
+
const terminalJobOwnsDraft = brandGeneration.job?.status === "completed" &&
|
|
14
|
+
terminalDraftProfile !== null &&
|
|
15
|
+
terminalDraftProfile.generatedFromJobId === brandGeneration.job.id;
|
|
16
|
+
const recoveredDraft = brandGeneration.job === null && Boolean(generatedDraftProfile);
|
|
17
|
+
const inGenerationFlow = brandGeneration.isGenerating ||
|
|
18
|
+
Boolean(activeJob) ||
|
|
19
|
+
profile?.status === "generating" ||
|
|
20
|
+
terminalJobOwnsDraft ||
|
|
21
|
+
brandGeneration.job?.status === "failed" ||
|
|
22
|
+
brandGeneration.job?.status === "cancelled" ||
|
|
23
|
+
(brandGeneration.job?.status === "completed" && (profileError || draftError)) ||
|
|
24
|
+
recoveredDraft;
|
|
25
|
+
return {
|
|
26
|
+
generatedDraftProfile,
|
|
27
|
+
terminalDraftProfile,
|
|
28
|
+
terminalJobOwnsDraft,
|
|
29
|
+
recoveredDraft,
|
|
30
|
+
inGenerationFlow,
|
|
31
|
+
workspaceProfile: generatedDraftProfile ?? profile,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=brand-generation-flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-flow.js","sourceRoot":"","sources":["../../src/brand/brand-generation-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAiB3D;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAGvC,EACA,eAAe,EACf,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,UAAU,GACiC;IAC3C,MAAM,qBAAqB,GAAG,YAAY,EAAE,kBAAkB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;IACrF,MAAM,SAAS,GACb,eAAe,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC;QAClE,CAAC,CAAC,eAAe,CAAC,GAAG;QACrB,CAAC,CAAC,IAAI,CAAC;IACX,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;IACnD,MAAM,oBAAoB,GACxB,eAAe,CAAC,GAAG,EAAE,MAAM,KAAK,WAAW;QAC3C,oBAAoB,KAAK,IAAI;QAC7B,oBAAoB,CAAC,kBAAkB,KAAK,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;IACrE,MAAM,cAAc,GAAG,eAAe,CAAC,GAAG,KAAK,IAAI,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACtF,MAAM,gBAAgB,GACpB,eAAe,CAAC,YAAY;QAC5B,OAAO,CAAC,SAAS,CAAC;QAClB,OAAO,EAAE,MAAM,KAAK,YAAY;QAChC,oBAAoB;QACpB,eAAe,CAAC,GAAG,EAAE,MAAM,KAAK,QAAQ;QACxC,eAAe,CAAC,GAAG,EAAE,MAAM,KAAK,WAAW;QAC3C,CAAC,eAAe,CAAC,GAAG,EAAE,MAAM,KAAK,WAAW,IAAI,CAAC,YAAY,IAAI,UAAU,CAAC,CAAC;QAC7E,cAAc,CAAC;IAEjB,OAAO;QACL,qBAAqB;QACrB,oBAAoB;QACpB,oBAAoB;QACpB,cAAc;QACd,gBAAgB;QAChB,gBAAgB,EAAE,qBAAqB,IAAI,OAAO;KACnD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BrandGenerationJobStatus } from "./brand-generation-response.js";
|
|
2
|
+
declare const brandGenerationErrorKinds: readonly ["start", "cancel", "prioritize", "accept", "resume"];
|
|
3
|
+
export type BrandGenerationErrorKind = (typeof brandGenerationErrorKinds)[number];
|
|
4
|
+
/**
|
|
5
|
+
* TanStack Query keys owned by the shared generation flow. Namespaced under
|
|
6
|
+
* `"brand-generation"` and scoped by org so they cannot collide with a
|
|
7
|
+
* consumer's own keys (CEL-2146). Consumers must not reuse this namespace.
|
|
8
|
+
*/
|
|
9
|
+
export declare const brandGenerationKeys: {
|
|
10
|
+
all: readonly ["brand-generation"];
|
|
11
|
+
active: (orgId: string) => readonly ["brand-generation", string, "active"];
|
|
12
|
+
latestTerminal: (orgId: string) => readonly ["brand-generation", string, "latest-terminal"];
|
|
13
|
+
};
|
|
14
|
+
export declare function isTerminalStatus(status: BrandGenerationJobStatus | undefined): boolean;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=brand-generation-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-keys.d.ts","sourceRoot":"","sources":["../../src/brand/brand-generation-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAG5E,QAAA,MAAM,yBAAyB,gEAAiE,CAAC;AAEjG,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;oBAEd,MAAM;4BACE,MAAM;CAC/B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,wBAAwB,GAAG,SAAS,GAAG,OAAO,CAEtF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const terminalStatuses = ["completed", "failed", "cancelled"];
|
|
2
|
+
const brandGenerationErrorKinds = ["start", "cancel", "prioritize", "accept", "resume"];
|
|
3
|
+
/**
|
|
4
|
+
* TanStack Query keys owned by the shared generation flow. Namespaced under
|
|
5
|
+
* `"brand-generation"` and scoped by org so they cannot collide with a
|
|
6
|
+
* consumer's own keys (CEL-2146). Consumers must not reuse this namespace.
|
|
7
|
+
*/
|
|
8
|
+
export const brandGenerationKeys = {
|
|
9
|
+
all: ["brand-generation"],
|
|
10
|
+
active: (orgId) => ["brand-generation", orgId, "active"],
|
|
11
|
+
latestTerminal: (orgId) => ["brand-generation", orgId, "latest-terminal"],
|
|
12
|
+
};
|
|
13
|
+
export function isTerminalStatus(status) {
|
|
14
|
+
return status !== undefined && terminalStatuses.includes(status);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=brand-generation-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-keys.js","sourceRoot":"","sources":["../../src/brand/brand-generation-keys.ts"],"names":[],"mappings":"AAEA,MAAM,gBAAgB,GAAwC,CAAC,WAAW,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;AACnG,MAAM,yBAAyB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC;AAIjG;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,GAAG,EAAE,CAAC,kBAAkB,CAAU;IAClC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,kBAAkB,EAAE,KAAK,EAAE,QAAQ,CAAU;IACzE,cAAc,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,kBAAkB,EAAE,KAAK,EAAE,iBAAiB,CAAU;CAC3F,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAAC,MAA4C;IAC3E,OAAO,MAAM,KAAK,SAAS,IAAI,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type BrandGenerationCopy } from "./brand-generation-copy.js";
|
|
2
|
+
import type { BrandGenerationErrorKind } from "./brand-generation-keys.js";
|
|
3
|
+
import type { BrandGenerationContext, BrandGenerationEligibility, BrandGenerationJob } from "./brand-generation-response.js";
|
|
4
|
+
import type { BrandPersona } from "./types.js";
|
|
5
|
+
export interface BrandGenerationProgressProps {
|
|
6
|
+
readonly job: BrandGenerationJob | null;
|
|
7
|
+
readonly eligibility?: BrandGenerationEligibility | null;
|
|
8
|
+
readonly transportDegraded: boolean;
|
|
9
|
+
readonly error: BrandGenerationErrorKind | null;
|
|
10
|
+
/** The homepage URL a retry starts with. Empty hides the retry action. */
|
|
11
|
+
readonly resolvedUrl: string;
|
|
12
|
+
readonly onStart: (url: string, context?: BrandGenerationContext) => void;
|
|
13
|
+
readonly onCancel: () => void;
|
|
14
|
+
readonly onReset: () => void;
|
|
15
|
+
/** Persona picks the default wording; `copy` overrides any string. */
|
|
16
|
+
readonly persona?: BrandPersona;
|
|
17
|
+
readonly copy?: Partial<BrandGenerationCopy>;
|
|
18
|
+
/** Formats the ISO dates the recovery surface shows (cooldown). Required: locale is the caller's. */
|
|
19
|
+
readonly formatDateTime: (iso: string) => string;
|
|
20
|
+
readonly idPrefix?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Progress, failure and recovery for one brand-generation attempt. Pure
|
|
24
|
+
* presentation: state comes from `useBrandGeneration`, strings from `copy`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function BrandGenerationProgress({ job, eligibility, transportDegraded, error, resolvedUrl, onStart, onCancel, onReset, persona, copy, formatDateTime, idPrefix, }: BrandGenerationProgressProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
//# sourceMappingURL=brand-generation-progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-generation-progress.d.ts","sourceRoot":"","sources":["../../src/brand/brand-generation-progress.tsx"],"names":[],"mappings":"AAOA,OAAO,EAA8B,KAAK,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC/F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAExE,OAAO,KAAK,EACV,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EACnB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAsB5C,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,GAAG,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,WAAW,CAAC,EAAE,0BAA0B,GAAG,IAAI,CAAC;IACzD,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAChD,0EAA0E;IAC1E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAC1E,QAAQ,CAAC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