@civitai/app-sdk 0.96.0 → 0.98.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocks/index.d.ts +1 -1
- package/dist/blocks/types.d.ts +66 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/manifest/defineBlock.d.ts +1 -0
- package/dist/manifest/defineBlock.js +8 -1
- package/dist/manifest/index.d.ts +1 -1
- package/package.json +1 -1
- package/schemas/app-block/v1.json +36 -1
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, BlockUploadedGenerationSource, BlockPersistGenerationSourceRequest, BlockPersistedGenerationSource, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockMediaUploadBatchItemResult, BlockPendingImageInfo, BlockSharedUploadImageInfo, BlockSharedPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockShareLinkMethod, BlockShareLinkRequest, BlockShareLinkResult, BlockTextToImageParams, BlockWorkflowSnapshot, RateLimitMeta, 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';
|
|
91
|
+
export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockSettings, BlockStorageCollectionDeclaration, BlockStorageCollectionExtends, 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, ViewerImage, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockUploadedGenerationSource, BlockPersistGenerationSourceRequest, BlockPersistedGenerationSource, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockMediaUploadBatchItemResult, BlockPendingImageInfo, BlockSharedUploadImageInfo, BlockSharedPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockShareLinkMethod, BlockShareLinkRequest, BlockShareLinkResult, BlockTextToImageParams, BlockWorkflowSnapshot, RateLimitMeta, 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`.
|
package/dist/blocks/types.d.ts
CHANGED
|
@@ -831,7 +831,8 @@ export interface ViewerInfo {
|
|
|
831
831
|
* so there is no half-covered fleet.
|
|
832
832
|
* - That repo's own contract test (`__tests__/projectBlockInit.test.ts`) now
|
|
833
833
|
* pins the BLOCK_INIT viewer key set as exactly
|
|
834
|
-
* `['id', 'signedIn', 'username']
|
|
834
|
+
* `['id', 'signedIn', 'username']` — plus {@link ViewerInfo.image} when the
|
|
835
|
+
* token carries `user:read:self` — and asserts the value is literally
|
|
835
836
|
* `true` rather than a computed boolean.
|
|
836
837
|
* - It arrived with civitai/civitai#3707 (merged 2026-08-07). Earlier
|
|
837
838
|
* revisions of this doc first told authors to write `viewer !== null`
|
|
@@ -869,7 +870,39 @@ export interface ViewerInfo {
|
|
|
869
870
|
username: string | null;
|
|
870
871
|
/** @deprecated Not sent by the platform to third-party iframes (civitai #2521). */
|
|
871
872
|
status?: 'active' | 'banned' | 'muted';
|
|
873
|
+
/**
|
|
874
|
+
* The viewer's avatar — see {@link ViewerImage}. Sent only when the block token
|
|
875
|
+
* carries `user:read:self`; ABSENT otherwise, and on a host that predates the
|
|
876
|
+
* field. Computed when the token is minted and not re-sent after a later consent
|
|
877
|
+
* grant: read `useViewer()` / `blocks/me` for a fresh value.
|
|
878
|
+
*/
|
|
879
|
+
image?: ViewerImage;
|
|
872
880
|
}
|
|
881
|
+
/**
|
|
882
|
+
* The viewer's avatar as the platform lets an app see it — the same value on
|
|
883
|
+
* `BLOCK_INIT.viewer.image`, `useViewer()` (`GET_VIEWER`) and
|
|
884
|
+
* `GET /api/v1/blocks/me`. The platform judges it against the block token's
|
|
885
|
+
* maturity ceiling — the one that restricts workflow outputs — and fails closed:
|
|
886
|
+
*
|
|
887
|
+
* - `{ url, nsfwLevel }` — a ready-to-render CDN image url and the avatar's
|
|
888
|
+
* rating (the same vocabulary as a workflow output's `nsfwLevel`:
|
|
889
|
+
* {@link KnownBlockWorkflowOutputRating}, open-ended).
|
|
890
|
+
* - `{ restricted: true }` — the viewer HAS an avatar this app may not show:
|
|
891
|
+
* rated above what this app may show this viewer (e.g. an X avatar in an SFW
|
|
892
|
+
* app), or not rated (still being scanned, or never). No url, and no reason —
|
|
893
|
+
* which of the two it is would disclose the avatar's rating.
|
|
894
|
+
* - `null` — the viewer has no avatar to show.
|
|
895
|
+
*
|
|
896
|
+
* Mirrors civitai/civitai's `BlockInitViewerImage`
|
|
897
|
+
* (`src/components/AppBlocks/types.ts`) and `projectBlockViewerImage`
|
|
898
|
+
* (`src/server/services/blocks/block-viewer-image.ts`).
|
|
899
|
+
*/
|
|
900
|
+
export type ViewerImage = {
|
|
901
|
+
url: string;
|
|
902
|
+
nsfwLevel: KnownBlockWorkflowOutputRating | (string & {});
|
|
903
|
+
} | {
|
|
904
|
+
restricted: true;
|
|
905
|
+
} | null;
|
|
873
906
|
/**
|
|
874
907
|
* THE sign-in gate. Pass `useBlockContext().viewer` (or a `BlockInitPayload`'s
|
|
875
908
|
* `viewer`) and render the signed-in branch when it returns `true`.
|
|
@@ -3492,6 +3525,29 @@ export interface BlockStorageCollectionHook {
|
|
|
3492
3525
|
/** The most milliseconds one call may take: an integer from 1 to 500. Omitted means 50. */
|
|
3493
3526
|
timeoutMs?: number;
|
|
3494
3527
|
}
|
|
3528
|
+
/**
|
|
3529
|
+
* RESERVED — civitai.com refuses this field until extensions are enabled, so do
|
|
3530
|
+
* not declare it yet. The source of an EXTENSION collection: this private
|
|
3531
|
+
* collection's document under key `k` extends the viewer's document under the
|
|
3532
|
+
* same key `k` in `from`'s collection `collection`, and a reader merges the two
|
|
3533
|
+
* on read (the source's value wins a property both hold;
|
|
3534
|
+
* `@civitai/sdk`'s `app.storage.extended()`). The source is never written.
|
|
3535
|
+
*
|
|
3536
|
+
* Checked by the server, not by the schema: `storage.imports` must import
|
|
3537
|
+
* `collection` from `from` with access `'read'` (never `'readwrite'`); the
|
|
3538
|
+
* source must have an approved version declaring the collection, not
|
|
3539
|
+
* `exportable: false`, and not itself an extension; this collection's
|
|
3540
|
+
* `schema` may not declare a top-level property the source's also declares; at
|
|
3541
|
+
* most 4 collections may declare `extends`; and it cannot be added, removed or
|
|
3542
|
+
* changed on a collection any approved version declared. See
|
|
3543
|
+
* `KNOWN_GAPS['storage-extends-server-only-rules']`.
|
|
3544
|
+
*/
|
|
3545
|
+
export interface BlockStorageCollectionExtends {
|
|
3546
|
+
/** The source app's blockId (its slug): `^[a-z][a-z0-9-]{1,38}[a-z0-9]$`. */
|
|
3547
|
+
from: string;
|
|
3548
|
+
/** The source app's collection name: `^[a-z][a-z0-9_]{0,31}$`. */
|
|
3549
|
+
collection: string;
|
|
3550
|
+
}
|
|
3495
3551
|
/**
|
|
3496
3552
|
* A PRIVATE collection — a separate key space per viewer, read and written
|
|
3497
3553
|
* only by that viewer. Carries none of the shared-only fields (`write`,
|
|
@@ -3519,6 +3575,13 @@ export interface BlockStoragePrivateCollectionDeclaration {
|
|
|
3519
3575
|
migrations?: BlockStorageMigrationOp[];
|
|
3520
3576
|
/** Limited rollout — see {@link BlockStorageSharedCollectionDeclaration.hook}. */
|
|
3521
3577
|
hook?: BlockStorageCollectionHook;
|
|
3578
|
+
/**
|
|
3579
|
+
* RESERVED — makes this collection an EXTENSION of another app's collection;
|
|
3580
|
+
* see {@link BlockStorageCollectionExtends}. Private collections of kind
|
|
3581
|
+
* `'docs'` only (the canonical refuses it with `kind` `'log'`, and it does
|
|
3582
|
+
* not exist on a shared collection).
|
|
3583
|
+
*/
|
|
3584
|
+
extends?: BlockStorageCollectionExtends;
|
|
3522
3585
|
}
|
|
3523
3586
|
/**
|
|
3524
3587
|
* A SHARED collection — one key space for the whole app, read by every viewer
|
|
@@ -4121,6 +4184,8 @@ export interface BlockViewer {
|
|
|
4121
4184
|
status: 'active' | 'muted';
|
|
4122
4185
|
/** The viewer's current Buzz budget, or `null` when the token lacks the claim. */
|
|
4123
4186
|
buzzBudget: number | null;
|
|
4187
|
+
/** The viewer's avatar — see {@link ViewerImage}. Absent from a host that predates it. */
|
|
4188
|
+
image?: ViewerImage;
|
|
4124
4189
|
}
|
|
4125
4190
|
/**
|
|
4126
4191
|
* The DISCRIMINATED error enum a `WILDCARD_PACK_RESULT` carries on failure —
|
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
|
+
* 247 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 247 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
|
+
* 247 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 247 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
|
|
@@ -100,6 +100,7 @@ export declare const KNOWN_GAPS: {
|
|
|
100
100
|
readonly 'storage-collection-schema-server-only-rules': string;
|
|
101
101
|
readonly 'storage-migrations-server-only-rules': string;
|
|
102
102
|
readonly 'storage-keyedBy-immutable': string;
|
|
103
|
+
readonly 'storage-extends-server-only-rules': string;
|
|
103
104
|
readonly 'format-uri-not-enforced': string;
|
|
104
105
|
};
|
|
105
106
|
/** The canonical schema object, parsed once. Exported for tests and tooling. */
|
|
@@ -153,7 +153,7 @@ export const KNOWN_GAPS = {
|
|
|
153
153
|
'already declare in the app\'s previous approved version; use a viewer-keyed collection, ' +
|
|
154
154
|
'`keyedBy`, instead), and the ' +
|
|
155
155
|
'RESERVED features (`kind` "log", `ttlSeconds`, `dailyWritesPerAuthor`, `registry`, ' +
|
|
156
|
-
'`write` "anyone" / "owner") validate offline and are refused at submit. A new or changed ' +
|
|
156
|
+
'`write` "anyone" / "owner", `extends`) validate offline and are refused at submit. A new or changed ' +
|
|
157
157
|
'`hook` is in a limited rollout: it validates offline and is refused at submit for an author ' +
|
|
158
158
|
'the rollout does not include. A `hook`\'s `file` ' +
|
|
159
159
|
'being outside `outputDir`, present in the bundle with its `sha256`, its size, and one file ' +
|
|
@@ -182,6 +182,13 @@ export const KNOWN_GAPS = {
|
|
|
182
182
|
'exactly. That it cannot be added, removed or changed on a collection ANY previously ' +
|
|
183
183
|
'approved version declared needs those approved manifests, so it is decided by the server at ' +
|
|
184
184
|
'submit. A change to it validates here.',
|
|
185
|
+
'storage-extends-server-only-rules': 'A collection\'s `extends` (an extension of another app\'s collection): the canonical encodes ' +
|
|
186
|
+
'its shape (`from` a blockId, `collection` a collection name, nothing else) and that it sits ' +
|
|
187
|
+
'only on a private collection of kind "docs", and Ajv enforces those exactly. The rest is the ' +
|
|
188
|
+
'server\'s, at submit: a covering `storage.imports` entry with access "read", the source app\'s ' +
|
|
189
|
+
'approved manifest declaring the collection, not `exportable: false` and not itself an ' +
|
|
190
|
+
'extension, no top-level schema property shared with the source, at most 4 extensions, and ' +
|
|
191
|
+
'that `extends` never changes on a collection any approved version declared. Those validate here.',
|
|
185
192
|
'format-uri-not-enforced': '`assetBundleUrl` carries `format: "uri"` in addition to `pattern: "^https://"`. Ajv ignores ' +
|
|
186
193
|
'unknown formats unless `ajv-formats` is installed, which would be a second optional peer for ' +
|
|
187
194
|
'one field whose pattern is already enforced. The pattern IS enforced; the `uri` format is ' +
|
package/dist/manifest/index.d.ts
CHANGED
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
export { defineBlock, SCHEMA_DIVERGENCES, KNOWN_GAPS, loadCanonicalSchema } from './defineBlock.js';
|
|
16
16
|
export type { DefineBlockConfig } from './defineBlock.js';
|
|
17
17
|
export { BlockManifestError } from '../blocks/manifestError.js';
|
|
18
|
-
export type { BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockStorageCollectionDeclaration, BlockStorageCollectionHook, BlockStorageCollectionSchema, BlockStorageDeclaration, BlockStorageImport, BlockStorageIndexes, BlockStorageIndexType, BlockStorageMigrationKeyword, BlockStorageMigrationOp, BlockStoragePrivateCollectionDeclaration, BlockStorageSchemaType, BlockStorageSharedCollectionDeclaration, } from '../blocks/types.js';
|
|
18
|
+
export type { BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockStorageCollectionDeclaration, BlockStorageCollectionExtends, BlockStorageCollectionHook, BlockStorageCollectionSchema, BlockStorageDeclaration, BlockStorageImport, BlockStorageIndexes, BlockStorageIndexType, BlockStorageMigrationKeyword, BlockStorageMigrationOp, BlockStoragePrivateCollectionDeclaration, BlockStorageSchemaType, BlockStorageSharedCollectionDeclaration, } from '../blocks/types.js';
|
|
19
19
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -381,7 +381,7 @@
|
|
|
381
381
|
},
|
|
382
382
|
"storage": {
|
|
383
383
|
"type": "object",
|
|
384
|
-
"description": "Optional APP STORAGE declaration — every collection of JSON documents your app keeps, and who may read and write each one. Manifest-governed and REVIEW-GATED: a collection that is not declared here does not exist at runtime, and the moderator sees each collection's visibility, write policy, counters, marks and indexes. Declaring any collection also requires the `apps:storage` scope; declaring a shared collection that viewers write (`write` of \"own\" or \"anyone\") also requires the sensitive, consent-gated `apps:storage:publish` scope with a `scopeJustifications` entry; declaring any `imports` also requires the sensitive, consent-gated `apps:storage:import` scope with a `scopeJustifications` entry (and `apps:storage`); and requesting any of these scopes with nothing here for it to reach is rejected. At least one of `collections` and `imports` is required. This schema describes the WHOLE declaration, including features the platform does not accept yet: today the server's manifest validation refuses `kind` \"log\", `ttlSeconds`, `dailyWritesPerAuthor`, `write` \"anyone\"
|
|
384
|
+
"description": "Optional APP STORAGE declaration — every collection of JSON documents your app keeps, and who may read and write each one. Manifest-governed and REVIEW-GATED: a collection that is not declared here does not exist at runtime, and the moderator sees each collection's visibility, write policy, counters, marks and indexes. Declaring any collection also requires the `apps:storage` scope; declaring a shared collection that viewers write (`write` of \"own\" or \"anyone\") also requires the sensitive, consent-gated `apps:storage:publish` scope with a `scopeJustifications` entry; declaring any `imports` also requires the sensitive, consent-gated `apps:storage:import` scope with a `scopeJustifications` entry (and `apps:storage`); and requesting any of these scopes with nothing here for it to reach is rejected. At least one of `collections` and `imports` is required. This schema describes the WHOLE declaration, including features the platform does not accept yet: today the server's manifest validation refuses `kind` \"log\", `ttlSeconds`, `dailyWritesPerAuthor`, `write` \"anyone\", `write` \"owner\" and `extends` with a message saying they are not available yet, so those validate offline and are rejected at submit. Kept in lockstep with src/shared/constants/block-storage.constants.ts (a drift-guard test enforces equality); the imperative validator in that module is authoritative.",
|
|
385
385
|
"additionalProperties": false,
|
|
386
386
|
"anyOf": [{ "required": ["collections"] }, { "required": ["imports"] }],
|
|
387
387
|
"properties": {
|
|
@@ -546,9 +546,24 @@
|
|
|
546
546
|
"hook": {
|
|
547
547
|
"description": "Optional, in a limited rollout: civitai.com accepts a new or changed hook only from authors the rollout includes, and refuses it otherwise. A permission hook: one ES module of the bundle whose default export decides, for every write to this collection, whether the write is allowed. It runs after the collection `schema` check, never instead of it. `file` is the hook's path in the submitted bundle, shipped verbatim — a committed source file, not a build output, so it must not be inside `outputDir` or `node_modules`; one self-contained module with no imports, at most 65536 bytes of UTF-8 text. `sha256` is the SHA-256 of that file's bytes as 64 lowercase hex characters: submit, the git-push path and approve each refuse a version whose file is missing or does not match it. `timeoutMs` is the most time one call may take, from 1 to 500 (omitted means 50). One file used by several collections must be pinned with the same sha256 in each.",
|
|
548
548
|
"$ref": "#/$defs/storageCollectionHook"
|
|
549
|
+
},
|
|
550
|
+
"extends": {
|
|
551
|
+
"description": "RESERVED — civitai.com refuses this field until extensions are enabled, so do not declare it yet. Private collections of kind \"docs\" only, without `keyedBy`. Makes this collection an EXTENSION of another app's collection: the viewer's document here under key k extends that viewer's document under the same key k in the source collection, and a reader merges the two on read (the source's value wins a property both hold). The source is never written. `from` is the source app's blockId and must be imported by `storage.imports` with access \"read\" (never \"readwrite\") naming `collection`. Submit refuses an extension whose source has no approved version or does not declare the collection, declares it `exportable: false`, or itself extends another collection; and one whose `schema` declares a top-level property the source collection's schema also declares. At most 4 collections may declare `extends`. Cannot be added, removed or changed on a collection any approved version declared: declare a new collection instead. A moderator sees each extension at review.",
|
|
552
|
+
"$ref": "#/$defs/storageCollectionExtends"
|
|
549
553
|
}
|
|
550
554
|
},
|
|
551
555
|
"allOf": [
|
|
556
|
+
{
|
|
557
|
+
"$comment": "An extension holds the viewer's own documents under the base collection's keys: private docs only (keyedBy is refused on private collections below).",
|
|
558
|
+
"if": { "required": ["extends"] },
|
|
559
|
+
"then": {
|
|
560
|
+
"required": ["visibility"],
|
|
561
|
+
"properties": {
|
|
562
|
+
"visibility": { "const": "private" },
|
|
563
|
+
"kind": { "const": "docs" }
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
},
|
|
552
567
|
{
|
|
553
568
|
"$comment": "No document body is ever written in a write:\"none\" collection, so a schema there would check nothing and a migration would migrate nothing.",
|
|
554
569
|
"if": {
|
|
@@ -796,6 +811,26 @@
|
|
|
796
811
|
"maximum": 500
|
|
797
812
|
}
|
|
798
813
|
}
|
|
814
|
+
},
|
|
815
|
+
"storageCollectionExtends": {
|
|
816
|
+
"type": "object",
|
|
817
|
+
"description": "The source of an extension (see `storage.collections.<name>.extends`). Whether `storage.imports` covers it with access \"read\", what the source app's approved manifest declares, the limit of 4, and that it never changes once approved are checked by the server, not by this schema.",
|
|
818
|
+
"additionalProperties": false,
|
|
819
|
+
"required": ["from", "collection"],
|
|
820
|
+
"properties": {
|
|
821
|
+
"from": {
|
|
822
|
+
"type": "string",
|
|
823
|
+
"description": "The source app's blockId (its slug).",
|
|
824
|
+
"minLength": 3,
|
|
825
|
+
"maxLength": 40,
|
|
826
|
+
"pattern": "^[a-z][a-z0-9-]{1,38}[a-z0-9]$"
|
|
827
|
+
},
|
|
828
|
+
"collection": {
|
|
829
|
+
"type": "string",
|
|
830
|
+
"description": "The name of the source app's collection this one extends.",
|
|
831
|
+
"pattern": "^[a-z][a-z0-9_]{0,31}$"
|
|
832
|
+
}
|
|
833
|
+
}
|
|
799
834
|
}
|
|
800
835
|
},
|
|
801
836
|
"allOf": [
|