@civitai/app-sdk 0.88.0 → 0.90.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 +43 -4
- package/dist/blocks/index.d.ts +1 -1
- package/dist/blocks/messages.d.ts +35 -3
- package/dist/blocks/messages.js +2 -0
- package/dist/blocks/types.d.ts +305 -14
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/schemas/app-block/v1.json +1 -1
package/README.md
CHANGED
|
@@ -114,8 +114,8 @@ queue it produced. Mirrors civitai/civitai PR #3164; the `@civitai/blocks-react`
|
|
|
114
114
|
|
|
115
115
|
`PERSIST_GENERATION_SOURCE` → `GENERATION_SOURCE_PERSISTED` saves ONE of those
|
|
116
116
|
outputs as a **private, scanned generation source** for the next generation.
|
|
117
|
-
The request is `{ requestId, workflowId, imageIndex }` (
|
|
118
|
-
workflow's `images`; never a url) and the reply carries `result`, a
|
|
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
119
|
`BlockPersistedGenerationSource` (`{ url, width, height, imageId, ready }`), or a
|
|
120
120
|
free-text `error`. The image is private to the viewer and not on the app's
|
|
121
121
|
shared grid, and there is no confirm dialog. The host waits up to about thirty
|
|
@@ -183,7 +183,46 @@ interface BlockInitPayload {
|
|
|
183
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`. |
|
|
184
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'`. |
|
|
185
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. |
|
|
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), `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), `BlockOutputUnlockResult` / `KnownBlockOutputUnlockOutcome` (unlocking a restricted output; `useOutputUnlock` in `@civitai/blocks-react`), `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
|
+
```
|
|
187
226
|
|
|
188
227
|
**Queue position, ETA and progress.** A non-terminal workflow snapshot from a
|
|
189
228
|
poll can carry `eta`, a summary of the step that is queued or running now, for
|
|
@@ -353,7 +392,7 @@ confirms that price in Civitai's own dialog. A confirmed run may exceed the toke
|
|
|
353
392
|
budget, up to `BLOCK_TRAINING_MAX_BUZZ_PER_RUN` (5,000). Page apps only, `ai:write:budgeted`,
|
|
354
393
|
behind the host flag `app-blocks-training-kind` (off by default), and refused from development
|
|
355
394
|
and review sessions. The images are uploaded over `OPEN_IMAGE_UPLOAD { purpose: 'trainingData' }`,
|
|
356
|
-
which replies `IMAGE_UPLOAD_RESULT { selected: { images: [{
|
|
395
|
+
which replies `IMAGE_UPLOAD_RESULT { selected: { images: [{ air }] } }`, an AIR reference per image
|
|
357
396
|
(`BlockTrainingDataUploadResult`); the host refuses a run whose quote names a blob it did not
|
|
358
397
|
upload for the block, with the `BlockRunTrainingHostError` `training data not uploaded here`.
|
|
359
398
|
`PREPARE_TRAINING_DATASET` (the server-prepared dataset of civitai/civitai#5438) is removed from
|
package/dist/blocks/index.d.ts
CHANGED
|
@@ -88,7 +88,7 @@ export { isModelSlotContext, isPageSlotContext } from './types.js';
|
|
|
88
88
|
* in `types.ts` for which of the two it uses and why.
|
|
89
89
|
*/
|
|
90
90
|
export { isSignedIn } 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, 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, BlockUploadedGenerationSource, BlockPersistGenerationSourceRequest, BlockPersistedGenerationSource, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockMediaUploadBatchItemResult, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockShareLinkMethod, BlockShareLinkRequest, BlockShareLinkResult, 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, KnownBlockOutputUnlockOutcome, BlockOutputUnlockResult, 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';
|
|
92
92
|
/**
|
|
93
93
|
* Host bounds for an inline `customComfy` graph, mirrored from civitai/civitai —
|
|
94
94
|
* see `WorkflowBodyCustomComfyInline.workflow`.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Wire format: `window.postMessage({ type, payload }, targetOrigin)`.
|
|
9
9
|
*/
|
|
10
10
|
import type { ColorDomain } from './browsingLevel.js';
|
|
11
|
-
import type { BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockUploadedImageInfo,
|
|
11
|
+
import type { BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockUploadedImageInfo, BlockUploadedGenerationSource, BlockPersistedGenerationSource, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockMediaUploadBatchItemResult, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockShareLinkResult, BlockContext, BlockSettings, Theme, ViewerInfo, WorkflowBody, BlockWorkflowSnapshot, BlockEstimateBatchAggregate, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, BlockResourceFile, BlockResourceFileErrorCode, AppWorkflow, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostResult, BlockTrainingDataUploadResult, WorkflowBodyTraining, WorkflowBodyPassThroughStep, BlockOutputUnlockResult } from './types.js';
|
|
12
12
|
import type { BlockAppReaction, BlockEntityReactionErrorCode, BlockEntityReactionResult, BlockEntityReactionsResult, BlockReactionEntityType } from './reactions.js';
|
|
13
13
|
/**
|
|
14
14
|
* Filter params for `GET_BUZZ_TRANSACTIONS`. All optional; the host validates
|
|
@@ -319,6 +319,8 @@ export type ParentToBlockMessage = {
|
|
|
319
319
|
type: 'ROUTE_CHANGED';
|
|
320
320
|
payload: {
|
|
321
321
|
subPath: string;
|
|
322
|
+
search?: string;
|
|
323
|
+
hash?: string;
|
|
322
324
|
};
|
|
323
325
|
} | {
|
|
324
326
|
type: 'CONSENT_UNAVAILABLE';
|
|
@@ -362,6 +364,13 @@ export type ParentToBlockMessage = {
|
|
|
362
364
|
purchased: boolean;
|
|
363
365
|
newBalance?: number;
|
|
364
366
|
};
|
|
367
|
+
} | {
|
|
368
|
+
type: 'OUTPUT_UNLOCK_RESULT';
|
|
369
|
+
payload: {
|
|
370
|
+
requestId: string;
|
|
371
|
+
result?: BlockOutputUnlockResult;
|
|
372
|
+
error?: string;
|
|
373
|
+
};
|
|
365
374
|
} | {
|
|
366
375
|
type: 'BUZZ_BALANCE_RESULT';
|
|
367
376
|
payload: {
|
|
@@ -449,6 +458,13 @@ export type ParentToBlockMessage = {
|
|
|
449
458
|
result?: BlockPersistedGenerationSource;
|
|
450
459
|
error?: string;
|
|
451
460
|
};
|
|
461
|
+
} | {
|
|
462
|
+
type: 'SHARE_LINK_RESULT';
|
|
463
|
+
payload: {
|
|
464
|
+
requestId: string;
|
|
465
|
+
result?: BlockShareLinkResult;
|
|
466
|
+
error?: string;
|
|
467
|
+
};
|
|
452
468
|
} | {
|
|
453
469
|
type: 'CREATE_POST_RESULT';
|
|
454
470
|
payload: {
|
|
@@ -527,7 +543,7 @@ export type ParentToBlockMessage = {
|
|
|
527
543
|
type: 'IMAGE_UPLOAD_RESULT';
|
|
528
544
|
payload: {
|
|
529
545
|
requestId: string;
|
|
530
|
-
selected?: BlockUploadedImageInfo |
|
|
546
|
+
selected?: BlockUploadedImageInfo | BlockUploadedGenerationSource | BlockPendingImageInfo | BlockTrainingDataUploadResult;
|
|
531
547
|
/** A `bytes` upload's refusal or failure: a host string or a forwarded server message. */
|
|
532
548
|
error?: string;
|
|
533
549
|
};
|
|
@@ -653,6 +669,13 @@ export type BlockToParentMessage = {
|
|
|
653
669
|
requestId: string;
|
|
654
670
|
suggestedAmount?: number;
|
|
655
671
|
};
|
|
672
|
+
} | {
|
|
673
|
+
type: 'REQUEST_OUTPUT_UNLOCK';
|
|
674
|
+
payload: {
|
|
675
|
+
requestId: string;
|
|
676
|
+
workflowId: string;
|
|
677
|
+
position: number;
|
|
678
|
+
};
|
|
656
679
|
} | {
|
|
657
680
|
type: 'GET_BUZZ_BALANCE';
|
|
658
681
|
payload: {
|
|
@@ -714,6 +737,14 @@ export type BlockToParentMessage = {
|
|
|
714
737
|
workflowId: string;
|
|
715
738
|
imageIndex: number;
|
|
716
739
|
};
|
|
740
|
+
} | {
|
|
741
|
+
type: 'SHARE_LINK';
|
|
742
|
+
payload: {
|
|
743
|
+
requestId: string;
|
|
744
|
+
subPath: string;
|
|
745
|
+
search?: string;
|
|
746
|
+
hash?: string;
|
|
747
|
+
};
|
|
717
748
|
} | {
|
|
718
749
|
type: 'CREATE_POST_FROM_APP';
|
|
719
750
|
payload: {
|
|
@@ -869,6 +900,7 @@ export type BlockToParentMessage = {
|
|
|
869
900
|
path: string;
|
|
870
901
|
scope?: BlockNavigateScope;
|
|
871
902
|
target: 'current' | 'new_tab';
|
|
903
|
+
replace?: boolean;
|
|
872
904
|
};
|
|
873
905
|
} | {
|
|
874
906
|
type: 'REQUEST_SIGN_IN';
|
|
@@ -983,7 +1015,7 @@ export type BlockToParentMessageType = BlockToParentMessage['type'];
|
|
|
983
1015
|
* it is a measurement, not an invariant, and civitai's own compile-time gate
|
|
984
1016
|
* (published SDK union ⊆ `keyof INVENTORY`) is what holds one direction of it.
|
|
985
1017
|
*/
|
|
986
|
-
export declare const BLOCK_TO_PARENT_MESSAGE_TYPES: readonly ["BLOCK_HELLO", "BLOCK_READY", "BLOCK_ERROR", "BLOCK_MESSAGE_REJECTED", "REQUEST_TOKEN", "RESIZE_IFRAME", "SUBMIT_WORKFLOW", "ESTIMATE_WORKFLOW", "ESTIMATE_WORKFLOW_BATCH", "POLL_WORKFLOW", "CANCEL_WORKFLOW", "OPEN_BUZZ_PURCHASE", "GET_BUZZ_BALANCE", "GET_VIEWER", "GET_BUZZ_TRANSACTIONS", "GET_BUZZ_ACCOUNTS", "GET_DAILY_COMPENSATION", "GET_WILDCARD_PACK", "GET_RESOURCE_FILE", "QUERY_APP_WORKFLOWS", "PUBLISH_GENERATION_OUTPUTS", "PERSIST_GENERATION_SOURCE", "CREATE_POST_FROM_APP", "RUN_TRAINING", "RUN_CONFIRMED_STEP", "GET_IMAGES_BY_IDS", "CANCEL_APP_WORKFLOW", "OPEN_CHECKPOINT_PICKER", "OPEN_RESOURCE_PICKER", "OPEN_IMAGE_UPLOAD", "OPEN_IMAGE_PICKER", "OPEN_MEDIA_UPLOAD", "OPEN_MEDIA_UPLOAD_BATCH", "SET_USER_CHECKPOINT", "NAVIGATE", "REQUEST_SIGN_IN", "REQUEST_CONSENT", "TRACK_EVENT", "SAVE_IMAGE", "SET_COLLECTION_FOLLOW", "SET_ENTITY_REACTION", "GET_ENTITY_REACTIONS"];
|
|
1018
|
+
export declare const BLOCK_TO_PARENT_MESSAGE_TYPES: readonly ["BLOCK_HELLO", "BLOCK_READY", "BLOCK_ERROR", "BLOCK_MESSAGE_REJECTED", "REQUEST_TOKEN", "RESIZE_IFRAME", "SUBMIT_WORKFLOW", "ESTIMATE_WORKFLOW", "ESTIMATE_WORKFLOW_BATCH", "POLL_WORKFLOW", "CANCEL_WORKFLOW", "OPEN_BUZZ_PURCHASE", "REQUEST_OUTPUT_UNLOCK", "GET_BUZZ_BALANCE", "GET_VIEWER", "GET_BUZZ_TRANSACTIONS", "GET_BUZZ_ACCOUNTS", "GET_DAILY_COMPENSATION", "GET_WILDCARD_PACK", "GET_RESOURCE_FILE", "QUERY_APP_WORKFLOWS", "PUBLISH_GENERATION_OUTPUTS", "PERSIST_GENERATION_SOURCE", "SHARE_LINK", "CREATE_POST_FROM_APP", "RUN_TRAINING", "RUN_CONFIRMED_STEP", "GET_IMAGES_BY_IDS", "CANCEL_APP_WORKFLOW", "OPEN_CHECKPOINT_PICKER", "OPEN_RESOURCE_PICKER", "OPEN_IMAGE_UPLOAD", "OPEN_IMAGE_PICKER", "OPEN_MEDIA_UPLOAD", "OPEN_MEDIA_UPLOAD_BATCH", "SET_USER_CHECKPOINT", "NAVIGATE", "REQUEST_SIGN_IN", "REQUEST_CONSENT", "TRACK_EVENT", "SAVE_IMAGE", "SET_COLLECTION_FOLLOW", "SET_ENTITY_REACTION", "GET_ENTITY_REACTIONS"];
|
|
987
1019
|
/**
|
|
988
1020
|
* The bucket a message type falls into when the protocol does not declare it.
|
|
989
1021
|
*
|
package/dist/blocks/messages.js
CHANGED
|
@@ -61,6 +61,7 @@ export const BLOCK_TO_PARENT_MESSAGE_TYPES = [
|
|
|
61
61
|
'POLL_WORKFLOW',
|
|
62
62
|
'CANCEL_WORKFLOW',
|
|
63
63
|
'OPEN_BUZZ_PURCHASE',
|
|
64
|
+
'REQUEST_OUTPUT_UNLOCK',
|
|
64
65
|
'GET_BUZZ_BALANCE',
|
|
65
66
|
'GET_VIEWER',
|
|
66
67
|
'GET_BUZZ_TRANSACTIONS',
|
|
@@ -71,6 +72,7 @@ export const BLOCK_TO_PARENT_MESSAGE_TYPES = [
|
|
|
71
72
|
'QUERY_APP_WORKFLOWS',
|
|
72
73
|
'PUBLISH_GENERATION_OUTPUTS',
|
|
73
74
|
'PERSIST_GENERATION_SOURCE',
|
|
75
|
+
'SHARE_LINK',
|
|
74
76
|
'CREATE_POST_FROM_APP',
|
|
75
77
|
'RUN_TRAINING',
|
|
76
78
|
'RUN_CONFIRMED_STEP',
|
package/dist/blocks/types.d.ts
CHANGED
|
@@ -253,9 +253,10 @@ export type BlockImageScanResult = {
|
|
|
253
253
|
* routes through the session-authed scan pipeline (SFW + no-flag gate). The
|
|
254
254
|
* host returns a moderated {@link BlockUploadedImageInfo}.
|
|
255
255
|
* - `'generationSource'`: a PRIVATE generation INPUT (an img2img source image).
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
256
|
+
* The host returns the source shape ({@link BlockUploadedGenerationSource});
|
|
257
|
+
* no `nsfwLevel`/`contentRating` crosses back into the block. While the
|
|
258
|
+
* host's scanned-rows rule is on, the source is a private SCANNED row and
|
|
259
|
+
* the reply also carries its `imageId` and `ready`.
|
|
259
260
|
* - `'trainingData'`: PRIVATE training images for a `kind: 'training'` run
|
|
260
261
|
* (civitai/civitai#6461). The viewer picks up to
|
|
261
262
|
* {@link BLOCK_TRAINING_DATASET_MAX_ITEMS} PNG, JPEG or WebP files in a host
|
|
@@ -289,6 +290,37 @@ export type BlockUploadPurpose = 'display' | 'generationSource' | 'trainingData'
|
|
|
289
290
|
* are one request. Do not reintroduce punctuation semantics.
|
|
290
291
|
*/
|
|
291
292
|
export type BlockNavigateScope = 'app' | 'site';
|
|
293
|
+
/**
|
|
294
|
+
* How the host delivered a `SHARE_LINK` URL to the viewer:
|
|
295
|
+
* - `'clipboard'` — the host's clipboard write RESOLVED (`copied` is `true`);
|
|
296
|
+
* - `'share'` — the native share sheet completed (phones; `copied` is `false`);
|
|
297
|
+
* - `'none'` — nothing was delivered: the clipboard write was refused, there was no
|
|
298
|
+
* click to act on, the share sheet was cancelled, or no API was available. Show
|
|
299
|
+
* `url` as selectable text so the viewer can copy it by hand.
|
|
300
|
+
*/
|
|
301
|
+
export type BlockShareLinkMethod = 'clipboard' | 'share' | 'none';
|
|
302
|
+
/**
|
|
303
|
+
* The view a `SHARE_LINK` links to. Every field is RELATIVE to the app: the host
|
|
304
|
+
* builds the absolute `/apps/run/<slug>/<subPath><search><hash>` URL from its own
|
|
305
|
+
* origin and slug, and refuses anything that would leave it (`..`, `//host`, a
|
|
306
|
+
* scheme), and drops the host-owned `from` / `sl` / `src` pairs. `subPath` carries no `?` or `#`; `search` is `''` or starts with `?`;
|
|
307
|
+
* `hash` is `''` or starts with `#`; each at most 2048 chars.
|
|
308
|
+
*/
|
|
309
|
+
export interface BlockShareLinkRequest {
|
|
310
|
+
subPath?: string;
|
|
311
|
+
search?: string;
|
|
312
|
+
hash?: string;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* What the host did with a `SHARE_LINK`. 🔴 `copied` is `true` ONLY when the
|
|
316
|
+
* clipboard write resolved; `false` is a normal outcome, not an error.
|
|
317
|
+
*/
|
|
318
|
+
export interface BlockShareLinkResult {
|
|
319
|
+
/** The canonical absolute URL, e.g. `https://civitai.com/apps/run/<slug>/c/42?take=3`. */
|
|
320
|
+
url: string;
|
|
321
|
+
copied: boolean;
|
|
322
|
+
method: BlockShareLinkMethod;
|
|
323
|
+
}
|
|
292
324
|
/**
|
|
293
325
|
* The source-image result the host returns from `OPEN_IMAGE_UPLOAD` when the
|
|
294
326
|
* block requested `purpose: 'generationSource'` (`IMAGE_UPLOAD_RESULT.selected`)
|
|
@@ -305,12 +337,45 @@ export type BlockNavigateScope = 'app' | 'site';
|
|
|
305
337
|
* lockstep.
|
|
306
338
|
*/
|
|
307
339
|
export type BlockGenerationSourceImageInfo = BlockSourceImage;
|
|
340
|
+
/**
|
|
341
|
+
* What `useImageUpload({ purpose: 'generationSource' })` resolves with: a
|
|
342
|
+
* {@link BlockGenerationSourceImageInfo} (`{ url, width, height }`, straight into
|
|
343
|
+
* a `sourceImages` entry), plus `imageId` and `ready` when the host kept the
|
|
344
|
+
* picked file as a private, SCANNED `Image` row.
|
|
345
|
+
*
|
|
346
|
+
* The host does that while its `app-block-source-scanned-rows` rule is on: it
|
|
347
|
+
* then refuses a generation source that is not a scanned image on Civitai, so it
|
|
348
|
+
* copies the upload into a row owned by the viewer, never on the app's shared
|
|
349
|
+
* grid and not postable, and returns that row, as `PERSIST_GENERATION_SOURCE`
|
|
350
|
+
* does ({@link BlockPersistedGenerationSource}):
|
|
351
|
+
*
|
|
352
|
+
* - `imageId` is the row's id.
|
|
353
|
+
* - `ready` says whether the scan finished; the host waits up to about 30 s.
|
|
354
|
+
* `ready: false` means it is still running: a generation that uses the source
|
|
355
|
+
* is refused with the `source-scan-pending` error code until it finishes, so
|
|
356
|
+
* retry that generation later. A scan that refuses the image is an upload
|
|
357
|
+
* error, and `open()` never resolves with that image.
|
|
358
|
+
*
|
|
359
|
+
* Both are ABSENT when the rule is off, and from a host that predates it: the
|
|
360
|
+
* source is then an unscanned private upload the orchestrator scans when the
|
|
361
|
+
* workflow runs, usable at once.
|
|
362
|
+
*
|
|
363
|
+
* Mirrors the host's `BlockSourceImageInfo` in civitai/civitai's
|
|
364
|
+
* `src/components/AppBlocks/BlockGenerationSourceUploadModal.tsx`.
|
|
365
|
+
*/
|
|
366
|
+
export interface BlockUploadedGenerationSource extends BlockGenerationSourceImageInfo {
|
|
367
|
+
imageId?: number;
|
|
368
|
+
ready?: boolean;
|
|
369
|
+
}
|
|
308
370
|
/**
|
|
309
371
|
* What a block sends in `PERSIST_GENERATION_SOURCE`: ONE output of one of the
|
|
310
|
-
* calling app's OWN workflows, named by `workflowId` and `imageIndex`
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
372
|
+
* calling app's OWN workflows, named by `workflowId` and `imageIndex` — the
|
|
373
|
+
* output's POSITION in that workflow's `outputs` ({@link AppWorkflow.outputs} /
|
|
374
|
+
* {@link BlockWorkflowSnapshot.outputs}), which keeps restricted outputs in place,
|
|
375
|
+
* so an index never moves when a rating lands late. NOT an index into `images` /
|
|
376
|
+
* `imageUrls`. A restricted position is refused (`output N is restricted`). Never a
|
|
377
|
+
* url: the host resolves the output server-side from the ownership-verified
|
|
378
|
+
* workflow.
|
|
314
379
|
*/
|
|
315
380
|
export interface BlockPersistGenerationSourceRequest {
|
|
316
381
|
workflowId: string;
|
|
@@ -347,10 +412,8 @@ export interface BlockPersistedGenerationSource extends BlockGenerationSourceIma
|
|
|
347
412
|
* `Image` row, so there is no `imageId`.
|
|
348
413
|
*/
|
|
349
414
|
export interface BlockTrainingDataImage {
|
|
350
|
-
/** The uploaded blob's url. Show it as the thumbnail; it is also accepted as an item's `air`. */
|
|
351
|
-
url: string;
|
|
352
415
|
/**
|
|
353
|
-
*
|
|
416
|
+
* An AIR reference to the uploaded image — pass it as {@link BlockTrainingDatasetItem.air}.
|
|
354
417
|
* Opaque. The host compares keys case-insensitively.
|
|
355
418
|
*/
|
|
356
419
|
air: string;
|
|
@@ -483,6 +546,10 @@ export interface BlockMediaUploadInfo {
|
|
|
483
546
|
height?: number;
|
|
484
547
|
/** Duration in milliseconds, for `'video'` / `'audio'` when known. Never set for `'image'`. */
|
|
485
548
|
durationMs?: number;
|
|
549
|
+
/** As on {@link BlockUploadedGenerationSource}, for a single `'image'` upload. */
|
|
550
|
+
imageId?: number;
|
|
551
|
+
/** As on {@link BlockUploadedGenerationSource}. */
|
|
552
|
+
ready?: boolean;
|
|
486
553
|
}
|
|
487
554
|
/**
|
|
488
555
|
* One item's answer in a batch media upload (`MEDIA_UPLOAD_BATCH_RESULT.results`,
|
|
@@ -611,6 +678,16 @@ export interface PageSlotContext {
|
|
|
611
678
|
* app's own index. Lets a page app route internally without owning history.
|
|
612
679
|
*/
|
|
613
680
|
subPath: string;
|
|
681
|
+
/**
|
|
682
|
+
* The query string of the host URL below the app route — `''` or starting with
|
|
683
|
+
* `?` (`'?take=3'`). The host strips the query pairs it owns (`from`, `sl`, `src`);
|
|
684
|
+
* every other pair arrives byte-for-byte, uncapped. Lets an app deep-link into its own STATE, not
|
|
685
|
+
* just a route. Absent from a host that predates the field; read it through
|
|
686
|
+
* `useCivitaiLocation()` (blocks-react), which reads absent as `''`.
|
|
687
|
+
*/
|
|
688
|
+
search?: string;
|
|
689
|
+
/** The fragment — `''` or starting with `#` (`'#top'`). Same source as `search`. */
|
|
690
|
+
hash?: string;
|
|
614
691
|
/** `null` for an anonymous viewer. */
|
|
615
692
|
viewerUserId: number | null;
|
|
616
693
|
/** Absent/`null` when the viewer has no handle. */
|
|
@@ -1900,7 +1977,7 @@ export type AiToolkitTrainingParams = AiToolkitTrainingParamsBase & ({
|
|
|
1900
1977
|
* 1. **Upload** — `useImageUpload({ purpose: 'trainingData' }).open()`
|
|
1901
1978
|
* (`OPEN_IMAGE_UPLOAD { purpose: 'trainingData' }`). The viewer picks up to
|
|
1902
1979
|
* {@link BLOCK_TRAINING_DATASET_MAX_ITEMS} images in a host modal; you get
|
|
1903
|
-
* `[{
|
|
1980
|
+
* `[{ air }]` ({@link BlockTrainingDataImage}), or `null` on cancel.
|
|
1904
1981
|
* Pair each `air` with your caption to build {@link WorkflowBodyTraining.items}.
|
|
1905
1982
|
* 2. **Quote** — `useBuzzWorkflow().estimate(body)` with this body, `quoteId`
|
|
1906
1983
|
* ABSENT. The reply's {@link BlockWorkflowSnapshot.trainingQuote} is the
|
|
@@ -2051,7 +2128,67 @@ export interface BlockWorkflowSnapshot {
|
|
|
2051
2128
|
*/
|
|
2052
2129
|
authorFee?: number;
|
|
2053
2130
|
};
|
|
2131
|
+
/**
|
|
2132
|
+
* The urls of the outputs you may load, in production order. A RESTRICTED
|
|
2133
|
+
* output is NOT here (see {@link outputs}), so with a host that emits
|
|
2134
|
+
* `outputs` this list can be shorter than `outputs`.
|
|
2135
|
+
*
|
|
2136
|
+
* 🔴 NOT FOR INDEXING. `imageIndexes` / `imageIndex` are positions in
|
|
2137
|
+
* {@link outputs}; a position here can point at a different output.
|
|
2138
|
+
*/
|
|
2054
2139
|
imageUrls?: string[];
|
|
2140
|
+
/**
|
|
2141
|
+
* Every available output, in production order, with RESTRICTED, PENDING and
|
|
2142
|
+
* BLOCKED outputs kept IN POSITION — the list to render a result grid from. Each
|
|
2143
|
+
* entry is exactly one of:
|
|
2144
|
+
*
|
|
2145
|
+
* - `{ url, nsfwLevel? }` — load and show it. `nsfwLevel` is the rating
|
|
2146
|
+
* (`'pg'`, `'pg13'`, `'r'`, `'x'`, `'xxx'`); it is absent when there is no
|
|
2147
|
+
* rating to report and none could restrict the output.
|
|
2148
|
+
* - `{ restricted: true, reason }` — **show a locked state, and do not try to
|
|
2149
|
+
* fetch it**: the entry carries no url, and the host withholds it. `reason`:
|
|
2150
|
+
* - `'pool'` — the Buzz that paid for this generation does not include
|
|
2151
|
+
* mature content for this viewer, and the output is above PG-13;
|
|
2152
|
+
* - `'ceiling'` — the output is above the viewer's own browsing level, capped
|
|
2153
|
+
* by your app's maturity ceiling (an SFW app on an SFW host caps every
|
|
2154
|
+
* viewer at PG-13), above a cap the host put on the request, or blocked as
|
|
2155
|
+
* mature content;
|
|
2156
|
+
* - `'unrated'` — no rating will ever arrive for it (a training sample, a 3D
|
|
2157
|
+
* model on a finished step with no rating source) and one could restrict it.
|
|
2158
|
+
* Terminal: it never becomes available. (A video from an engine the
|
|
2159
|
+
* orchestrator does not rate is DELIVERED with its url while unrated, as on
|
|
2160
|
+
* Civitai — its provider moderates it.)
|
|
2161
|
+
* - `{ pending: true }` — not rated yet; no url and no `nsfwLevel`. See
|
|
2162
|
+
* {@link ratingPending}.
|
|
2163
|
+
* - `{ blocked: true }` — blocked by moderation; no url, keeps its slot, never
|
|
2164
|
+
* becomes available.
|
|
2165
|
+
*
|
|
2166
|
+
* See {@link BlockWorkflowOutput}. Not-yet-available outputs are not listed, as in
|
|
2167
|
+
* `imageUrls`.
|
|
2168
|
+
*
|
|
2169
|
+
* 🔴 INDEXES ARE POSITIONS IN THIS LIST. `imageIndexes`
|
|
2170
|
+
* (`publishGenerationOutputs`, `createPostFromApp`) and `imageIndex`
|
|
2171
|
+
* (`persistGenerationSource`) name an output by its position here. A restricted
|
|
2172
|
+
* output keeps its slot, so an index never moves when a rating lands late.
|
|
2173
|
+
* Naming a restricted position is refused with `output N is restricted` — the
|
|
2174
|
+
* host never picks another output. `imageUrls` / {@link AppWorkflow.images} drop
|
|
2175
|
+
* restricted outputs and are NOT index spaces.
|
|
2176
|
+
*
|
|
2177
|
+
* 🔴 REQUIRES A HOST VERSION THAT EMITS IT. Absent on older hosts, and when
|
|
2178
|
+
* the workflow has no available output. In `@civitai/blocks-react`, the inbound
|
|
2179
|
+
* validator REPLACES a malformed entry in place with
|
|
2180
|
+
* `{ restricted: true, reason: 'ceiling' }`, so the reply is kept and no position
|
|
2181
|
+
* moves (`@civitai/sdk` does not validate replies).
|
|
2182
|
+
*/
|
|
2183
|
+
outputs?: BlockWorkflowOutput[];
|
|
2184
|
+
/**
|
|
2185
|
+
* `true` while any entry of {@link outputs} is `{ pending: true }`. The workflow
|
|
2186
|
+
* can be in a final status and still gain a rating, so read it again until this is
|
|
2187
|
+
* absent. `watch` in `@civitai/blocks-react` and `@civitai/sdk` keeps polling for up
|
|
2188
|
+
* to two minutes after the final status while it is set, then resolves with the last
|
|
2189
|
+
* snapshot, outputs still pending. 🔴 REQUIRES A HOST VERSION THAT EMITS IT.
|
|
2190
|
+
*/
|
|
2191
|
+
ratingPending?: true;
|
|
2055
2192
|
error?: string;
|
|
2056
2193
|
/**
|
|
2057
2194
|
* A stable, machine-readable companion to {@link error}, for a block to
|
|
@@ -2550,10 +2687,19 @@ export interface BlockWorkflowStepSnapshot {
|
|
|
2550
2687
|
$type: string;
|
|
2551
2688
|
status: 'pending' | 'processing' | 'succeeded' | 'failed' | 'expired' | 'canceled';
|
|
2552
2689
|
/**
|
|
2553
|
-
* This step's own image urls
|
|
2554
|
-
* for a step submitted with
|
|
2690
|
+
* This step's own image urls, restricted outputs excluded — not for indexing.
|
|
2691
|
+
* Omitted when it has none, and always omitted for a step submitted with
|
|
2692
|
+
* `suppressOutput: true`.
|
|
2555
2693
|
*/
|
|
2556
2694
|
imageUrls?: string[];
|
|
2695
|
+
/**
|
|
2696
|
+
* This step's own outputs, restricted ones in position — the same rules as
|
|
2697
|
+
* {@link BlockWorkflowSnapshot.outputs}. Omitted with `imageUrls`'s rule, and
|
|
2698
|
+
* present when every output of the step is restricted.
|
|
2699
|
+
*/
|
|
2700
|
+
outputs?: BlockWorkflowOutput[];
|
|
2701
|
+
/** `true` while any of this step's `outputs` is pending — see {@link BlockWorkflowSnapshot.ratingPending}. */
|
|
2702
|
+
ratingPending?: true;
|
|
2557
2703
|
/**
|
|
2558
2704
|
* The step's raw orchestrator output, minus its blobs — the same treatment
|
|
2559
2705
|
* and the same caveats as {@link BlockWorkflowSnapshot.stepOutputs}: its shape
|
|
@@ -2704,6 +2850,138 @@ export interface BlockStepQuote {
|
|
|
2704
2850
|
/** ISO-8601. The quote cannot be run after this. */
|
|
2705
2851
|
expiresAt: string;
|
|
2706
2852
|
}
|
|
2853
|
+
/**
|
|
2854
|
+
* The rating of an output you may load ({@link BlockWorkflowOutput}). An unknown
|
|
2855
|
+
* value is possible (the field is typed as these plus any string, and the SDK's
|
|
2856
|
+
* inbound validator accepts any string); treat one as the most mature rating.
|
|
2857
|
+
*/
|
|
2858
|
+
export type KnownBlockWorkflowOutputRating = 'pg' | 'pg13' | 'r' | 'x' | 'xxx';
|
|
2859
|
+
/**
|
|
2860
|
+
* Why an output is restricted ({@link BlockWorkflowRestrictedOutput}). An unknown
|
|
2861
|
+
* value is possible; treat it like `'ceiling'`.
|
|
2862
|
+
*
|
|
2863
|
+
* - `'pool'` — the Buzz that paid does not include mature content for this
|
|
2864
|
+
* viewer, and the output is above PG-13.
|
|
2865
|
+
* - `'ceiling'` — the output is above the viewer's own browsing level, capped by
|
|
2866
|
+
* the app's maturity ceiling, above a cap the host put on the request, or
|
|
2867
|
+
* blocked as mature content.
|
|
2868
|
+
* - `'unrated'` — no rating will ever arrive for the output and one could restrict
|
|
2869
|
+
* it, so the host fails closed. Terminal; does not set `ratingPending`.
|
|
2870
|
+
*/
|
|
2871
|
+
export type KnownBlockWorkflowRestrictionReason = 'pool' | 'ceiling' | 'unrated';
|
|
2872
|
+
/** An output you may load: an entry of {@link BlockWorkflowSnapshot.outputs}. */
|
|
2873
|
+
export interface BlockWorkflowAvailableOutput {
|
|
2874
|
+
url: string;
|
|
2875
|
+
/**
|
|
2876
|
+
* Absent when the output has no rating to report: the host HOLDS an unrated output
|
|
2877
|
+
* whose rating could still restrict it ({@link BlockWorkflowPendingOutput}), so an
|
|
2878
|
+
* entry with a url and no rating is one nothing could restrict.
|
|
2879
|
+
*/
|
|
2880
|
+
nsfwLevel?: KnownBlockWorkflowOutputRating | (string & {});
|
|
2881
|
+
restricted?: never;
|
|
2882
|
+
reason?: never;
|
|
2883
|
+
pending?: never;
|
|
2884
|
+
blocked?: never;
|
|
2885
|
+
}
|
|
2886
|
+
/**
|
|
2887
|
+
* An output NOT RATED YET whose rating could still restrict it (the viewer's level,
|
|
2888
|
+
* capped by your app's maturity ceiling, is below the top rating, the workflow refused
|
|
2889
|
+
* mature content, or the host capped it).
|
|
2890
|
+
* There is no url until the rating lands. The orchestrator can mark a workflow
|
|
2891
|
+
* succeeded seconds before it rates the last output, so the snapshot carries
|
|
2892
|
+
* {@link BlockWorkflowSnapshot.ratingPending}: poll again — `@civitai/blocks-react`'s
|
|
2893
|
+
* and `@civitai/sdk`'s `watch` do, for up to two minutes after the final status.
|
|
2894
|
+
* Show a "still processing" tile; publishing, posting or persisting this position is
|
|
2895
|
+
* refused with `output N is still being rated, try again shortly`.
|
|
2896
|
+
*/
|
|
2897
|
+
export interface BlockWorkflowPendingOutput {
|
|
2898
|
+
pending: true;
|
|
2899
|
+
url?: never;
|
|
2900
|
+
nsfwLevel?: never;
|
|
2901
|
+
restricted?: never;
|
|
2902
|
+
reason?: never;
|
|
2903
|
+
blocked?: never;
|
|
2904
|
+
}
|
|
2905
|
+
/**
|
|
2906
|
+
* An output BLOCKED by moderation. It keeps its position (so no index moves when a
|
|
2907
|
+
* block lands late) and carries no url and no rating; it never becomes available.
|
|
2908
|
+
* Publishing, posting or persisting it is refused. A maturity block reads as a
|
|
2909
|
+
* {@link BlockWorkflowRestrictedOutput} with `reason: 'ceiling'` instead.
|
|
2910
|
+
*/
|
|
2911
|
+
export interface BlockWorkflowBlockedOutput {
|
|
2912
|
+
blocked: true;
|
|
2913
|
+
url?: never;
|
|
2914
|
+
nsfwLevel?: never;
|
|
2915
|
+
restricted?: never;
|
|
2916
|
+
reason?: never;
|
|
2917
|
+
pending?: never;
|
|
2918
|
+
}
|
|
2919
|
+
/**
|
|
2920
|
+
* A RESTRICTED output: an entry of {@link BlockWorkflowSnapshot.outputs} that
|
|
2921
|
+
* carries NO url. Show a locked state in its place and do not try to fetch it.
|
|
2922
|
+
*/
|
|
2923
|
+
export interface BlockWorkflowRestrictedOutput {
|
|
2924
|
+
restricted: true;
|
|
2925
|
+
reason: KnownBlockWorkflowRestrictionReason | (string & {});
|
|
2926
|
+
url?: never;
|
|
2927
|
+
nsfwLevel?: never;
|
|
2928
|
+
pending?: never;
|
|
2929
|
+
blocked?: never;
|
|
2930
|
+
}
|
|
2931
|
+
/**
|
|
2932
|
+
* One entry of {@link BlockWorkflowSnapshot.outputs} /
|
|
2933
|
+
* {@link BlockWorkflowStepSnapshot.outputs} / {@link AppWorkflow.outputs}.
|
|
2934
|
+
* Narrow on `restricted === true`:
|
|
2935
|
+
*
|
|
2936
|
+
* ```ts
|
|
2937
|
+
* for (const out of snapshot.outputs ?? []) {
|
|
2938
|
+
* if (out.restricted === true) renderLocked(out.reason);
|
|
2939
|
+
* else if (out.pending === true) renderProcessing();
|
|
2940
|
+
* else if (out.blocked === true) renderUnavailable();
|
|
2941
|
+
* else renderImage(out.url);
|
|
2942
|
+
* }
|
|
2943
|
+
* ```
|
|
2944
|
+
*/
|
|
2945
|
+
export type BlockWorkflowOutput = BlockWorkflowAvailableOutput | BlockWorkflowRestrictedOutput | BlockWorkflowPendingOutput | BlockWorkflowBlockedOutput;
|
|
2946
|
+
/**
|
|
2947
|
+
* How an output unlock ended ({@link BlockOutputUnlockResult}). An unknown value is
|
|
2948
|
+
* possible; treat it like `'unavailable'`.
|
|
2949
|
+
*
|
|
2950
|
+
* - `'unlocked'` — the output now carries a url: read it from `snapshot.outputs` at
|
|
2951
|
+
* the position you asked about. The viewer paid for it in the host's own dialog.
|
|
2952
|
+
* - `'not-restricted'` — it already had a url (a retry after an unlock lands here).
|
|
2953
|
+
* Nothing was shown or charged; poll the workflow to read it.
|
|
2954
|
+
* - `'not-released'` — the unlock ran but the output is still above the viewer's
|
|
2955
|
+
* browsing level; `snapshot` shows it still restricted, `message` says why.
|
|
2956
|
+
* - `'refused'` — the viewer does not have enough yellow Buzz for the unlock;
|
|
2957
|
+
* nothing was charged. `message` says so.
|
|
2958
|
+
* - `'linked-out'` — the site your app runs on cannot show it, and the viewer opened
|
|
2959
|
+
* your app on civitai.red, at the same page, to see it there. Never charged.
|
|
2960
|
+
* - `'dismissed'` — the viewer closed the dialog without a completed unlock. If an
|
|
2961
|
+
* unlock attempt failed before they closed it, its charge state is unknown: poll
|
|
2962
|
+
* the workflow to see the output's current entry.
|
|
2963
|
+
* - `'unavailable'` — it cannot be unlocked here; `message` says why (for example,
|
|
2964
|
+
* the viewer's own mature content settings hide it).
|
|
2965
|
+
*/
|
|
2966
|
+
export type KnownBlockOutputUnlockOutcome = 'unlocked' | 'not-restricted' | 'not-released' | 'refused' | 'linked-out' | 'dismissed' | 'unavailable';
|
|
2967
|
+
/**
|
|
2968
|
+
* The outcome of asking the host to unlock ONE restricted output
|
|
2969
|
+
* (`REQUEST_OUTPUT_UNLOCK`, `@civitai/blocks-react`'s `useOutputUnlock`).
|
|
2970
|
+
*
|
|
2971
|
+
* The host decides what to offer from the live workflow, never from your app: an
|
|
2972
|
+
* output restricted for the paying Buzz pool (`reason: 'pool'`) can be unlocked with
|
|
2973
|
+
* yellow Buzz (the viewer confirms the price in the host's dialog). An unlock adds no
|
|
2974
|
+
* author share and counts against no spend limit: the original generation's spend
|
|
2975
|
+
* already did. One restricted for `'ceiling'` or `'unrated'` is never charged (the host
|
|
2976
|
+
* links to your app on civitai.red when that site could show it).
|
|
2977
|
+
*/
|
|
2978
|
+
export interface BlockOutputUnlockResult {
|
|
2979
|
+
outcome: KnownBlockOutputUnlockOutcome | (string & {});
|
|
2980
|
+
/** The re-read workflow, on `'unlocked'`, `'not-released'` and `'refused'`. */
|
|
2981
|
+
snapshot?: BlockWorkflowSnapshot;
|
|
2982
|
+
/** Why, on `'refused'`, `'not-released'` and `'unavailable'`. For display. */
|
|
2983
|
+
message?: string;
|
|
2984
|
+
}
|
|
2707
2985
|
/**
|
|
2708
2986
|
* One entry of {@link BlockWorkflowSnapshot.model3dOutputs} /
|
|
2709
2987
|
* {@link AppWorkflow.model3dOutputs} — the label for one 3D model url.
|
|
@@ -3881,7 +4159,9 @@ export interface AppWorkflowImage {
|
|
|
3881
4159
|
*
|
|
3882
4160
|
* status: the block-contract status — the orchestrator's
|
|
3883
4161
|
* `unassigned`/`preparing`/`scheduled` all collapse to `pending`.
|
|
3884
|
-
* images: only `available` blobs with a non-null url (see {@link AppWorkflowImage})
|
|
4162
|
+
* images: only `available` blobs with a non-null url (see {@link AppWorkflowImage}),
|
|
4163
|
+
* RESTRICTED outputs excluded. A convenience view, NOT for indexing:
|
|
4164
|
+
* `imageIndexes` / `imageIndex` are positions in `outputs`.
|
|
3885
4165
|
* cost: the workflow's realized/estimated buzz total, or `null` when absent.
|
|
3886
4166
|
* createdAt: ISO-8601 string.
|
|
3887
4167
|
*/
|
|
@@ -3921,6 +4201,17 @@ export interface AppWorkflow {
|
|
|
3921
4201
|
* there are none (and on hosts that predate it).
|
|
3922
4202
|
*/
|
|
3923
4203
|
model3dOutputs?: BlockModel3dOutput[];
|
|
4204
|
+
/**
|
|
4205
|
+
* Every available output, restricted ones IN POSITION — same value and rules
|
|
4206
|
+
* as {@link BlockWorkflowSnapshot.outputs}. THIS is the index space of
|
|
4207
|
+
* `imageIndexes` / `imageIndex`; a restricted output is not in
|
|
4208
|
+
* {@link AppWorkflow.images}, which is not.
|
|
4209
|
+
*
|
|
4210
|
+
* 🔴 REQUIRES A HOST VERSION THAT EMITS IT. Absent on older hosts.
|
|
4211
|
+
*/
|
|
4212
|
+
outputs?: BlockWorkflowOutput[];
|
|
4213
|
+
/** Same value and rule as {@link BlockWorkflowSnapshot.ratingPending}. */
|
|
4214
|
+
ratingPending?: true;
|
|
3924
4215
|
}
|
|
3925
4216
|
/**
|
|
3926
4217
|
* Per-viewer gated projection of ONE image returned by `GET_IMAGES_BY_IDS`
|
package/dist/index.d.ts
CHANGED
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
*
|
|
26
26
|
* - **`./blocks`** — importing it RUNS `./safe-storage` for its side effect
|
|
27
27
|
* (repairing `localStorage`/`sessionStorage` at an opaque origin). Folding
|
|
28
|
-
*
|
|
28
|
+
* 242 symbols and that side effect into the root would make every OAuth app
|
|
29
29
|
* that writes `import { exchangeCode } from '@civitai/app-sdk'` pay for the
|
|
30
30
|
* Civitai-Apps contract it does not use. Blocks and OAuth apps are disjoint
|
|
31
31
|
* audiences; see this package's README.
|
|
32
|
-
* 🔴 That
|
|
32
|
+
* 🔴 That 242 is ASSERTED, not merely quoted — by
|
|
33
33
|
* `packages/civitai-app-sdk/test/export-surface.test.ts`, which pins
|
|
34
34
|
* `surface.get('./blocks').size`. It said 119 here against a real 125 until
|
|
35
35
|
* 2026-10-04, because the existing checks pin the root as an exact union and
|
package/dist/index.js
CHANGED
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
*
|
|
26
26
|
* - **`./blocks`** — importing it RUNS `./safe-storage` for its side effect
|
|
27
27
|
* (repairing `localStorage`/`sessionStorage` at an opaque origin). Folding
|
|
28
|
-
*
|
|
28
|
+
* 242 symbols and that side effect into the root would make every OAuth app
|
|
29
29
|
* that writes `import { exchangeCode } from '@civitai/app-sdk'` pay for the
|
|
30
30
|
* Civitai-Apps contract it does not use. Blocks and OAuth apps are disjoint
|
|
31
31
|
* audiences; see this package's README.
|
|
32
|
-
* 🔴 That
|
|
32
|
+
* 🔴 That 242 is ASSERTED, not merely quoted — by
|
|
33
33
|
* `packages/civitai-app-sdk/test/export-surface.test.ts`, which pins
|
|
34
34
|
* `surface.get('./blocks').size`. It said 119 here against a real 125 until
|
|
35
35
|
* 2026-10-04, because the existing checks pin the root as an exact union and
|
package/package.json
CHANGED
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"auth": {
|
|
73
73
|
"type": "string",
|
|
74
|
-
"description": "Which credential the host hands the block: \"block-token\" (default when omitted) is the block-scoped JWT; \"oauth\" asks for an opaque OAuth access token for the block's own OauthClient, which ordinary /api/v1 routes accept as a viewer bearer. Minting it
|
|
74
|
+
"description": "Which credential the host hands the block: \"block-token\" (default when omitted) is the block-scoped JWT; \"oauth\" asks for an opaque OAuth access token for the block's own OauthClient, which ordinary /api/v1 routes accept as a viewer bearer. Minting it requires OAuth minting to be switched on for the server, a signed-in viewer and a declared \"user:read:self\" scope; when any of those is unmet the host hands back a block JWT instead of failing, so branch on the token kind the host reports rather than on this field. An OAuth token is refused by the postMessage bridge procedures, which verify a block JWT only, and a manifest declaring \"oauth\" alongside \"apps:storage\" or any \"apps:storage:*\" scope is rejected by manifest validation.",
|
|
75
75
|
"enum": ["block-token", "oauth"]
|
|
76
76
|
},
|
|
77
77
|
"trustTier": {
|