@civitai/app-sdk 0.97.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.
@@ -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, 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';
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`.
@@ -3525,6 +3525,29 @@ export interface BlockStorageCollectionHook {
3525
3525
  /** The most milliseconds one call may take: an integer from 1 to 500. Omitted means 50. */
3526
3526
  timeoutMs?: number;
3527
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
+ }
3528
3551
  /**
3529
3552
  * A PRIVATE collection — a separate key space per viewer, read and written
3530
3553
  * only by that viewer. Carries none of the shared-only fields (`write`,
@@ -3552,6 +3575,13 @@ export interface BlockStoragePrivateCollectionDeclaration {
3552
3575
  migrations?: BlockStorageMigrationOp[];
3553
3576
  /** Limited rollout — see {@link BlockStorageSharedCollectionDeclaration.hook}. */
3554
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;
3555
3585
  }
3556
3586
  /**
3557
3587
  * A SHARED collection — one key space for the whole app, read by every viewer
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
- * 246 symbols and that side effect into the root would make every OAuth app
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 246 is ASSERTED, not merely quoted — by
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
- * 246 symbols and that side effect into the root would make every OAuth app
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 246 is ASSERTED, not merely quoted — by
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 ' +
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@civitai/app-sdk",
3
- "version": "0.97.0",
3
+ "version": "0.98.0",
4
4
  "description": "OAuth + PKCE, encrypted-cookie sessions, scopes, and orchestrator helpers for building third-party Civitai apps.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -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\" 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.",
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": [