@civitai/app-sdk 0.80.1 → 0.81.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/messages.d.ts +1 -0
- package/dist/blocks/scopes.d.ts +1 -0
- package/dist/blocks/scopes.js +5 -0
- package/dist/blocks/types.d.ts +113 -3
- 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 +12 -2
- package/dist/manifest/index.d.ts +1 -1
- package/package.json +1 -1
- package/schemas/app-block/v1.json +102 -13
package/dist/blocks/index.d.ts
CHANGED
|
@@ -116,7 +116,7 @@ export { isModelSlotContext, isPageSlotContext } from './types.js';
|
|
|
116
116
|
* in `types.ts` for which of the two it uses and why.
|
|
117
117
|
*/
|
|
118
118
|
export { isSignedIn } from './types.js';
|
|
119
|
-
export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockSettings, BlockStorageCollectionDeclaration, BlockStorageDeclaration, BlockStorageIndexes, BlockStorageIndexType, BlockStoragePrivateCollectionDeclaration, 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';
|
|
119
|
+
export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockSettings, BlockStorageCollectionDeclaration, BlockStorageCollectionSchema, BlockStorageDeclaration, BlockStorageImport, BlockStorageIndexes, BlockStorageIndexType, 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';
|
|
120
120
|
/**
|
|
121
121
|
* Host bounds for an inline `customComfy` graph, mirrored from civitai/civitai —
|
|
122
122
|
* see `WorkflowBodyCustomComfyInline.workflow`.
|
package/dist/blocks/scopes.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare const BLOCK_SCOPES: {
|
|
|
22
22
|
readonly APPS_STORAGE_SHARED_WRITE: "apps:storage:shared:write";
|
|
23
23
|
readonly APPS_STORAGE: "apps:storage";
|
|
24
24
|
readonly APPS_STORAGE_PUBLISH: "apps:storage:publish";
|
|
25
|
+
readonly APPS_STORAGE_IMPORT: "apps:storage:import";
|
|
25
26
|
readonly COLLECTIONS_READ_SELF: "collections:read:self";
|
|
26
27
|
readonly COLLECTIONS_WRITE_SELF: "collections:write:self";
|
|
27
28
|
readonly COLLECTIONS_READ_PRIVATE: "collections:read:private";
|
package/dist/blocks/scopes.js
CHANGED
|
@@ -39,6 +39,11 @@ export const BLOCK_SCOPES = {
|
|
|
39
39
|
// civitai/civitai `src/shared/constants/block-scope.constants.ts`.
|
|
40
40
|
APPS_STORAGE: 'apps:storage',
|
|
41
41
|
APPS_STORAGE_PUBLISH: 'apps:storage:publish',
|
|
42
|
+
// apps:storage:import — reach ANOTHER app's collections as the viewer, through
|
|
43
|
+
// the manifest's `storage.imports` (civitai/civitai#7494; a fork reading its
|
|
44
|
+
// parent). SENSITIVE (needs a `scopeJustifications` entry) and CONSENT-GATED:
|
|
45
|
+
// the viewer's grant is recorded per (viewer, this app, source app).
|
|
46
|
+
APPS_STORAGE_IMPORT: 'apps:storage:import',
|
|
42
47
|
// collections:* — the App Blocks Collections surface. These have no OAuth bit
|
|
43
48
|
// (they never touch the user's civitai resources via the OAuth surface); the
|
|
44
49
|
// server gates them per-op server-side (collection visibility/ownership +
|
package/dist/blocks/types.d.ts
CHANGED
|
@@ -2690,6 +2690,61 @@ export interface BlockStorageIndexes {
|
|
|
2690
2690
|
createdAt?: never;
|
|
2691
2691
|
updatedAt?: never;
|
|
2692
2692
|
}
|
|
2693
|
+
/** A JSON type name a {@link BlockStorageCollectionSchema} can require. */
|
|
2694
|
+
export type BlockStorageSchemaType = 'object' | 'array' | 'string' | 'number' | 'integer' | 'boolean' | 'null';
|
|
2695
|
+
/**
|
|
2696
|
+
* A collection's DOCUMENT SCHEMA (civitai/civitai#7491): a JSON Schema SUBSET that every
|
|
2697
|
+
* document's `data` in the collection must match. Opt-in: without one, documents are not
|
|
2698
|
+
* checked. The server checks every create and put, and refuses a document that does not match
|
|
2699
|
+
* with 400 `schema_violation`. The refusal's message and `details.pointer` name the FIRST
|
|
2700
|
+
* failing JSON pointer into `data` (for example `/title`), and `details.keyword` names the
|
|
2701
|
+
* keyword it failed. Counters and marks are not checked. Changing a schema does not re-check
|
|
2702
|
+
* stored documents; each is checked the next time it is written.
|
|
2703
|
+
*
|
|
2704
|
+
* Only these keywords exist; any other is refused at submit by name. Semantics: a keyword for
|
|
2705
|
+
* another type is ignored (`minLength` on a number), `integer` is a number with no fraction,
|
|
2706
|
+
* lengths count code points, `pattern` is an UNANCHORED JavaScript regular expression with the
|
|
2707
|
+
* `u` flag, and `enum`/`const` compare JSON values. "First" is: `type`, `const`, `enum`, the
|
|
2708
|
+
* string, number and array keywords (`maxLength` before `pattern`), `items` element by element,
|
|
2709
|
+
* then `required` in declared order, then the object's own keys in ascending order.
|
|
2710
|
+
*
|
|
2711
|
+
* Bounds (the server's, refused at submit): at most 16 schemas nested in one another, 16384
|
|
2712
|
+
* bytes of JSON and 16 patterns per collection schema, and 32 patterns across all of the
|
|
2713
|
+
* manifest's collection schemas together; a `pattern` is at most 256 characters,
|
|
2714
|
+
* must compile, needs a `maxLength` of at most 1000 on the same schema, and must not backtrack
|
|
2715
|
+
* catastrophically; no `min*` above its `max*`. Not allowed on a `write: 'none'` collection,
|
|
2716
|
+
* which has no document bodies. Mirrors the canonical schema's
|
|
2717
|
+
* `$defs.storageCollectionSchema`.
|
|
2718
|
+
*/
|
|
2719
|
+
export interface BlockStorageCollectionSchema {
|
|
2720
|
+
/** One type, or a non-empty list of them without repeats. */
|
|
2721
|
+
type?: BlockStorageSchemaType | BlockStorageSchemaType[];
|
|
2722
|
+
/** Property name → the schema its value must match. */
|
|
2723
|
+
properties?: Record<string, BlockStorageCollectionSchema>;
|
|
2724
|
+
/** Property names that must be present (own keys), checked in this order. */
|
|
2725
|
+
required?: string[];
|
|
2726
|
+
/** `false` refuses undeclared keys; a schema checks their values; `true` (the default) allows them. */
|
|
2727
|
+
additionalProperties?: boolean | BlockStorageCollectionSchema;
|
|
2728
|
+
/** One schema every array element must match. */
|
|
2729
|
+
items?: BlockStorageCollectionSchema;
|
|
2730
|
+
/** The allowed JSON values (at least one). */
|
|
2731
|
+
enum?: unknown[];
|
|
2732
|
+
/** The one allowed JSON value. */
|
|
2733
|
+
const?: unknown;
|
|
2734
|
+
/** In code points. */
|
|
2735
|
+
minLength?: number;
|
|
2736
|
+
/** In code points. Required, at most 1000, on any schema that declares `pattern`. */
|
|
2737
|
+
maxLength?: number;
|
|
2738
|
+
/** A JavaScript regular expression (`u` flag), unanchored, at most 256 characters. */
|
|
2739
|
+
pattern?: string;
|
|
2740
|
+
/** Inclusive. */
|
|
2741
|
+
minimum?: number;
|
|
2742
|
+
/** Inclusive. */
|
|
2743
|
+
maximum?: number;
|
|
2744
|
+
minItems?: number;
|
|
2745
|
+
maxItems?: number;
|
|
2746
|
+
description?: string;
|
|
2747
|
+
}
|
|
2693
2748
|
/**
|
|
2694
2749
|
* A PRIVATE collection — a separate key space per viewer, read and written
|
|
2695
2750
|
* only by that viewer. Carries none of the shared-only fields (`write`,
|
|
@@ -2709,6 +2764,10 @@ export interface BlockStoragePrivateCollectionDeclaration {
|
|
|
2709
2764
|
ttlSeconds?: number;
|
|
2710
2765
|
/** RESERVED — see {@link BlockStorageSharedCollectionDeclaration.maxEntries}. */
|
|
2711
2766
|
maxEntries?: number;
|
|
2767
|
+
/** See {@link BlockStorageSharedCollectionDeclaration.exportable}. */
|
|
2768
|
+
exportable?: boolean;
|
|
2769
|
+
/** See {@link BlockStorageCollectionSchema}. */
|
|
2770
|
+
schema?: BlockStorageCollectionSchema;
|
|
2712
2771
|
}
|
|
2713
2772
|
/**
|
|
2714
2773
|
* A SHARED collection — one key space for the whole app, read by every viewer
|
|
@@ -2803,6 +2862,17 @@ export interface BlockStorageSharedCollectionDeclaration {
|
|
|
2803
2862
|
* model later changes hands or is deleted.
|
|
2804
2863
|
*/
|
|
2805
2864
|
ownedModelVersions?: string[];
|
|
2865
|
+
/**
|
|
2866
|
+
* Whether OTHER apps may reach this collection through their `storage.imports`,
|
|
2867
|
+
* with the viewer's consent (see {@link BlockStorageImport}). Default `true`;
|
|
2868
|
+
* `false` refuses every import of it with 403 `not_exportable`.
|
|
2869
|
+
*/
|
|
2870
|
+
exportable?: boolean;
|
|
2871
|
+
/**
|
|
2872
|
+
* The schema every document's `data` must match — see {@link BlockStorageCollectionSchema}.
|
|
2873
|
+
* Not allowed with `write` `'none'` (no document bodies are written there).
|
|
2874
|
+
*/
|
|
2875
|
+
schema?: BlockStorageCollectionSchema;
|
|
2806
2876
|
}
|
|
2807
2877
|
/**
|
|
2808
2878
|
* One collection declaration — see {@link BlockManifestV1.storage}.
|
|
@@ -2811,9 +2881,44 @@ export interface BlockStorageSharedCollectionDeclaration {
|
|
|
2811
2881
|
* canonical schema's `storage.collections.*`.
|
|
2812
2882
|
*/
|
|
2813
2883
|
export type BlockStorageCollectionDeclaration = BlockStoragePrivateCollectionDeclaration | BlockStorageSharedCollectionDeclaration;
|
|
2884
|
+
/**
|
|
2885
|
+
* One entry of the manifest's `storage.imports` (civitai/civitai#7494): collections of
|
|
2886
|
+
* ANOTHER app this app reaches as the viewer — for example a fork reading and writing its
|
|
2887
|
+
* parent's data. The SDK reaches one with `app.storage.collection(name, { from })`.
|
|
2888
|
+
*
|
|
2889
|
+
* Through an import the app acts AS THE VIEWER IN THE SOURCE APP: a private collection
|
|
2890
|
+
* gives that viewer's own documents, a shared one reads as the source shows it to them,
|
|
2891
|
+
* writes follow the source collection's write policy and schema, and usage counts against
|
|
2892
|
+
* the source app's ceilings. Nothing is reached until the viewer grants it: declaring any
|
|
2893
|
+
* import requires the sensitive, consent-gated `apps:storage:import` scope with a
|
|
2894
|
+
* `scopeJustifications` entry (and `apps:storage`), and the viewer's consent is recorded
|
|
2895
|
+
* per (viewer, this app, source app). A source collection declared `exportable: false`
|
|
2896
|
+
* refuses every import.
|
|
2897
|
+
*
|
|
2898
|
+
* Limits (the canonical's): at most 8 imports, one per source, never this app itself.
|
|
2899
|
+
*/
|
|
2900
|
+
export interface BlockStorageImport {
|
|
2901
|
+
/** The source app's blockId (`^[a-z][a-z0-9-]{1,38}[a-z0-9]$`, 3 to 40 characters). */
|
|
2902
|
+
from: string;
|
|
2903
|
+
/** 1 to 16 distinct names of collections the source declares. */
|
|
2904
|
+
collections: string[];
|
|
2905
|
+
/**
|
|
2906
|
+
* `'read'`: reads only; every write, counter and mark is refused (`write_policy`).
|
|
2907
|
+
* `'readwrite'`: also writes, under the source collection's own write policy. A write,
|
|
2908
|
+
* counter or mark in one of the source's SHARED collections also needs the viewer's own
|
|
2909
|
+
* `apps:storage:publish` grant IN THE SOURCE APP; a private collection needs only the
|
|
2910
|
+
* import grant.
|
|
2911
|
+
*/
|
|
2912
|
+
access: 'read' | 'readwrite';
|
|
2913
|
+
}
|
|
2814
2914
|
/**
|
|
2815
2915
|
* The manifest's `storage` object — see {@link BlockManifestV1.storage}.
|
|
2816
2916
|
* Mirrors the canonical schema's `storage`; no other key is allowed.
|
|
2917
|
+
*
|
|
2918
|
+
* It declares `collections` (this app's own), `imports` (other apps'), or both.
|
|
2919
|
+
* AT LEAST ONE is required, which this type does not express: each is optional
|
|
2920
|
+
* here, and the canonical schema (so `defineBlock`) refuses a `storage` with
|
|
2921
|
+
* neither.
|
|
2817
2922
|
*/
|
|
2818
2923
|
export interface BlockStorageDeclaration {
|
|
2819
2924
|
/**
|
|
@@ -2823,7 +2928,9 @@ export interface BlockStorageDeclaration {
|
|
|
2823
2928
|
* its visibility, is a NEW collection: the old one's documents are not
|
|
2824
2929
|
* carried over.
|
|
2825
2930
|
*/
|
|
2826
|
-
collections
|
|
2931
|
+
collections?: Record<string, BlockStorageCollectionDeclaration>;
|
|
2932
|
+
/** Other apps' collections this app reaches as the viewer, 1 to 8 entries. See {@link BlockStorageImport}. */
|
|
2933
|
+
imports?: BlockStorageImport[];
|
|
2827
2934
|
}
|
|
2828
2935
|
/**
|
|
2829
2936
|
* One entry of a manifest's `goods[]`. Mirrors the canonical schema exactly;
|
|
@@ -2972,8 +3079,11 @@ export interface BlockManifestV1 {
|
|
|
2972
3079
|
* Declaring any collection requires the `apps:storage` scope; a shared
|
|
2973
3080
|
* collection viewers write (`write` `'own'` or `'anyone'`) also requires the
|
|
2974
3081
|
* sensitive, consent-gated `apps:storage:publish` scope with a
|
|
2975
|
-
* `scopeJustifications` entry;
|
|
2976
|
-
*
|
|
3082
|
+
* `scopeJustifications` entry; declaring any `imports` (another app's
|
|
3083
|
+
* collections, see {@link BlockStorageImport}) requires the sensitive,
|
|
3084
|
+
* consent-gated `apps:storage:import` scope with a `scopeJustifications`
|
|
3085
|
+
* entry; and requesting any of these scopes with nothing here for it to
|
|
3086
|
+
* reach is rejected. Those couplings, and the RESERVED features
|
|
2977
3087
|
* (`kind: 'log'`, `ttlSeconds`, `dailyWritesPerAuthor`, `write` `'anyone'` /
|
|
2978
3088
|
* `'owner'`), are enforced by the platform's manifest validator at submit,
|
|
2979
3089
|
* not by `defineBlock` — see `KNOWN_GAPS['storage-server-only-rules']`.
|
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
|
+
* 211 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 211 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
|
+
* 211 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 211 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
|
|
@@ -97,6 +97,7 @@ export declare const KNOWN_GAPS: {
|
|
|
97
97
|
readonly 'slotId-registry': string;
|
|
98
98
|
readonly 'settings-meta-schema-not-vendored': string;
|
|
99
99
|
readonly 'storage-server-only-rules': string;
|
|
100
|
+
readonly 'storage-collection-schema-server-only-rules': string;
|
|
100
101
|
readonly 'format-uri-not-enforced': string;
|
|
101
102
|
};
|
|
102
103
|
/** The canonical schema object, parsed once. Exported for tests and tooling. */
|
|
@@ -145,11 +145,21 @@ export const KNOWN_GAPS = {
|
|
|
145
145
|
'See SCHEMA_DIVERGENCES.settings.',
|
|
146
146
|
'storage-server-only-rules': 'The canonical `storage` description states rules it does not encode: declaring any ' +
|
|
147
147
|
'collection requires the `apps:storage` scope, a shared collection viewers write (`write` ' +
|
|
148
|
-
'"own" or "anyone") also requires `apps:storage:publish`,
|
|
149
|
-
'
|
|
148
|
+
'"own" or "anyone") also requires `apps:storage:publish`, declaring `imports` requires ' +
|
|
149
|
+
'`apps:storage:import` (and `apps:storage`), requesting any of these scopes with nothing for ' +
|
|
150
|
+
'it to reach is rejected, an import never names this app itself and names each source at ' +
|
|
151
|
+
'most once, a counter may not share a name with a mark, and the ' +
|
|
150
152
|
'RESERVED features (`kind` "log", `ttlSeconds`, `dailyWritesPerAuthor`, `write` "anyone" / ' +
|
|
151
153
|
'"owner") validate offline and are refused at submit. Ajv enforces the structural rules ' +
|
|
152
154
|
'exactly; these are server-side.',
|
|
155
|
+
'storage-collection-schema-server-only-rules': 'A collection `schema` (civitai/civitai#7491): the canonical encodes the keyword subset, each ' +
|
|
156
|
+
'keyword\'s shape, the 256-character `pattern` bound, "a pattern needs a maxLength of at most ' +
|
|
157
|
+
'1000" and "no schema on write none", and Ajv enforces those exactly. It states in prose only ' +
|
|
158
|
+
'the bounds the server checks at submit: at most 16384 bytes of JSON, 16 nested schemas and ' +
|
|
159
|
+
'16 patterns per collection schema, 32 patterns across the whole manifest, no min above ' +
|
|
160
|
+
'its max, a pattern that compiles as a JavaScript regular expression with the `u` flag, ' +
|
|
161
|
+
'and no pattern that can backtrack ' +
|
|
162
|
+
'catastrophically. Those validate here and are refused at submit.',
|
|
153
163
|
'format-uri-not-enforced': '`assetBundleUrl` carries `format: "uri"` in addition to `pattern: "^https://"`. Ajv ignores ' +
|
|
154
164
|
'unknown formats unless `ajv-formats` is installed, which would be a second optional peer for ' +
|
|
155
165
|
'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, BlockStorageDeclaration, BlockStorageIndexes, BlockStorageIndexType, BlockStoragePrivateCollectionDeclaration, BlockStorageSharedCollectionDeclaration, } from '../blocks/types.js';
|
|
18
|
+
export type { BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockStorageCollectionDeclaration, BlockStorageCollectionSchema, BlockStorageDeclaration, BlockStorageImport, BlockStorageIndexes, BlockStorageIndexType, BlockStoragePrivateCollectionDeclaration, BlockStorageSchemaType, BlockStorageSharedCollectionDeclaration, } from '../blocks/types.js';
|
|
19
19
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -55,15 +55,7 @@
|
|
|
55
55
|
"category": {
|
|
56
56
|
"type": "string",
|
|
57
57
|
"description": "Optional marketplace category for the app's `/apps` store listing. When present it flows to the listing automatically on moderator-approve (only when a moderator has not already curated a category). Omit to let a moderator categorise the app. Must be one of the known marketplace categories — this enum is kept in lockstep with MARKETPLACE_CATEGORIES in src/server/services/blocks/marketplace-categories.constants.ts (a drift-guard test enforces equality).",
|
|
58
|
-
"enum": [
|
|
59
|
-
"generation",
|
|
60
|
-
"games",
|
|
61
|
-
"utility",
|
|
62
|
-
"discovery",
|
|
63
|
-
"moderation",
|
|
64
|
-
"analytics",
|
|
65
|
-
"other"
|
|
66
|
-
]
|
|
58
|
+
"enum": ["generation", "games", "utility", "discovery", "moderation", "analytics", "other"]
|
|
67
59
|
},
|
|
68
60
|
"renderMode": {
|
|
69
61
|
"type": "string",
|
|
@@ -98,6 +90,7 @@
|
|
|
98
90
|
"apps:storage:shared:write",
|
|
99
91
|
"apps:storage",
|
|
100
92
|
"apps:storage:publish",
|
|
93
|
+
"apps:storage:import",
|
|
101
94
|
"collections:read:self",
|
|
102
95
|
"collections:write:self",
|
|
103
96
|
"collections:read:private",
|
|
@@ -111,7 +104,7 @@
|
|
|
111
104
|
},
|
|
112
105
|
"scopeJustifications": {
|
|
113
106
|
"type": "object",
|
|
114
|
-
"description": "Per-scope justification: a map of scope-id → free-text rationale explaining WHY the app needs that permission, shown to the moderator during review. REQUIRED for SENSITIVE scopes — any declared scope that can spend or read the viewer's Buzz, read the viewer's private data, or write data other users see (e.g. `ai:write:budgeted`, `social:tip:self`, `goods:purchase:self`, `buzz:read:self`, `collections:read:private`, `apps:storage:shared:write`, `apps:storage:publish`, `posts:write:self`, `apps:store:items:write`, `social:react:self`) MUST carry a non-empty justification here, or the manifest is rejected at submit time. OPTIONAL for non-sensitive scopes — omit those and the manifest stays valid. Every key MUST be a scope also present in `scopes` (justifications for scopes you don't request are rejected). Each value is a non-empty string of at most 500 characters. The requirement is enforced imperatively by the manifest validator (not expressed as JSON-Schema conditionals here). NOTE: the justification captures the developer's STATED rationale only; the platform does not verify the truth of the claims.",
|
|
107
|
+
"description": "Per-scope justification: a map of scope-id → free-text rationale explaining WHY the app needs that permission, shown to the moderator during review. REQUIRED for SENSITIVE scopes — any declared scope that can spend or read the viewer's Buzz, read the viewer's private data, or write data other users see (e.g. `ai:write:budgeted`, `social:tip:self`, `goods:purchase:self`, `buzz:read:self`, `collections:read:private`, `apps:storage:shared:write`, `apps:storage:publish`, `apps:storage:import`, `posts:write:self`, `apps:store:items:write`, `social:react:self`) MUST carry a non-empty justification here, or the manifest is rejected at submit time. OPTIONAL for non-sensitive scopes — omit those and the manifest stays valid. Every key MUST be a scope also present in `scopes` (justifications for scopes you don't request are rejected). Each value is a non-empty string of at most 500 characters. The requirement is enforced imperatively by the manifest validator (not expressed as JSON-Schema conditionals here). NOTE: the justification captures the developer's STATED rationale only; the platform does not verify the truth of the claims.",
|
|
115
108
|
"additionalProperties": {
|
|
116
109
|
"type": "string",
|
|
117
110
|
"minLength": 1,
|
|
@@ -137,7 +130,10 @@
|
|
|
137
130
|
"maxLength": 256,
|
|
138
131
|
"allOf": [
|
|
139
132
|
{ "$comment": "no leading '/' (absolute path)", "not": { "pattern": "^/" } },
|
|
140
|
-
{
|
|
133
|
+
{
|
|
134
|
+
"$comment": "no backslash separators (Windows / '\\..' traversal)",
|
|
135
|
+
"not": { "pattern": "\\\\" }
|
|
136
|
+
},
|
|
141
137
|
{ "$comment": "no '..' path-traversal segment", "not": { "pattern": "(^|/)\\.\\.(/|$)" } },
|
|
142
138
|
{ "$comment": "no Windows drive prefix (e.g. C:)", "not": { "pattern": "^[A-Za-z]:" } }
|
|
143
139
|
]
|
|
@@ -378,10 +374,43 @@
|
|
|
378
374
|
},
|
|
379
375
|
"storage": {
|
|
380
376
|
"type": "object",
|
|
381
|
-
"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; and requesting
|
|
377
|
+
"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\" and `write` \"owner\" 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.",
|
|
382
378
|
"additionalProperties": false,
|
|
383
|
-
"required": ["collections"],
|
|
379
|
+
"anyOf": [{ "required": ["collections"] }, { "required": ["imports"] }],
|
|
384
380
|
"properties": {
|
|
381
|
+
"imports": {
|
|
382
|
+
"type": "array",
|
|
383
|
+
"description": "Collections of OTHER apps this app reaches as the viewer — for example a fork reading and writing its parent's data. Each import names the source app by its `blockId`, 1 to 16 distinct collection names the source declares, and the access wanted: \"read\" or \"readwrite\". At most 8 imports, one per source app, never this app itself. Through an import the app acts AS THE VIEWER IN THE SOURCE APP: a private collection gives that viewer's own documents, a shared one reads as the source shows it to them, writes follow the source collection's write policy, and usage counts against the source app's ceilings. Nothing is reached until the viewer grants it: the `apps:storage:import` consent is recorded per (viewer, this app, source app) and can be withdrawn under Apps → Permissions. A source collection with `exportable: false` refuses every import. The SDK reaches one with `app.storage.collection(name, { from: blockId })`.",
|
|
384
|
+
"minItems": 1,
|
|
385
|
+
"maxItems": 8,
|
|
386
|
+
"items": {
|
|
387
|
+
"type": "object",
|
|
388
|
+
"additionalProperties": false,
|
|
389
|
+
"required": ["from", "collections", "access"],
|
|
390
|
+
"properties": {
|
|
391
|
+
"from": {
|
|
392
|
+
"type": "string",
|
|
393
|
+
"description": "The source app's blockId (its slug).",
|
|
394
|
+
"minLength": 3,
|
|
395
|
+
"maxLength": 40,
|
|
396
|
+
"pattern": "^[a-z][a-z0-9-]{1,38}[a-z0-9]$"
|
|
397
|
+
},
|
|
398
|
+
"collections": {
|
|
399
|
+
"type": "array",
|
|
400
|
+
"description": "Names of the source app's collections this import reaches.",
|
|
401
|
+
"minItems": 1,
|
|
402
|
+
"maxItems": 16,
|
|
403
|
+
"uniqueItems": true,
|
|
404
|
+
"items": { "type": "string", "pattern": "^[a-z][a-z0-9_]{0,31}$" }
|
|
405
|
+
},
|
|
406
|
+
"access": {
|
|
407
|
+
"type": "string",
|
|
408
|
+
"description": "\"read\": reads only; every write is refused. \"readwrite\": reads and writes, under the source collection's own write policy. A create, update, counter, mark or unmark in one of the source's SHARED collections also needs the viewer's own `apps:storage:publish` grant in the source app, which the app asks the host to prompt for; a document delete, and any write to a private collection, needs only the import grant.",
|
|
409
|
+
"enum": ["read", "readwrite"]
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
},
|
|
385
414
|
"collections": {
|
|
386
415
|
"type": "object",
|
|
387
416
|
"description": "Map of collection name → declaration. At least 1 and at most 16 collections. A collection name is lowercase snake_case: a letter, then up to 31 of a-z, 0-9 or _. Renaming a collection, or changing its visibility, is a NEW collection: the old one's documents are not carried over.",
|
|
@@ -470,6 +499,10 @@
|
|
|
470
499
|
"minimum": 1,
|
|
471
500
|
"maximum": 1000
|
|
472
501
|
},
|
|
502
|
+
"exportable": {
|
|
503
|
+
"type": "boolean",
|
|
504
|
+
"description": "Whether other apps may reach this collection through their `storage.imports` (with the viewer's consent). Default true; false refuses every import of it with 403 `not_exportable`."
|
|
505
|
+
},
|
|
473
506
|
"ownedModelVersions": {
|
|
474
507
|
"type": "array",
|
|
475
508
|
"description": "Shared collections with `write` \"own\" only. Fields of a document's `data` that, when present, must hold a Civitai model version id owned by the viewer writing the document — for example [\"/workflow/modelVersionId\"] for a collection where viewers publish their own workflows. Each entry is a pointer of 1 to 4 segments, each \"/\" then a letter or _ followed by up to 63 letters, digits or _; 1 to 4 distinct pointers. A pointer names one field of nested objects: it never indexes into an array, and a step through an array or any other non-object finds nothing. On every create and update the server resolves each pointer in the new `data`: a field that is absent is allowed; a field that is present must be a positive integer naming a model version whose model the writer owns, and is otherwise refused with 403 `resource_not_owned` — a version that is someone else's, missing or deleted, and a value that is not a positive integer, are all refused the same way. The check runs before moderation and before any write budget is spent. Ownership is checked when a document is written, not afterwards: if the model later changes hands or is deleted, documents already stored keep the id.",
|
|
@@ -480,9 +513,21 @@
|
|
|
480
513
|
"type": "string",
|
|
481
514
|
"pattern": "^(/[A-Za-z_][A-Za-z0-9_]{0,63}){1,4}$"
|
|
482
515
|
}
|
|
516
|
+
},
|
|
517
|
+
"schema": {
|
|
518
|
+
"description": "Optional. A JSON Schema SUBSET that every document's `data` in this collection must match. The server checks it on every create and update and refuses a document that does not match with 400 `schema_violation`, whose message names the first failing JSON pointer into `data` (for example \"/title\"); counters and marks are not checked. Without a schema, documents are not checked. Supported keywords only: type (object, array, string, number, integer, boolean, null, or an array of them), properties, required, additionalProperties (true, false or a schema), items (one schema for every element), enum, const, minLength, maxLength, pattern, minimum, maximum, minItems, maxItems and description; any other keyword is refused at submit with a message naming it. Keywords that do not apply to a value's type are ignored; string lengths count code points; `pattern` is a JavaScript regular expression (the \"u\" flag), unanchored, of at most 256 characters, and a schema with a `pattern` must also declare a `maxLength` of at most 1000; a pattern that can backtrack catastrophically (analysed with the \"u\" flag, as the store runs it) is refused at submit. At most 16 patterns per schema and 32 across all of the manifest's collection schemas together, schemas nested at most 16 deep, and at most 16384 bytes of JSON. Not allowed on a `write` \"none\" collection. Changing a schema does not re-check documents already stored; they are checked when next written.",
|
|
519
|
+
"$ref": "#/$defs/storageCollectionSchema"
|
|
483
520
|
}
|
|
484
521
|
},
|
|
485
522
|
"allOf": [
|
|
523
|
+
{
|
|
524
|
+
"$comment": "No document body is ever written in a write:\"none\" collection, so a schema there would check nothing.",
|
|
525
|
+
"if": {
|
|
526
|
+
"required": ["write"],
|
|
527
|
+
"properties": { "write": { "const": "none" } }
|
|
528
|
+
},
|
|
529
|
+
"then": { "properties": { "schema": false } }
|
|
530
|
+
},
|
|
486
531
|
{
|
|
487
532
|
"$comment": "A shared collection must state its write policy; a private one carries none of the shared-only fields.",
|
|
488
533
|
"if": {
|
|
@@ -560,6 +605,50 @@
|
|
|
560
605
|
}
|
|
561
606
|
}
|
|
562
607
|
},
|
|
608
|
+
"$defs": {
|
|
609
|
+
"storageCollectionSchema": {
|
|
610
|
+
"type": "object",
|
|
611
|
+
"description": "One schema of the storage collection-schema subset (see `storage.collections.<name>.schema`). Depth, size, pattern-count and min-greater-than-max limits, and whether a pattern compiles, are checked by the server, not by this schema.",
|
|
612
|
+
"additionalProperties": false,
|
|
613
|
+
"properties": {
|
|
614
|
+
"type": {
|
|
615
|
+
"anyOf": [
|
|
616
|
+
{ "$ref": "#/$defs/storageCollectionSchemaType" },
|
|
617
|
+
{
|
|
618
|
+
"type": "array",
|
|
619
|
+
"minItems": 1,
|
|
620
|
+
"uniqueItems": true,
|
|
621
|
+
"items": { "$ref": "#/$defs/storageCollectionSchemaType" }
|
|
622
|
+
}
|
|
623
|
+
]
|
|
624
|
+
},
|
|
625
|
+
"properties": {
|
|
626
|
+
"type": "object",
|
|
627
|
+
"additionalProperties": { "$ref": "#/$defs/storageCollectionSchema" }
|
|
628
|
+
},
|
|
629
|
+
"required": { "type": "array", "uniqueItems": true, "items": { "type": "string" } },
|
|
630
|
+
"additionalProperties": {
|
|
631
|
+
"anyOf": [{ "type": "boolean" }, { "$ref": "#/$defs/storageCollectionSchema" }]
|
|
632
|
+
},
|
|
633
|
+
"items": { "$ref": "#/$defs/storageCollectionSchema" },
|
|
634
|
+
"enum": { "type": "array", "minItems": 1 },
|
|
635
|
+
"const": {},
|
|
636
|
+
"minLength": { "type": "integer", "minimum": 0 },
|
|
637
|
+
"maxLength": { "type": "integer", "minimum": 0 },
|
|
638
|
+
"pattern": { "type": "string", "maxLength": 256 },
|
|
639
|
+
"minimum": { "type": "number" },
|
|
640
|
+
"maximum": { "type": "number" },
|
|
641
|
+
"minItems": { "type": "integer", "minimum": 0 },
|
|
642
|
+
"maxItems": { "type": "integer", "minimum": 0 },
|
|
643
|
+
"description": { "type": "string" }
|
|
644
|
+
},
|
|
645
|
+
"if": { "required": ["pattern"] },
|
|
646
|
+
"then": { "required": ["maxLength"], "properties": { "maxLength": { "maximum": 1000 } } }
|
|
647
|
+
},
|
|
648
|
+
"storageCollectionSchemaType": {
|
|
649
|
+
"enum": ["object", "array", "string", "number", "integer", "boolean", "null"]
|
|
650
|
+
}
|
|
651
|
+
},
|
|
563
652
|
"allOf": [
|
|
564
653
|
{
|
|
565
654
|
"$comment": "outputDir is required whenever buildCommand is set. NOTE: the server-owned iframe.src and trustTier fields are rejected by the platform validator (and the CLI in Go) with clearer error messages than JSON Schema's `not`; they are declared in `properties` above only so the schema documents them.",
|