@civitai/app-sdk 0.87.0 → 0.89.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 CHANGED
@@ -95,19 +95,14 @@ import manifestSchema from '@civitai/app-sdk/schemas/app-block/v1.json' with { t
95
95
 
96
96
  A block runs in a sandboxed iframe. The host (civitai.com) and the block speak
97
97
  over `window.postMessage({ type, payload }, targetOrigin)`, discriminated by
98
- `type`. The full union is exported:
99
-
100
- - **parent → block**: `BLOCK_INIT`, `TOKEN_REFRESH`, `TOKEN_REFRESH_RESPONSE`,
101
- `ESTIMATE_RESULT`, `ESTIMATE_BATCH_RESULT`, `WORKFLOW_SUBMITTED`, `WORKFLOW_STATUS`,
102
- `BUZZ_PURCHASE_RESULT`, `CHECKPOINT_PICKER_RESULT`, `USER_CHECKPOINT_SET`,
103
- `APP_STORAGE_*_RESULT`, `SUSPEND`, `RESUME`, `THEME_CHANGE`, `ROUTE_CHANGED`,
104
- `CONSENT_UNAVAILABLE` (`ParentToBlockMessage`).
105
- - **block → parent**: `BLOCK_READY`, `BLOCK_ERROR`, `REQUEST_TOKEN`,
106
- `RESIZE_IFRAME`, `SUBMIT_WORKFLOW`, `ESTIMATE_WORKFLOW`,
107
- `ESTIMATE_WORKFLOW_BATCH`, `POLL_WORKFLOW`,
108
- `QUERY_APP_WORKFLOWS`, `CANCEL_APP_WORKFLOW`, `OPEN_BUZZ_PURCHASE`,
109
- `OPEN_CHECKPOINT_PICKER`, `SET_USER_CHECKPOINT`, `NAVIGATE`, `TRACK_EVENT`,
110
- `APP_STORAGE_*` (`BlockToParentMessage`).
98
+ `type`. Both unions are exported from `@civitai/app-sdk/blocks`, and their
99
+ source is the list — it is not copied here, so it cannot fall behind:
100
+
101
+ - **parent → block**: `ParentToBlockMessage` (`ParentToBlockMessageType` is its
102
+ `type` union), in
103
+ [`src/blocks/messages.ts`](https://github.com/civitai/civitai-app-starters/blob/main/packages/civitai-app-sdk/src/blocks/messages.ts).
104
+ - **block → parent**: `BlockToParentMessage` (`BlockToParentMessageType`), in the
105
+ same file; `BLOCK_TO_PARENT_MESSAGE_TYPES` is the same set as a runtime array.
111
106
 
112
107
  The app generator **subqueue** pair — `QUERY_APP_WORKFLOWS` →
113
108
  `APP_WORKFLOWS_RESULT` and `CANCEL_APP_WORKFLOW` → `CANCEL_APP_WORKFLOW_RESULT` —
@@ -117,6 +112,41 @@ forces the per-app tag filter off the block token, so a block only ever sees the
117
112
  queue it produced. Mirrors civitai/civitai PR #3164; the `@civitai/blocks-react`
118
113
  `useAppWorkflows()` hook wraps both.
119
114
 
115
+ `PERSIST_GENERATION_SOURCE` → `GENERATION_SOURCE_PERSISTED` saves ONE of those
116
+ outputs as a **private, scanned generation source** for the next generation.
117
+ The request is `{ requestId, workflowId, imageIndex }` (the output's POSITION in
118
+ the workflow's `outputs`, not an index into `images`; never a url) and the reply carries `result`, a
119
+ `BlockPersistedGenerationSource` (`{ url, width, height, imageId, ready }`), or a
120
+ free-text `error`. The image is private to the viewer and not on the app's
121
+ shared grid, and there is no confirm dialog. The host waits up to about thirty
122
+ seconds for the scan; `ready: false` means it is still pending, and a generation using the
123
+ source is refused with `source-scan-pending` until it finishes. `url` / `width` /
124
+ `height` are a `BlockGenerationSourceImageInfo`, so they go into a
125
+ `sourceImages` entry (a `textToImage` source image is refused with
126
+ `source-scan-pending` too). It is idempotent per (viewer, app, `workflowId`,
127
+ `imageIndex`): asking again returns the same image with its current `ready`.
128
+ Full-page app hosts only: the iframe/slot host, review mode, a block that is not
129
+ ready yet and App Assistant dev-tunnel previews all reply with an `error`. The
130
+ `@civitai/blocks-react` `usePersistGenerationSource()` hook wraps it; its README
131
+ section lists the size and rate limits:
132
+
133
+ ```ts
134
+ import type { BlockPersistedGenerationSource, WorkflowBody } from '@civitai/app-sdk/blocks';
135
+
136
+ declare const src: BlockPersistedGenerationSource; // from persist({ workflowId, imageIndex: 0 })
137
+ declare const modelId: number, modelVersionId: number;
138
+
139
+ const next: WorkflowBody = {
140
+ kind: 'textToImage',
141
+ modelId,
142
+ modelVersionId,
143
+ params: { prompt: 'the same fox, in snow' },
144
+ sourceImages: [{ url: src.url, width: src.width, height: src.height }],
145
+ };
146
+ // If `src.ready` was false, submitting `next` can fail with errorCode
147
+ // 'source-scan-pending' (nothing is reserved); retry it later.
148
+ ```
149
+
120
150
  `isMessage(data, 'BLOCK_INIT')` is a **discriminator-only** narrowing helper — it
121
151
  checks `data.type`, NOT the payload shape. Anything crossing the iframe trust
122
152
  boundary must be payload-validated at the boundary (the React transport does this
@@ -153,7 +183,78 @@ interface BlockInitPayload {
153
183
  | `isModelSlotContext(ctx)` / `isPageSlotContext(ctx)` | Runtime narrowing for the `slotId`-discriminated `BlockContext` union. Real checks on a value that crossed a `postMessage` boundary — they verify every field they assert, not just `slotId`. |
154
184
  | `fetchNestedDocument(opts)` | Embed one of your OWN bundled documents as an iframe `srcdoc`, because a nested `<iframe src>` of your own content **cannot load** — see [Nested documents](#nested-documents) below. `NestedDocumentError` carries a `.code` of `'invalid-url' \| 'http-error' \| 'network-error'`. |
155
185
  | `isSignedIn(viewer)` | **The sign-in gate.** `isSignedIn(useBlockContext().viewer)` — do not open-code it as `viewer !== null` or `viewer?.signedIn === true`. Which of those is correct has already changed once with the host contract, and this is the one place it is decided. It reads neither `viewer.id` nor `viewer.username` (both `@deprecated`), so nothing written through it changes when those are removed. Need the identity rather than the presence? `useViewer()` — scope-gated and audited per call. |
156
- | types | `BlockManifestV1`, `ManifestSettings` (+ field types), `BlockContext`, `ModelSlotContext`, `BlockCheckpointInfo`, `ShowcaseImage`, `BlockToken`, `WrappedToken`, `BlockSettings`, `ViewerInfo`, `Theme`, `WorkflowBody`, `BlockTextToImageParams`, `WorkflowBodyCustomComfy` (+ its two arms `WorkflowBodyCustomComfyRecipe` / `WorkflowBodyCustomComfyInline`, and `InlineComfyNode`), `WorkflowBodyStep` / `WorkflowBodyPassThroughStep` (the two arms of `kind: 'step'`), `WorkflowBodyTraining` (+ `AiToolkitTrainingParams`, `BlockTrainingQuote`, `BlockTrainingDatasetItem`, `BlockTrainingDataImage`, `BlockTrainingDataUploadResult`, `BlockRunTrainingHostError` and the `BLOCK_TRAINING_*` bounds), `WorkflowBodyWorkflow` (+ `WorkflowBodyWorkflowStep`, `WorkflowStepRef`, `WithWorkflowStepRefs`, `BlockWorkflowStepSnapshot` and `BLOCK_WORKFLOW_MAX_STEPS`), `BlockStepQuote` / `BlockRunConfirmedStepHostError` (+ `BLOCK_CONFIRMED_STEP_MAX_BUZZ_PER_JOB`, `BLOCK_STEP_QUOTE_ID_REGEX`), `BlockModel3dOutput`, `BlockWorkflowSnapshot`, `WorkflowStatus`, `BlockInitPayload`, `ParentToBlockMessage`, `BlockToParentMessage`. |
186
+ | types | `BlockManifestV1`, `ManifestSettings` (+ field types), `BlockContext`, `ModelSlotContext`, `BlockCheckpointInfo`, `ShowcaseImage`, `BlockToken`, `WrappedToken`, `BlockSettings`, `ViewerInfo`, `Theme`, `WorkflowBody`, `BlockTextToImageParams`, `WorkflowBodyCustomComfy` (+ its two arms `WorkflowBodyCustomComfyRecipe` / `WorkflowBodyCustomComfyInline`, and `InlineComfyNode`), `WorkflowBodyStep` / `WorkflowBodyPassThroughStep` (the two arms of `kind: 'step'`), `WorkflowBodyTraining` (+ `AiToolkitTrainingParams`, `BlockTrainingQuote`, `BlockTrainingDatasetItem`, `BlockTrainingDataImage`, `BlockTrainingDataUploadResult`, `BlockRunTrainingHostError` and the `BLOCK_TRAINING_*` bounds), `WorkflowBodyWorkflow` (+ `WorkflowBodyWorkflowStep`, `WorkflowStepRef`, `WithWorkflowStepRefs`, `BlockWorkflowStepSnapshot` and `BLOCK_WORKFLOW_MAX_STEPS`), `BlockStepQuote` / `BlockRunConfirmedStepHostError` (+ `BLOCK_CONFIRMED_STEP_MAX_BUZZ_PER_JOB`, `BLOCK_STEP_QUOTE_ID_REGEX`), `BlockModel3dOutput`, `BlockWorkflowSnapshot` (+ `BlockWorkflowEta`, `BlockWorkflowStepQueue` and `KnownBlockWorkflowQueueSupport` — queue position, ETA and progress, see below; + `BlockWorkflowOutput`, `BlockWorkflowAvailableOutput`, `BlockWorkflowRestrictedOutput`, `KnownBlockWorkflowOutputRating` and `KnownBlockWorkflowRestrictionReason` — restricted outputs, see below), `WorkflowStatus`, `BlockInitPayload`, `ParentToBlockMessage`, `BlockToParentMessage`. |
187
+
188
+ **Restricted outputs.** `outputs` on a workflow snapshot (and on each of its
189
+ `steps`, and on an `AppWorkflow` row) lists every available output in order, with
190
+ **restricted** outputs kept in position. An entry is either `{ url, nsfwLevel? }`
191
+ (load it; `nsfwLevel` is `'pg' | 'pg13' | 'r' | 'x' | 'xxx'`, absent while
192
+ unrated) or `{ restricted: true, reason }`. A restricted entry has **no url**:
193
+ show a locked state and do not try to fetch it. `reason: 'pool'` means the Buzz
194
+ that paid does not include mature content for this viewer and the output is above
195
+ PG-13. `'ceiling'` means it is above the viewer's own browsing level, capped by
196
+ your app's maturity ceiling, or above a cap the host put on the request. A
197
+ restricted output is not in `imageUrls` (nor `AppWorkflow.images`), so those
198
+ lists can be shorter than `outputs` and are
199
+ **not for indexing**: `imageIndexes` (publish, post) and `imageIndex` (persist)
200
+ are **positions in `outputs`**, which never move when a rating lands late, and
201
+ naming a restricted position is refused with `output N is restricted`. Two more
202
+ entry shapes carry no url and keep their slot: `{ pending: true }` (not rated yet;
203
+ the snapshot then carries `ratingPending: true`, so read it again) and
204
+ `{ blocked: true }` (blocked by moderation). With `@civitai/blocks-react`, a
205
+ malformed entry reaches you as `{ restricted: true, reason: 'ceiling' }` in its own
206
+ slot (`@civitai/sdk` does not validate replies). ⚠️ **Migration:** an app that built
207
+ `imageIndexes` from `images` positions (`images.map((_, i) => i)`) now names a
208
+ different output whenever an earlier one is restricted, pending or blocked — build
209
+ them from `outputs` positions, or omit `imageIndexes`. An older host sends no
210
+ `outputs`:
211
+
212
+ ```ts
213
+ import type { BlockWorkflowOutput, BlockWorkflowSnapshot } from '@civitai/app-sdk/blocks';
214
+
215
+ function tiles(snapshot: BlockWorkflowSnapshot): Array<{ src: string } | { locked: string }> {
216
+ const outputs: BlockWorkflowOutput[] =
217
+ snapshot.outputs ?? (snapshot.imageUrls ?? []).map((url) => ({ url }));
218
+ return outputs.map((out) => {
219
+ if (out.restricted === true) return { locked: out.reason };
220
+ if (out.pending === true) return { locked: 'still processing' };
221
+ if (out.blocked === true) return { locked: 'not available' };
222
+ return { src: out.url };
223
+ });
224
+ }
225
+ ```
226
+
227
+ **Queue position, ETA and progress.** A non-terminal workflow snapshot from a
228
+ poll can carry `eta`, a summary of the step that is queued or running now, for
229
+ every kind of workflow. Each entry of `steps` can carry `queue` (only while that
230
+ step is queued), `progress`, `startedAt` and `completedAt`. All of them are
231
+ optional, and **absent means the same as `null`**: the host omits a field with
232
+ nothing to report. A terminal snapshot has no `eta`, nor does a host that
233
+ predates the field. A poll the host could not serve (rate-limited) answers
234
+ `{ workflowId, status: 'processing', throttled: true }`: not a real update, and
235
+ `@civitai/blocks-react`'s `watch` skips it. A throttled answer to a cancel means
236
+ the cancel was not issued: `useBuzzWorkflow().cancel()` rejects with
237
+ `WorkflowCancelNotIssuedError`; retry it. `progress` is a fraction from 0 to 1, reported only for image and
238
+ video generation steps. `queuedAhead` / `precedingJobs` count the jobs ahead in
239
+ the queue; while a step is queued they refresh at most once per held poll
240
+ (about every 15 s), since a held poll does not wake on queue drift. Every time
241
+ is an ISO-8601 string and an estimate. `support` is `'available' |
242
+ 'unavailable' | 'unsupported'` or a value added later (`'unavailable'` means no
243
+ capacity right now):
244
+
245
+ ```ts
246
+ import type { BlockWorkflowSnapshot } from '@civitai/app-sdk/blocks';
247
+
248
+ function etaLine(snapshot: BlockWorkflowSnapshot): string | null {
249
+ const eta = snapshot.eta;
250
+ if (!eta) return null; // terminal, or nothing queued or running
251
+ if (eta.progress !== null) return eta.progress.toLocaleString(undefined, { style: 'percent' });
252
+ const at = eta.startsAt
253
+ ? new Date(eta.startsAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
254
+ : null;
255
+ return `${eta.queuedAhead ?? '?'} ahead${at ? `, starts ~${at}` : ''}`;
256
+ }
257
+ ```
157
258
 
158
259
  `WorkflowBody`'s `customComfy` member is a discriminated union on `mode`, mirroring
159
260
  the host's `blockCustomComfyMemberSchema`. Narrow on the VALUE (`body.mode === 'inline'`),
@@ -228,6 +329,18 @@ const body: WorkflowBody = {
228
329
  };
229
330
  ```
230
331
 
332
+ **Choosing the Buzz pool.** Both step arms, and a `kind: 'workflow'` body (once for the whole
333
+ workflow, never per step), take an optional `accountType` (`'blue' | 'green' | 'yellow'`), as a
334
+ `textToImage` body does. The host tries that pool first and keeps the app's other allowed pools
335
+ as fallback — an SFW app may spend `blue` and `green`, a mature app `blue` and `yellow`. A pool
336
+ outside that set is refused on the estimate and the submit alike; omit the field for the
337
+ default order, blue first. A pick does **not** guarantee an unrestricted output: when the picked
338
+ pool runs out the fallback pays, and a fallback to `blue` can still leave a mature output
339
+ restricted. On a confirmed step, `accountType` is part of the quoted body — submit with the pool
340
+ you estimated with. **Release order: host first** — civitai/civitai must accept the field
341
+ (civitai/civitai#8985) before an app sends it, because a host that predates it refuses the whole
342
+ body as an unknown key. Leaving it out works on every host.
343
+
231
344
  **Above the per-call budget: a confirmed step.** A pass-through job the per-call budget refuses
232
345
  can still run when the **viewer confirms its exact price** in Civitai's own dialog
233
346
  (civitai/civitai#5786). When the orchestrator quotes a **fixed** price (positive, not variable
@@ -469,8 +582,8 @@ round-trip probe shows they're unusable. Rules:
469
582
  not propagated.
470
583
  - The fallback is **session-scoped** — nothing survives a reload. That's the
471
584
  honest semantic at an opaque origin. Treat storage as a cache; use the
472
- platform's app-storage messages (`useAppStorage` in `@civitai/blocks-react`)
473
- for anything durable.
585
+ document store (`app.storage.collection(name)` in `@civitai/sdk`) for anything
586
+ durable.
474
587
 
475
588
  Most apps need to do nothing. Two cases where you reach for it explicitly:
476
589
 
@@ -2,7 +2,7 @@
2
2
  * The IDEMPOTENCY-KEY FORMAT the host enforces on every money POST — **the only
3
3
  * site in this repository that spells this rule**.
4
4
  *
5
- * Sibling of `./appStorageLimits.ts`, for the same reason: the rule lives in the
5
+ * The rule lives in the
6
6
  * host, the SDK cannot change it, and a hand-copied regex at each call site is
7
7
  * how the copies come to agree with each other and disagree with the host.
8
8
  *
@@ -2,7 +2,7 @@
2
2
  * The IDEMPOTENCY-KEY FORMAT the host enforces on every money POST — **the only
3
3
  * site in this repository that spells this rule**.
4
4
  *
5
- * Sibling of `./appStorageLimits.ts`, for the same reason: the rule lives in the
5
+ * The rule lives in the
6
6
  * host, the SDK cannot change it, and a hand-copied regex at each call site is
7
7
  * how the copies come to agree with each other and disagree with the host.
8
8
  *
@@ -27,7 +27,13 @@ export { BLOCK_SCOPES, BLOCK_SCOPE_PATTERN, BLOCK_CATEGORIES, BLOCK_TAGLINE_MAX_
27
27
  export type { BlockScope, BlockScopeKey, BlockCategory } from './scopes.js';
28
28
  export { BrowsingLevel, SFW_LEVELS, NSFW_LEVELS, isSfwCeiling, isLevelAllowed, effectiveBrowsingCeiling, } from './browsingLevel.js';
29
29
  export type { BrowsingLevelKey, BrowsingLevelBit, ColorDomain } from './browsingLevel.js';
30
- export { APP_STORAGE_MAX_VALUE_BYTES, APP_STORAGE_MAX_BYTES, APP_STORAGE_MAX_ROWS, } from './appStorageLimits.js';
30
+ /**
31
+ * @deprecated Seven leftovers of the removed legacy key-value store, kept only
32
+ * because published `@civitai/blocks-react` up to 0.80.x imports them at module
33
+ * load. See `legacyStoreCompat.ts`. Use `app.storage.collection(name)` in
34
+ * `@civitai/sdk`.
35
+ */
36
+ export { APP_STORAGE_MAX_VALUE_BYTES, APP_STORAGE_MAX_BYTES, APP_STORAGE_MAX_ROWS, APP_STORAGE_ERROR_VALUE_TOO_LARGE, APP_STORAGE_ERROR_USER_QUOTA_EXCEEDED, APP_STORAGE_ERROR_USER_ROW_LIMIT, APP_STORAGE_ERROR_REQUEST_FAILED, } from './legacyStoreCompat.js';
31
37
  /**
32
38
  * App reactions (`SET_ENTITY_REACTION` / `GET_ENTITY_REACTIONS`, scope
33
39
  * `social:react:self`). The vocabulary mirrors civitai's
@@ -43,7 +49,6 @@ export { BLOCK_IDEMPOTENCY_KEY_REGEX, BLOCK_IDEMPOTENCY_KEY_MAX_LENGTH, isValidB
43
49
  * the limits live in ONE place: the header of `nestedDocument.ts`.
44
50
  *
45
51
  * 🔴 `injectBaseHref` and `InjectBaseHrefResult` ARE DELIBERATELY NOT HERE, and
46
- * the omission is the same decision as the `appStorageErrors.ts` block below:
47
52
  * publish the branching surface, not every internal the module happens to
48
53
  * export. `fetchNestedDocument` covers every runnable example in this repo's
49
54
  * four prose surfaces (this package's README, `@civitai/blocks-react`'s README,
@@ -67,43 +72,10 @@ export { BLOCK_IDEMPOTENCY_KEY_REGEX, BLOCK_IDEMPOTENCY_KEY_MAX_LENGTH, isValidB
67
72
  */
68
73
  export { fetchNestedDocument, NestedDocumentError } from './nestedDocument.js';
69
74
  export type { FetchNestedDocumentOptions, NestedDocument, NestedDocumentErrorCode, } from './nestedDocument.js';
70
- /**
71
- * {@link classifyAppStorageError} — the matcher a block branches on — plus the
72
- * four rejection messages a MOCK HOST has to emit. The wire carries a
73
- * host-authored message, never the TRPC code; see `appStorageErrors.ts` for the
74
- * measurement, and #343 for the bug it closes.
75
- *
76
- * 🔴 **THE PUBLIC BRANCHING SURFACE IS THE REASON, NOT THE STRING.** A block
77
- * switches on {@link AppStorageRejectionReason}; it never needs to hold a host
78
- * message. So this barrel deliberately exports LESS than
79
- * `appStorageErrors.ts` does, and the omissions are each a decision:
80
- *
81
- * - `APP_STORAGE_HOST_ERROR_MESSAGES` — the frozen array. Publishing it invites
82
- * `MESSAGES.includes(err.message)`, which is EQUALITY against a snapshot and
83
- * stops matching the day the host moves its per-value cap. That is the
84
- * matcher shape #343 exists to eliminate; `classifyAppStorageError` is
85
- * strictly wider (see its note on the per-value FAMILY).
86
- * - `isAppStorageHostErrorMessage` — a thin `classifyAppStorageError(…) !==
87
- * null`. Its only caller is `tests/guards/app-storage-error-strings.test.mjs`,
88
- * which imports the module by FILE PATH.
89
- * - `APP_STORAGE_ERROR_APP_QUOTA_EXCEEDED` / `_APP_ROW_LIMIT` — the app-wide
90
- * umbrella pair. No mock in this repository can emit them (nothing models the
91
- * umbrella), and a block reaches them through the `'app-quota-exceeded'` /
92
- * `'app-row-limit'` reasons, which ARE exported.
93
- * - `appStorageValueTooLargeMessage` — the builder, so a test can prove the
94
- * per-value string is DERIVED from `APP_STORAGE_MAX_VALUE_BYTES` rather than
95
- * hardcoded.
96
- *
97
- * All five stay exported from `appStorageErrors.ts` itself, so a test or a
98
- * guard reaches them by path. Adding one here later is a `minor`; removing one
99
- * once published is not.
100
- */
101
- export { APP_STORAGE_ERROR_VALUE_TOO_LARGE, APP_STORAGE_ERROR_USER_QUOTA_EXCEEDED, APP_STORAGE_ERROR_USER_ROW_LIMIT, APP_STORAGE_ERROR_REQUEST_FAILED, classifyAppStorageError, } from './appStorageErrors.js';
102
- export type { AppStorageRejectionReason } from './appStorageErrors.js';
103
75
  export { BLOCK_INIT_FRAGMENT_MARKER_KEY, BLOCK_INIT_FRAGMENT_VERSION, BLOCK_INIT_FRAGMENT_KEYS, encodeBlockInitFragment, parseBlockInitFragment, stripBlockInitFragment, } from './initFragment.js';
104
76
  export type { BlockInitFragment } from './initFragment.js';
105
77
  export { isMessage, BLOCK_TO_PARENT_MESSAGE_TYPES, OTHER_MESSAGE_TYPE_LABEL, boundBlockToParentMessageType, } from './messages.js';
106
- export type { BlockInitPayload, BlockToParentMessage, BlockToParentMessageType, ConsentUnavailablePayload, ConsentUnavailableReason, ParentToBlockMessage, ParentToBlockMessageType, SharedStorageItemWire, SharedStorageRateLimit, SharedStorageValue, WrappedToken, BlockBuzzTransactionsParams, BlockDailyCompensationParams, AppWorkflowsParams, } from './messages.js';
78
+ export type { BlockInitPayload, BlockToParentMessage, BlockToParentMessageType, ConsentUnavailablePayload, ConsentUnavailableReason, ParentToBlockMessage, ParentToBlockMessageType, WrappedToken, BlockBuzzTransactionsParams, BlockDailyCompensationParams, AppWorkflowsParams, } from './messages.js';
107
79
  /**
108
80
  * Runtime narrowing for the `slotId`-discriminated {@link BlockContext} union.
109
81
  * Values, not types — a slot context crosses a `postMessage` boundary, so its
@@ -116,7 +88,7 @@ export { isModelSlotContext, isPageSlotContext } from './types.js';
116
88
  * in `types.ts` for which of the two it uses and why.
117
89
  */
118
90
  export { isSignedIn } from './types.js';
119
- export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockSettings, BlockStorageCollectionDeclaration, BlockStorageCollectionHook, BlockStorageCollectionSchema, BlockStorageDeclaration, BlockStorageImport, BlockStorageIndexes, BlockStorageIndexType, BlockStorageMigrationKeyword, BlockStorageMigrationOp, BlockStoragePrivateCollectionDeclaration, BlockStorageSchemaType, BlockStorageSharedCollectionDeclaration, BlockToken, ContentRating, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPage, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockTextToImageParams, BlockWorkflowSnapshot, BlockEstimateBatchAggregate, BlockModelSubstitution, ModelSubstitutionReason, KnownBlockWorkflowErrorCode, BlockStepToolCall, BlockTrainedEpoch, BlockPublishedModel, BuzzAccountType, ShowcaseImage, WorkflowBody, WorkflowBodyTextToImage, WorkflowBodyCustomComfy, WorkflowBodyCustomComfyRecipe, WorkflowBodyCustomComfyInline, InlineComfyNode, WorkflowBodyStep, WorkflowBodyPassThroughStep, WorkflowBodyWorkflow, WorkflowBodyWorkflowStep, WorkflowStepRef, WithWorkflowStepRefs, BlockWorkflowStepSnapshot, WorkflowStatus, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, BlockResourceFile, BlockResourceFileEntry, BlockResourceFileEntryFormat, BlockResourceFileErrorCode, BlockResourceFileMeta, AppWorkflow, AppWorkflowImage, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostRequest, BlockCreatePostResult, BlockCreatePostHostError, WorkflowBodyTraining, AiToolkitTrainingParams, AiToolkitTrainingParamsBase, AiToolkitPlainEcosystem, AiToolkitLrScheduler, AiToolkitOptimizerType, BlockTrainingQuote, BlockTrainingDatasetItem, BlockTrainingDataImage, BlockTrainingDataUploadResult, BlockRunTrainingHostError, BlockStepQuote, BlockModel3dOutput, BlockRunConfirmedStepHostError, } from './types.js';
91
+ export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockSettings, BlockStorageCollectionDeclaration, BlockStorageCollectionHook, BlockStorageCollectionSchema, BlockStorageDeclaration, BlockStorageImport, BlockStorageIndexes, BlockStorageIndexType, BlockStorageMigrationKeyword, BlockStorageMigrationOp, BlockStoragePrivateCollectionDeclaration, BlockStorageSchemaType, BlockStorageSharedCollectionDeclaration, BlockToken, ContentRating, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPage, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockPersistGenerationSourceRequest, BlockPersistedGenerationSource, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockMediaUploadBatchItemResult, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockTextToImageParams, BlockWorkflowSnapshot, BlockEstimateBatchAggregate, BlockModelSubstitution, ModelSubstitutionReason, KnownBlockWorkflowErrorCode, BlockStepToolCall, BlockTrainedEpoch, BlockPublishedModel, BuzzAccountType, ShowcaseImage, WorkflowBody, WorkflowBodyTextToImage, WorkflowBodyCustomComfy, WorkflowBodyCustomComfyRecipe, WorkflowBodyCustomComfyInline, InlineComfyNode, WorkflowBodyStep, WorkflowBodyPassThroughStep, WorkflowBodyWorkflow, WorkflowBodyWorkflowStep, WorkflowStepRef, WithWorkflowStepRefs, BlockWorkflowStepSnapshot, BlockWorkflowStepQueue, BlockWorkflowEta, KnownBlockWorkflowQueueSupport, BlockWorkflowOutput, BlockWorkflowAvailableOutput, BlockWorkflowRestrictedOutput, BlockWorkflowPendingOutput, BlockWorkflowBlockedOutput, KnownBlockWorkflowOutputRating, KnownBlockWorkflowRestrictionReason, WorkflowStatus, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, BlockResourceFile, BlockResourceFileEntry, BlockResourceFileEntryFormat, BlockResourceFileErrorCode, BlockResourceFileMeta, AppWorkflow, AppWorkflowImage, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostRequest, BlockCreatePostResult, BlockCreatePostHostError, WorkflowBodyTraining, AiToolkitTrainingParams, AiToolkitTrainingParamsBase, AiToolkitPlainEcosystem, AiToolkitLrScheduler, AiToolkitOptimizerType, BlockTrainingQuote, BlockTrainingDatasetItem, BlockTrainingDataImage, BlockTrainingDataUploadResult, BlockRunTrainingHostError, BlockStepQuote, BlockModel3dOutput, BlockRunConfirmedStepHostError, } from './types.js';
120
92
  /**
121
93
  * Host bounds for an inline `customComfy` graph, mirrored from civitai/civitai —
122
94
  * see `WorkflowBodyCustomComfyInline.workflow`.
@@ -30,7 +30,13 @@ export { installSafeStorage, createMemoryStorage } from '../safe-storage/index.j
30
30
  export { BlockManifestError } from './manifestError.js';
31
31
  export { BLOCK_SCOPES, BLOCK_SCOPE_PATTERN, BLOCK_CATEGORIES, BLOCK_TAGLINE_MAX_LENGTH, } from './scopes.js';
32
32
  export { BrowsingLevel, SFW_LEVELS, NSFW_LEVELS, isSfwCeiling, isLevelAllowed, effectiveBrowsingCeiling, } from './browsingLevel.js';
33
- export { APP_STORAGE_MAX_VALUE_BYTES, APP_STORAGE_MAX_BYTES, APP_STORAGE_MAX_ROWS, } from './appStorageLimits.js';
33
+ /**
34
+ * @deprecated Seven leftovers of the removed legacy key-value store, kept only
35
+ * because published `@civitai/blocks-react` up to 0.80.x imports them at module
36
+ * load. See `legacyStoreCompat.ts`. Use `app.storage.collection(name)` in
37
+ * `@civitai/sdk`.
38
+ */
39
+ export { APP_STORAGE_MAX_VALUE_BYTES, APP_STORAGE_MAX_BYTES, APP_STORAGE_MAX_ROWS, APP_STORAGE_ERROR_VALUE_TOO_LARGE, APP_STORAGE_ERROR_USER_QUOTA_EXCEEDED, APP_STORAGE_ERROR_USER_ROW_LIMIT, APP_STORAGE_ERROR_REQUEST_FAILED, } from './legacyStoreCompat.js';
34
40
  /**
35
41
  * App reactions (`SET_ENTITY_REACTION` / `GET_ENTITY_REACTIONS`, scope
36
42
  * `social:react:self`). The vocabulary mirrors civitai's
@@ -45,7 +51,6 @@ export { BLOCK_IDEMPOTENCY_KEY_REGEX, BLOCK_IDEMPOTENCY_KEY_MAX_LENGTH, isValidB
45
51
  * the limits live in ONE place: the header of `nestedDocument.ts`.
46
52
  *
47
53
  * 🔴 `injectBaseHref` and `InjectBaseHrefResult` ARE DELIBERATELY NOT HERE, and
48
- * the omission is the same decision as the `appStorageErrors.ts` block below:
49
54
  * publish the branching surface, not every internal the module happens to
50
55
  * export. `fetchNestedDocument` covers every runnable example in this repo's
51
56
  * four prose surfaces (this package's README, `@civitai/blocks-react`'s README,
@@ -68,38 +73,6 @@ export { BLOCK_IDEMPOTENCY_KEY_REGEX, BLOCK_IDEMPOTENCY_KEY_MAX_LENGTH, isValidB
68
73
  * published is not.
69
74
  */
70
75
  export { fetchNestedDocument, NestedDocumentError } from './nestedDocument.js';
71
- /**
72
- * {@link classifyAppStorageError} — the matcher a block branches on — plus the
73
- * four rejection messages a MOCK HOST has to emit. The wire carries a
74
- * host-authored message, never the TRPC code; see `appStorageErrors.ts` for the
75
- * measurement, and #343 for the bug it closes.
76
- *
77
- * 🔴 **THE PUBLIC BRANCHING SURFACE IS THE REASON, NOT THE STRING.** A block
78
- * switches on {@link AppStorageRejectionReason}; it never needs to hold a host
79
- * message. So this barrel deliberately exports LESS than
80
- * `appStorageErrors.ts` does, and the omissions are each a decision:
81
- *
82
- * - `APP_STORAGE_HOST_ERROR_MESSAGES` — the frozen array. Publishing it invites
83
- * `MESSAGES.includes(err.message)`, which is EQUALITY against a snapshot and
84
- * stops matching the day the host moves its per-value cap. That is the
85
- * matcher shape #343 exists to eliminate; `classifyAppStorageError` is
86
- * strictly wider (see its note on the per-value FAMILY).
87
- * - `isAppStorageHostErrorMessage` — a thin `classifyAppStorageError(…) !==
88
- * null`. Its only caller is `tests/guards/app-storage-error-strings.test.mjs`,
89
- * which imports the module by FILE PATH.
90
- * - `APP_STORAGE_ERROR_APP_QUOTA_EXCEEDED` / `_APP_ROW_LIMIT` — the app-wide
91
- * umbrella pair. No mock in this repository can emit them (nothing models the
92
- * umbrella), and a block reaches them through the `'app-quota-exceeded'` /
93
- * `'app-row-limit'` reasons, which ARE exported.
94
- * - `appStorageValueTooLargeMessage` — the builder, so a test can prove the
95
- * per-value string is DERIVED from `APP_STORAGE_MAX_VALUE_BYTES` rather than
96
- * hardcoded.
97
- *
98
- * All five stay exported from `appStorageErrors.ts` itself, so a test or a
99
- * guard reaches them by path. Adding one here later is a `minor`; removing one
100
- * once published is not.
101
- */
102
- export { APP_STORAGE_ERROR_VALUE_TOO_LARGE, APP_STORAGE_ERROR_USER_QUOTA_EXCEEDED, APP_STORAGE_ERROR_USER_ROW_LIMIT, APP_STORAGE_ERROR_REQUEST_FAILED, classifyAppStorageError, } from './appStorageErrors.js';
103
76
  export { BLOCK_INIT_FRAGMENT_MARKER_KEY, BLOCK_INIT_FRAGMENT_VERSION, BLOCK_INIT_FRAGMENT_KEYS, encodeBlockInitFragment, parseBlockInitFragment, stripBlockInitFragment, } from './initFragment.js';
104
77
  export { isMessage, BLOCK_TO_PARENT_MESSAGE_TYPES, OTHER_MESSAGE_TYPE_LABEL, boundBlockToParentMessageType, } from './messages.js';
105
78
  /**
@@ -0,0 +1,42 @@
1
+ /**
2
+ * The last seven exports of the removed legacy key-value store.
3
+ *
4
+ * civitai.com refuses every legacy-store call since 2026-11-10 (HTTP 410,
5
+ * `legacy_store_removed`), and `@civitai/blocks-react` removed `useAppStorage()`
6
+ * and `useSharedStorage()` in the release after 0.80.x. Use the document store
7
+ * instead: `app.storage.collection(name)` in `@civitai/sdk`.
8
+ *
9
+ * 🔴 **Why these seven are still exported, when nothing in this repository
10
+ * reads them.** Published `@civitai/blocks-react` releases value-import these
11
+ * names from `@civitai/app-sdk/blocks` at module load, in
12
+ * `dist/internal/mockHost.js` (all seven in the `0.80.1` tarball, measured
13
+ * 2026-11-14; `PEER_FLOOR.md` records them arriving in 0.47.0 and 0.49.0).
14
+ * `0.80.1` declares the peer range `>=0.57.0 <1.0.0`, so it accepts this
15
+ * release. Deleting a name would make `@civitai/blocks-react/testing`
16
+ * fail to load with `SyntaxError: ... does not provide an export named ...` for
17
+ * anyone who upgrades app-sdk before blocks-react. That stops every one of their
18
+ * test files from loading (the #344 failure).
19
+ *
20
+ * **When to remove them:** in app-sdk `1.0.0`. Every published blocks-react
21
+ * that imports them (0.54.0 onward) caps its app-sdk peer range below `1.0.0`
22
+ * (read from the registry, 2026-11-14), so none of them can be installed next
23
+ * to it.
24
+ *
25
+ * The values are the ones the host used; they describe a store that no longer
26
+ * exists. Do not build anything on them.
27
+ */
28
+ /** @deprecated The legacy store was removed. Use `app.storage.collection(name)` in `@civitai/sdk`. */
29
+ export declare const APP_STORAGE_MAX_VALUE_BYTES: number;
30
+ /** @deprecated The legacy store was removed. Use `app.storage.collection(name)` in `@civitai/sdk`. */
31
+ export declare const APP_STORAGE_MAX_BYTES: number;
32
+ /** @deprecated The legacy store was removed. Use `app.storage.collection(name)` in `@civitai/sdk`. */
33
+ export declare const APP_STORAGE_MAX_ROWS = 1000;
34
+ /** @deprecated The legacy store was removed. Use `app.storage.collection(name)` in `@civitai/sdk`. */
35
+ export declare const APP_STORAGE_ERROR_VALUE_TOO_LARGE = "value exceeds 64KB cap";
36
+ /** @deprecated The legacy store was removed. Use `app.storage.collection(name)` in `@civitai/sdk`. */
37
+ export declare const APP_STORAGE_ERROR_USER_QUOTA_EXCEEDED = "per-user storage quota exceeded";
38
+ /** @deprecated The legacy store was removed. Use `app.storage.collection(name)` in `@civitai/sdk`. */
39
+ export declare const APP_STORAGE_ERROR_USER_ROW_LIMIT = "per-user row limit exceeded";
40
+ /** @deprecated The legacy store was removed. Use `app.storage.collection(name)` in `@civitai/sdk`. */
41
+ export declare const APP_STORAGE_ERROR_REQUEST_FAILED = "storage request failed";
42
+ //# sourceMappingURL=legacyStoreCompat.d.ts.map
@@ -0,0 +1,42 @@
1
+ /**
2
+ * The last seven exports of the removed legacy key-value store.
3
+ *
4
+ * civitai.com refuses every legacy-store call since 2026-11-10 (HTTP 410,
5
+ * `legacy_store_removed`), and `@civitai/blocks-react` removed `useAppStorage()`
6
+ * and `useSharedStorage()` in the release after 0.80.x. Use the document store
7
+ * instead: `app.storage.collection(name)` in `@civitai/sdk`.
8
+ *
9
+ * 🔴 **Why these seven are still exported, when nothing in this repository
10
+ * reads them.** Published `@civitai/blocks-react` releases value-import these
11
+ * names from `@civitai/app-sdk/blocks` at module load, in
12
+ * `dist/internal/mockHost.js` (all seven in the `0.80.1` tarball, measured
13
+ * 2026-11-14; `PEER_FLOOR.md` records them arriving in 0.47.0 and 0.49.0).
14
+ * `0.80.1` declares the peer range `>=0.57.0 <1.0.0`, so it accepts this
15
+ * release. Deleting a name would make `@civitai/blocks-react/testing`
16
+ * fail to load with `SyntaxError: ... does not provide an export named ...` for
17
+ * anyone who upgrades app-sdk before blocks-react. That stops every one of their
18
+ * test files from loading (the #344 failure).
19
+ *
20
+ * **When to remove them:** in app-sdk `1.0.0`. Every published blocks-react
21
+ * that imports them (0.54.0 onward) caps its app-sdk peer range below `1.0.0`
22
+ * (read from the registry, 2026-11-14), so none of them can be installed next
23
+ * to it.
24
+ *
25
+ * The values are the ones the host used; they describe a store that no longer
26
+ * exists. Do not build anything on them.
27
+ */
28
+ /** @deprecated The legacy store was removed. Use `app.storage.collection(name)` in `@civitai/sdk`. */
29
+ export const APP_STORAGE_MAX_VALUE_BYTES = 64 * 1024;
30
+ /** @deprecated The legacy store was removed. Use `app.storage.collection(name)` in `@civitai/sdk`. */
31
+ export const APP_STORAGE_MAX_BYTES = 2 * 1024 * 1024;
32
+ /** @deprecated The legacy store was removed. Use `app.storage.collection(name)` in `@civitai/sdk`. */
33
+ export const APP_STORAGE_MAX_ROWS = 1_000;
34
+ /** @deprecated The legacy store was removed. Use `app.storage.collection(name)` in `@civitai/sdk`. */
35
+ export const APP_STORAGE_ERROR_VALUE_TOO_LARGE = `value exceeds ${APP_STORAGE_MAX_VALUE_BYTES / 1024}KB cap`;
36
+ /** @deprecated The legacy store was removed. Use `app.storage.collection(name)` in `@civitai/sdk`. */
37
+ export const APP_STORAGE_ERROR_USER_QUOTA_EXCEEDED = 'per-user storage quota exceeded';
38
+ /** @deprecated The legacy store was removed. Use `app.storage.collection(name)` in `@civitai/sdk`. */
39
+ export const APP_STORAGE_ERROR_USER_ROW_LIMIT = 'per-user row limit exceeded';
40
+ /** @deprecated The legacy store was removed. Use `app.storage.collection(name)` in `@civitai/sdk`. */
41
+ export const APP_STORAGE_ERROR_REQUEST_FAILED = 'storage request failed';
42
+ //# sourceMappingURL=legacyStoreCompat.js.map