@cellarnode/ui 0.186.0 → 0.188.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.
Files changed (129) hide show
  1. package/dist/brand/brand-assets-api.d.ts +58 -0
  2. package/dist/brand/brand-assets-api.d.ts.map +1 -0
  3. package/dist/brand/brand-assets-api.js +160 -0
  4. package/dist/brand/brand-assets-api.js.map +1 -0
  5. package/dist/brand/brand-generation-api.d.ts +44 -0
  6. package/dist/brand/brand-generation-api.d.ts.map +1 -0
  7. package/dist/brand/brand-generation-api.js +2 -0
  8. package/dist/brand/brand-generation-api.js.map +1 -0
  9. package/dist/brand/brand-generation-client.d.ts +36 -0
  10. package/dist/brand/brand-generation-client.d.ts.map +1 -0
  11. package/dist/brand/brand-generation-client.js +107 -0
  12. package/dist/brand/brand-generation-client.js.map +1 -0
  13. package/dist/brand/brand-generation-copy.d.ts +44 -0
  14. package/dist/brand/brand-generation-copy.d.ts.map +1 -0
  15. package/dist/brand/brand-generation-copy.js +70 -0
  16. package/dist/brand/brand-generation-copy.js.map +1 -0
  17. package/dist/brand/brand-generation-fixtures.d.ts +32 -0
  18. package/dist/brand/brand-generation-fixtures.d.ts.map +1 -0
  19. package/dist/brand/brand-generation-fixtures.js +88 -0
  20. package/dist/brand/brand-generation-fixtures.js.map +1 -0
  21. package/dist/brand/brand-generation-flow.d.ts +34 -0
  22. package/dist/brand/brand-generation-flow.d.ts.map +1 -0
  23. package/dist/brand/brand-generation-flow.js +34 -0
  24. package/dist/brand/brand-generation-flow.js.map +1 -0
  25. package/dist/brand/brand-generation-keys.d.ts +16 -0
  26. package/dist/brand/brand-generation-keys.d.ts.map +1 -0
  27. package/dist/brand/brand-generation-keys.js +16 -0
  28. package/dist/brand/brand-generation-keys.js.map +1 -0
  29. package/dist/brand/brand-generation-progress.d.ts +27 -0
  30. package/dist/brand/brand-generation-progress.d.ts.map +1 -0
  31. package/dist/brand/brand-generation-progress.js +61 -0
  32. package/dist/brand/brand-generation-progress.js.map +1 -0
  33. package/dist/brand/brand-generation-recovery-error.d.ts +8 -0
  34. package/dist/brand/brand-generation-recovery-error.d.ts.map +1 -0
  35. package/dist/brand/brand-generation-recovery-error.js +7 -0
  36. package/dist/brand/brand-generation-recovery-error.js.map +1 -0
  37. package/dist/brand/brand-generation-response.d.ts +86 -0
  38. package/dist/brand/brand-generation-response.d.ts.map +1 -0
  39. package/dist/brand/brand-generation-response.js +261 -0
  40. package/dist/brand/brand-generation-response.js.map +1 -0
  41. package/dist/brand/brand-generation-sse-parser.d.ts +14 -0
  42. package/dist/brand/brand-generation-sse-parser.d.ts.map +1 -0
  43. package/dist/brand/brand-generation-sse-parser.js +92 -0
  44. package/dist/brand/brand-generation-sse-parser.js.map +1 -0
  45. package/dist/brand/brand-generation-start.d.ts +49 -0
  46. package/dist/brand/brand-generation-start.d.ts.map +1 -0
  47. package/dist/brand/brand-generation-start.js +48 -0
  48. package/dist/brand/brand-generation-start.js.map +1 -0
  49. package/dist/brand/brand-generation-steps.d.ts +4 -0
  50. package/dist/brand/brand-generation-steps.d.ts.map +1 -0
  51. package/dist/brand/brand-generation-steps.js +29 -0
  52. package/dist/brand/brand-generation-steps.js.map +1 -0
  53. package/dist/brand/brand-generation-surface.d.ts +50 -0
  54. package/dist/brand/brand-generation-surface.d.ts.map +1 -0
  55. package/dist/brand/brand-generation-surface.js +25 -0
  56. package/dist/brand/brand-generation-surface.js.map +1 -0
  57. package/dist/brand/brand-generation-url.d.ts +6 -0
  58. package/dist/brand/brand-generation-url.d.ts.map +1 -0
  59. package/dist/brand/brand-generation-url.js +4 -0
  60. package/dist/brand/brand-generation-url.js.map +1 -0
  61. package/dist/brand/brand-image-chooser.d.ts +3 -1
  62. package/dist/brand/brand-image-chooser.d.ts.map +1 -1
  63. package/dist/brand/brand-image-chooser.js +7 -1
  64. package/dist/brand/brand-image-chooser.js.map +1 -1
  65. package/dist/brand/brand-image-choosers.d.ts +37 -0
  66. package/dist/brand/brand-image-choosers.d.ts.map +1 -0
  67. package/dist/brand/brand-image-choosers.js +76 -0
  68. package/dist/brand/brand-image-choosers.js.map +1 -0
  69. package/dist/brand/brand-workspace-change-notice.d.ts +20 -0
  70. package/dist/brand/brand-workspace-change-notice.d.ts.map +1 -0
  71. package/dist/brand/brand-workspace-change-notice.js +19 -0
  72. package/dist/brand/brand-workspace-change-notice.js.map +1 -0
  73. package/dist/brand/index.d.ts +37 -0
  74. package/dist/brand/index.d.ts.map +1 -1
  75. package/dist/brand/index.js +29 -0
  76. package/dist/brand/index.js.map +1 -1
  77. package/dist/brand/resume-brand-generation.d.ts +17 -0
  78. package/dist/brand/resume-brand-generation.d.ts.map +1 -0
  79. package/dist/brand/resume-brand-generation.js +22 -0
  80. package/dist/brand/resume-brand-generation.js.map +1 -0
  81. package/dist/brand/use-brand-generation-discovery.d.ts +14 -0
  82. package/dist/brand/use-brand-generation-discovery.d.ts.map +1 -0
  83. package/dist/brand/use-brand-generation-discovery.js +61 -0
  84. package/dist/brand/use-brand-generation-discovery.js.map +1 -0
  85. package/dist/brand/use-brand-generation-transport.d.ts +16 -0
  86. package/dist/brand/use-brand-generation-transport.d.ts.map +1 -0
  87. package/dist/brand/use-brand-generation-transport.js +182 -0
  88. package/dist/brand/use-brand-generation-transport.js.map +1 -0
  89. package/dist/brand/use-brand-generation.d.ts +35 -0
  90. package/dist/brand/use-brand-generation.d.ts.map +1 -0
  91. package/dist/brand/use-brand-generation.js +225 -0
  92. package/dist/brand/use-brand-generation.js.map +1 -0
  93. package/dist/brand/use-brand-image-operation-result.d.ts +43 -0
  94. package/dist/brand/use-brand-image-operation-result.d.ts.map +1 -0
  95. package/dist/brand/use-brand-image-operation-result.js +162 -0
  96. package/dist/brand/use-brand-image-operation-result.js.map +1 -0
  97. package/dist/brand/use-brand-profile-acceptance.d.ts +38 -0
  98. package/dist/brand/use-brand-profile-acceptance.d.ts.map +1 -0
  99. package/dist/brand/use-brand-profile-acceptance.js +84 -0
  100. package/dist/brand/use-brand-profile-acceptance.js.map +1 -0
  101. package/dist/brand/use-brand-public-visibility.d.ts +59 -0
  102. package/dist/brand/use-brand-public-visibility.d.ts.map +1 -0
  103. package/dist/brand/use-brand-public-visibility.js +69 -0
  104. package/dist/brand/use-brand-public-visibility.js.map +1 -0
  105. package/dist/brand/use-brand-workspace-concurrency.d.ts +132 -0
  106. package/dist/brand/use-brand-workspace-concurrency.d.ts.map +1 -0
  107. package/dist/brand/use-brand-workspace-concurrency.js +255 -0
  108. package/dist/brand/use-brand-workspace-concurrency.js.map +1 -0
  109. package/dist/brand/use-brand-workspace-image-candidates.d.ts +19 -0
  110. package/dist/brand/use-brand-workspace-image-candidates.d.ts.map +1 -0
  111. package/dist/brand/use-brand-workspace-image-candidates.js +39 -0
  112. package/dist/brand/use-brand-workspace-image-candidates.js.map +1 -0
  113. package/dist/brand/use-org-scoped-state.d.ts +3 -0
  114. package/dist/brand/use-org-scoped-state.d.ts.map +1 -0
  115. package/dist/brand/use-org-scoped-state.js +22 -0
  116. package/dist/brand/use-org-scoped-state.js.map +1 -0
  117. package/dist/components/multi-step-loader.d.ts +4 -0
  118. package/dist/components/multi-step-loader.d.ts.map +1 -1
  119. package/dist/components/multi-step-loader.js +4 -3
  120. package/dist/components/multi-step-loader.js.map +1 -1
  121. package/dist/moderation/moderation-event.d.ts +2 -0
  122. package/dist/moderation/moderation-event.d.ts.map +1 -1
  123. package/dist/moderation/moderation-event.js +7 -0
  124. package/dist/moderation/moderation-event.js.map +1 -1
  125. package/dist/moderation/moderation-store.d.ts.map +1 -1
  126. package/dist/moderation/moderation-store.js +4 -2
  127. package/dist/moderation/moderation-store.js.map +1 -1
  128. package/dist/realtime/job-status/schemas.d.ts +2 -2
  129. package/package.json +1 -1
@@ -0,0 +1,58 @@
1
+ import type { ModerationPersistedRead } from "../moderation/index.js";
2
+ import type { BrandAsset, BrandProfileAssetSlot } from "./types.js";
3
+ /** The moderation-relevant fields the backend returns with every asset. */
4
+ export interface BrandAssetModeration {
5
+ readonly outcome: "pending" | "pass" | "reject" | "unsure" | null;
6
+ readonly publishedAt: string | null;
7
+ }
8
+ export type BrandAssetRecord = BrandAsset & BrandAssetModeration;
9
+ export interface UploadBrandAssetArgs {
10
+ readonly profileId: string;
11
+ readonly slot: BrandProfileAssetSlot;
12
+ readonly file: File;
13
+ }
14
+ /**
15
+ * CEL-2127 — the transport-agnostic seam of the brand image/asset flow
16
+ * (`/brand-profiles/{id}/assets*`, present in both the producer and importer
17
+ * OpenAPIs). A consumer supplies one implementation: producer may wrap its
18
+ * generated client, importer uses {@link createBrandAssetsClient}. Cache
19
+ * invalidation stays with the consumer (wrap `upload`).
20
+ */
21
+ export interface BrandAssetsApi {
22
+ /** `GET /brand-profiles/{id}/assets`. */
23
+ list(profileId: string): Promise<BrandAssetRecord[]>;
24
+ /** `POST .../assets/upload-url`, `PUT` the file to storage, `POST .../assets/confirm`. */
25
+ upload(args: UploadBrandAssetArgs): Promise<BrandAssetRecord>;
26
+ /** `DELETE /brand-profiles/{id}/assets/{assetId}`. */
27
+ remove(profileId: string, assetId: string): Promise<void>;
28
+ /**
29
+ * The durable, asset-id-keyed moderation read the shared moderation operation
30
+ * falls back to when no live verdict event arrives. `null` when the exact
31
+ * asset no longer exists; rejects on transport failure so the bounded poll
32
+ * retries instead of reporting a false outcome.
33
+ */
34
+ fetchModeration(profileId: string, assetId: string): Promise<ModerationPersistedRead | null>;
35
+ }
36
+ /** A non-2xx answer, or a failed storage upload, from the assets endpoints. */
37
+ export declare class BrandAssetsRequestError extends Error {
38
+ readonly status: number;
39
+ readonly code: string;
40
+ constructor(status: number, code: string, message: string);
41
+ }
42
+ export interface BrandAssetsClientOptions {
43
+ /** API origin (e.g. `http://localhost:4000`). */
44
+ readonly baseUrl: string;
45
+ /** Bearer token source. Omit for cookie auth (`credentials: "include"`). */
46
+ readonly getAccessToken?: () => Promise<string | null>;
47
+ /** Defaults to the global `fetch`. Used for the API calls only, never for the storage PUT. */
48
+ readonly fetch?: typeof fetch;
49
+ /** The injected `fetch` refreshes an expired session itself: never retry a 401 here. */
50
+ readonly fetchRefreshesSession?: boolean;
51
+ /** Abort the storage PUT after this long. Default 30000. */
52
+ readonly uploadTimeoutMs?: number;
53
+ }
54
+ /** Browsers report fonts as octet-stream or empty; the backend whitelists real font MIME types. */
55
+ export declare function resolveBrandAssetMimeType(file: File): string;
56
+ /** The shared HTTP implementation of {@link BrandAssetsApi}. */
57
+ export declare function createBrandAssetsClient(options: BrandAssetsClientOptions): BrandAssetsApi;
58
+ //# sourceMappingURL=brand-assets-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brand-assets-api.d.ts","sourceRoot":"","sources":["../../src/brand/brand-assets-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEjE,2EAA2E;AAC3E,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAC;IAClE,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAED,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,oBAAoB,CAAC;AAEjE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,yCAAyC;IACzC,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IACrD,0FAA0F;IAC1F,MAAM,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC9D,sDAAsD;IACtD,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D;;;;;OAKG;IACH,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC;CAC9F;AAED,+EAA+E;AAC/E,qBAAa,uBAAwB,SAAQ,KAAK;IAE9C,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,wBAAwB;IACvC,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,8FAA8F;IAC9F,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IAC9B,wFAAwF;IACxF,QAAQ,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IACzC,4DAA4D;IAC5D,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AASD,mGAAmG;AACnG,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAM5D;AAyCD,gEAAgE;AAChE,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,cAAc,CA2HzF"}
@@ -0,0 +1,160 @@
1
+ /** A non-2xx answer, or a failed storage upload, from the assets endpoints. */
2
+ export class BrandAssetsRequestError extends Error {
3
+ status;
4
+ code;
5
+ constructor(status, code, message) {
6
+ super(message);
7
+ this.status = status;
8
+ this.code = code;
9
+ this.name = "BrandAssetsRequestError";
10
+ }
11
+ }
12
+ const FONT_MIME_BY_EXTENSION = {
13
+ woff2: "font/woff2",
14
+ woff: "font/woff",
15
+ ttf: "font/ttf",
16
+ otf: "font/otf",
17
+ };
18
+ /** Browsers report fonts as octet-stream or empty; the backend whitelists real font MIME types. */
19
+ export function resolveBrandAssetMimeType(file) {
20
+ const extension = file.name.split(".").pop()?.toLowerCase();
21
+ const fontMime = extension ? FONT_MIME_BY_EXTENSION[extension] : undefined;
22
+ if (fontMime)
23
+ return fontMime;
24
+ if (file.type && file.type !== "application/octet-stream")
25
+ return file.type;
26
+ return "application/octet-stream";
27
+ }
28
+ function isRecord(value) {
29
+ return value !== null && typeof value === "object" && !Array.isArray(value);
30
+ }
31
+ const OUTCOMES = new Set(["pending", "pass", "reject", "unsure"]);
32
+ function parseAsset(value) {
33
+ if (!isRecord(value) ||
34
+ typeof value.id !== "string" ||
35
+ typeof value.slot !== "string" ||
36
+ typeof value.fileUrl !== "string") {
37
+ throw new BrandAssetsRequestError(200, "INVALID_RESPONSE", "Unexpected brand asset response");
38
+ }
39
+ const outcome = value.moderationOutcome;
40
+ return {
41
+ id: value.id,
42
+ slot: value.slot,
43
+ fileUrl: value.fileUrl,
44
+ fileName: typeof value.fileName === "string" ? value.fileName : "",
45
+ mimeType: typeof value.mimeType === "string" ? value.mimeType : "",
46
+ fileSize: typeof value.fileSize === "number" ? value.fileSize : 0,
47
+ width: typeof value.width === "number" ? value.width : null,
48
+ height: typeof value.height === "number" ? value.height : null,
49
+ outcome: typeof outcome === "string" && OUTCOMES.has(outcome) ? outcome : null,
50
+ publishedAt: typeof value.publishedAt === "string" ? value.publishedAt : null,
51
+ };
52
+ }
53
+ function errorFields(body, fallback) {
54
+ if (!isRecord(body))
55
+ return { code: "UNKNOWN", message: fallback };
56
+ const nested = isRecord(body.error) ? body.error : body;
57
+ return {
58
+ code: typeof nested.code === "string" ? nested.code : "UNKNOWN",
59
+ message: typeof nested.message === "string" ? nested.message : fallback,
60
+ };
61
+ }
62
+ /** The shared HTTP implementation of {@link BrandAssetsApi}. */
63
+ export function createBrandAssetsClient(options) {
64
+ const base = options.baseUrl.replace(/\/+$/, "");
65
+ const assetsPath = (profileId) => `/brand-profiles/${encodeURIComponent(profileId)}/assets`;
66
+ async function request(method, path, fallback, body) {
67
+ const doFetch = options.fetch ?? fetch;
68
+ const send = async (token) => {
69
+ const headers = { Accept: "application/json" };
70
+ if (body !== undefined)
71
+ headers["Content-Type"] = "application/json";
72
+ if (token)
73
+ headers.Authorization = `Bearer ${token}`;
74
+ return doFetch(`${base}${path}`, {
75
+ method,
76
+ headers,
77
+ ...(options.getAccessToken ? {} : { credentials: "include" }),
78
+ ...(body === undefined ? {} : { body: JSON.stringify(body) }),
79
+ });
80
+ };
81
+ let response = await send(options.getAccessToken ? await options.getAccessToken() : undefined);
82
+ if (response.status === 401 && options.getAccessToken && !options.fetchRefreshesSession) {
83
+ response = await send(await options.getAccessToken());
84
+ }
85
+ let parsed;
86
+ if (response.status !== 204) {
87
+ try {
88
+ parsed = await response.json();
89
+ }
90
+ catch {
91
+ parsed = undefined;
92
+ }
93
+ }
94
+ if (!response.ok) {
95
+ const { code, message } = errorFields(parsed, fallback);
96
+ throw new BrandAssetsRequestError(response.status, code, message);
97
+ }
98
+ return parsed;
99
+ }
100
+ async function list(profileId) {
101
+ const data = await request("GET", assetsPath(profileId), "Failed to list brand assets");
102
+ if (!isRecord(data) || !Array.isArray(data.assets)) {
103
+ throw new BrandAssetsRequestError(200, "INVALID_RESPONSE", "Unexpected brand asset list");
104
+ }
105
+ return data.assets.map(parseAsset);
106
+ }
107
+ return {
108
+ list,
109
+ async upload({ profileId, slot, file }) {
110
+ const mimeType = resolveBrandAssetMimeType(file);
111
+ const target = await request("POST", `${assetsPath(profileId)}/upload-url`, "Failed to start brand asset upload", { slot, fileName: file.name, mimeType, fileSize: file.size });
112
+ if (!isRecord(target) ||
113
+ typeof target.uploadUrl !== "string" ||
114
+ typeof target.uploadId !== "string") {
115
+ throw new BrandAssetsRequestError(200, "INVALID_RESPONSE", "Unexpected upload target");
116
+ }
117
+ const requiredHeaders = isRecord(target.requiredHeaders)
118
+ ? target.requiredHeaders
119
+ : {};
120
+ const controller = new AbortController();
121
+ const timeoutId = setTimeout(() => controller.abort(), options.uploadTimeoutMs ?? 30_000);
122
+ try {
123
+ let stored;
124
+ try {
125
+ // Storage is a different origin with a presigned URL: plain fetch,
126
+ // never the authenticated one, so no bearer token leaks to it.
127
+ stored = await fetch(target.uploadUrl, {
128
+ method: "PUT",
129
+ headers: requiredHeaders,
130
+ body: file,
131
+ signal: controller.signal,
132
+ });
133
+ }
134
+ catch {
135
+ throw new BrandAssetsRequestError(0, controller.signal.aborted ? "BRAND_ASSET_UPLOAD_TIMEOUT" : "BRAND_ASSET_UPLOAD_NETWORK", controller.signal.aborted
136
+ ? "Upload timed out. Please try again."
137
+ : "Network error while uploading. Please check your connection and try again.");
138
+ }
139
+ if (!stored.ok) {
140
+ throw new BrandAssetsRequestError(stored.status, "BRAND_ASSET_UPLOAD_FAILED", "Failed to upload file to storage");
141
+ }
142
+ }
143
+ finally {
144
+ clearTimeout(timeoutId);
145
+ }
146
+ const confirmed = await request("POST", `${assetsPath(profileId)}/confirm`, "Failed to confirm brand asset upload", { uploadId: target.uploadId, slot, fileName: file.name, mimeType, fileSize: file.size });
147
+ return parseAsset(confirmed);
148
+ },
149
+ async remove(profileId, assetId) {
150
+ await request("DELETE", `${assetsPath(profileId)}/${encodeURIComponent(assetId)}`, "Failed to delete brand asset");
151
+ },
152
+ async fetchModeration(profileId, assetId) {
153
+ const asset = (await list(profileId)).find((candidate) => candidate.id === assetId);
154
+ if (!asset)
155
+ return null;
156
+ return { identity: asset.id, outcome: asset.outcome, published: asset.publishedAt !== null };
157
+ },
158
+ };
159
+ }
160
+ //# sourceMappingURL=brand-assets-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brand-assets-api.js","sourceRoot":"","sources":["../../src/brand/brand-assets-api.ts"],"names":[],"mappings":"AAwCA,+EAA+E;AAC/E,MAAM,OAAO,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S,EAAE,OAAO;YAC7B,MAAM,OAAO,CACX,QAAQ,EACR,GAAG,UAAU,CAAC,SAAS,CAAC,IAAI,kBAAkB,CAAC,OAAO,CAAC,EAAE,EACzD,8BAA8B,CAC/B,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,eAAe,CAAC,SAAS,EAAE,OAAO;YACtC,MAAM,KAAK,GAAG,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC;YACpF,IAAI,CAAC,KAAK;gBAAE,OAAO,IAAI,CAAC;YACxB,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;QAC/F,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=brand-generation-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brand-generation-api.js","sourceRoot":"","sources":["../../src/brand/brand-generation-api.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
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
+ * Set when the injected `fetch` already refreshes an expired session and
23
+ * retries the request itself. The client then NEVER retries a 401: stacking
24
+ * its own retry on top of the consumer's would send a persistent 401 twice
25
+ * (2x2 requests) and hammer the refresh endpoint. Only meaningful together
26
+ * with `fetch`; default `false`.
27
+ */
28
+ readonly fetchRefreshesSession?: boolean;
29
+ }
30
+ /**
31
+ * The shared HTTP implementation of {@link BrandGenerationApi}. It parses every
32
+ * response with the same strict parsers producer uses, so a wire drift fails
33
+ * the same way in every consumer instead of rendering a half-valid job.
34
+ */
35
+ export declare function createBrandGenerationClient(options: BrandGenerationClientOptions): BrandGenerationApi;
36
+ //# 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;IAC9B;;;;;;OAMG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC;CAC1C;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 && !options.fetchRefreshesSession) {
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;AAyBD,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;IACnE,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IACxD,OAAO;QACL,IAAI,EAAE,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,M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AC;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,EAA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BAAmB,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,yCAA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,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE;QAC7C,QAAQ,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE;KACjD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,32 @@
1
+ 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.d.ts","sourceRoot":"","sources":["../../src/brand/brand-generation-fixtures.ts"],"names":[],"mappings":"AAA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