@civitai/app-sdk 0.83.0 → 0.84.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.
@@ -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, BlockStorageCollectionSchema, BlockStorageDeclaration, BlockStorageImport, BlockStorageIndexes, BlockStorageIndexType, BlockStorageMigrationKeyword, BlockStorageMigrationOp, BlockStoragePrivateCollectionDeclaration, BlockStorageSchemaType, BlockStorageSharedCollectionDeclaration, BlockToken, ContentRating, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPage, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockTextToImageParams, BlockWorkflowSnapshot, BlockEstimateBatchAggregate, BlockModelSubstitution, ModelSubstitutionReason, KnownBlockWorkflowErrorCode, BlockStepToolCall, BlockTrainedEpoch, BlockPublishedModel, BuzzAccountType, ShowcaseImage, WorkflowBody, WorkflowBodyTextToImage, WorkflowBodyCustomComfy, WorkflowBodyCustomComfyRecipe, WorkflowBodyCustomComfyInline, InlineComfyNode, WorkflowBodyStep, WorkflowBodyPassThroughStep, WorkflowBodyWorkflow, WorkflowBodyWorkflowStep, WorkflowStepRef, WithWorkflowStepRefs, BlockWorkflowStepSnapshot, WorkflowStatus, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, BlockResourceFile, BlockResourceFileEntry, BlockResourceFileEntryFormat, BlockResourceFileErrorCode, BlockResourceFileMeta, AppWorkflow, AppWorkflowImage, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostRequest, BlockCreatePostResult, BlockCreatePostHostError, WorkflowBodyTraining, AiToolkitTrainingParams, AiToolkitTrainingParamsBase, AiToolkitPlainEcosystem, AiToolkitLrScheduler, AiToolkitOptimizerType, BlockTrainingQuote, BlockTrainingDatasetItem, BlockTrainingDataImage, BlockTrainingDataUploadResult, BlockRunTrainingHostError, BlockStepQuote, BlockModel3dOutput, BlockRunConfirmedStepHostError, } from './types.js';
119
+ export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockSettings, BlockStorageCollectionDeclaration, BlockStorageCollectionHook, BlockStorageCollectionSchema, BlockStorageDeclaration, BlockStorageImport, BlockStorageIndexes, BlockStorageIndexType, BlockStorageMigrationKeyword, BlockStorageMigrationOp, BlockStoragePrivateCollectionDeclaration, BlockStorageSchemaType, BlockStorageSharedCollectionDeclaration, BlockToken, ContentRating, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPage, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockTextToImageParams, BlockWorkflowSnapshot, BlockEstimateBatchAggregate, BlockModelSubstitution, ModelSubstitutionReason, KnownBlockWorkflowErrorCode, BlockStepToolCall, BlockTrainedEpoch, BlockPublishedModel, BuzzAccountType, ShowcaseImage, WorkflowBody, WorkflowBodyTextToImage, WorkflowBodyCustomComfy, WorkflowBodyCustomComfyRecipe, WorkflowBodyCustomComfyInline, InlineComfyNode, WorkflowBodyStep, WorkflowBodyPassThroughStep, WorkflowBodyWorkflow, WorkflowBodyWorkflowStep, WorkflowStepRef, WithWorkflowStepRefs, BlockWorkflowStepSnapshot, WorkflowStatus, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, BlockResourceFile, BlockResourceFileEntry, BlockResourceFileEntryFormat, BlockResourceFileErrorCode, BlockResourceFileMeta, AppWorkflow, AppWorkflowImage, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostRequest, BlockCreatePostResult, BlockCreatePostHostError, WorkflowBodyTraining, AiToolkitTrainingParams, AiToolkitTrainingParamsBase, AiToolkitPlainEcosystem, AiToolkitLrScheduler, AiToolkitOptimizerType, BlockTrainingQuote, BlockTrainingDatasetItem, BlockTrainingDataImage, BlockTrainingDataUploadResult, BlockRunTrainingHostError, BlockStepQuote, BlockModel3dOutput, BlockRunConfirmedStepHostError, } from './types.js';
120
120
  /**
121
121
  * Host bounds for an inline `customComfy` graph, mirrored from civitai/civitai —
122
122
  * see `WorkflowBodyCustomComfyInline.workflow`.
@@ -2793,6 +2793,39 @@ export type BlockStorageMigrationOp = {
2793
2793
  path: string;
2794
2794
  keyword: BlockStorageMigrationKeyword;
2795
2795
  };
2796
+ /**
2797
+ * RESERVED — civitai.com refuses this field until permission hooks are enabled,
2798
+ * so do not declare it yet. A collection's permission hook: one ES module of the
2799
+ * bundle whose default export decides, for every write to the collection,
2800
+ * whether the write is allowed. It runs after the collection `schema` check,
2801
+ * never instead of it. Mirrors the canonical schema's
2802
+ * `$defs.storageCollectionHook`; this package adds no hook behaviour.
2803
+ *
2804
+ * Checked by the server, not by the schema: whether `file` is inside
2805
+ * `outputDir`, whether it exists in the bundle with this `sha256`, its size (one
2806
+ * self-contained module with no imports, at most 65536 bytes of UTF-8 text),
2807
+ * and two collections pinning one file with different digests.
2808
+ */
2809
+ export interface BlockStorageCollectionHook {
2810
+ /**
2811
+ * The hook's relative path in the submitted bundle, shipped verbatim (a
2812
+ * committed source file, not a build output): `/`-separated segments, each
2813
+ * starting with a letter, digit, `_` or `-` and then letters, digits, `_`, `.`
2814
+ * or `-` (so no `.` or `..` segment, no hidden file, no leading `/`), ending
2815
+ * `.js` or `.mjs`, at most 200 characters, with no `node_modules` segment.
2816
+ * Pattern `^([A-Za-z0-9_-][A-Za-z0-9_.-]*\/)*[A-Za-z0-9_-][A-Za-z0-9_.-]*\.m?js$`.
2817
+ */
2818
+ file: string;
2819
+ /**
2820
+ * The SHA-256 of the file's bytes as 64 lowercase hex characters
2821
+ * (`^[0-9a-f]{64}$`). Submit, the git-push path and approve each refuse a
2822
+ * version whose file is missing or does not match it. One file used by several
2823
+ * collections must be pinned with the same digest in each.
2824
+ */
2825
+ sha256: string;
2826
+ /** The most milliseconds one call may take: an integer from 1 to 500. Omitted means 50. */
2827
+ timeoutMs?: number;
2828
+ }
2796
2829
  /**
2797
2830
  * A PRIVATE collection — a separate key space per viewer, read and written
2798
2831
  * only by that viewer. Carries none of the shared-only fields (`write`,
@@ -2818,6 +2851,8 @@ export interface BlockStoragePrivateCollectionDeclaration {
2818
2851
  schema?: BlockStorageCollectionSchema;
2819
2852
  /** See {@link BlockStorageSharedCollectionDeclaration.migrations}. */
2820
2853
  migrations?: BlockStorageMigrationOp[];
2854
+ /** RESERVED — see {@link BlockStorageSharedCollectionDeclaration.hook}. */
2855
+ hook?: BlockStorageCollectionHook;
2821
2856
  }
2822
2857
  /**
2823
2858
  * A SHARED collection — one key space for the whole app, read by every viewer
@@ -2939,6 +2974,14 @@ export interface BlockStorageSharedCollectionDeclaration {
2939
2974
  * {@link BlockStorageMigrationOp}. Not allowed with `write` `'none'`.
2940
2975
  */
2941
2976
  migrations?: BlockStorageMigrationOp[];
2977
+ /**
2978
+ * RESERVED — civitai.com refuses this field until permission hooks are
2979
+ * enabled, so do not declare it yet. A permission hook that decides, for every
2980
+ * write to this collection, whether it is allowed — see
2981
+ * {@link BlockStorageCollectionHook}. Allowed on every collection kind,
2982
+ * private and shared alike.
2983
+ */
2984
+ hook?: BlockStorageCollectionHook;
2942
2985
  }
2943
2986
  /**
2944
2987
  * One collection declaration — see {@link BlockManifestV1.storage}.
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
- * 213 symbols and that side effect into the root would make every OAuth app
28
+ * 214 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 213 is ASSERTED, not merely quoted — by
32
+ * 🔴 That 214 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
- * 213 symbols and that side effect into the root would make every OAuth app
28
+ * 214 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 213 is ASSERTED, not merely quoted — by
32
+ * 🔴 That 214 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
@@ -149,9 +149,11 @@ export const KNOWN_GAPS = {
149
149
  '`apps:storage:import` (and `apps:storage`), requesting any of these scopes with nothing for ' +
150
150
  'it to reach is rejected, an import never names this app itself and names each source at ' +
151
151
  'most once, a counter may not share a name with a mark, and the ' +
152
- 'RESERVED features (`kind` "log", `ttlSeconds`, `dailyWritesPerAuthor`, `registry`, `write` ' +
153
- '"anyone" / "owner") validate offline and are refused at submit. Ajv enforces the structural rules ' +
154
- 'exactly; these are server-side.',
152
+ 'RESERVED features (`kind` "log", `ttlSeconds`, `dailyWritesPerAuthor`, `registry`, `hook`, ' +
153
+ '`write` "anyone" / "owner") validate offline and are refused at submit. A `hook`\'s `file` ' +
154
+ 'being outside `outputDir`, present in the bundle with its `sha256`, its size, and one file ' +
155
+ 'pinned with one digest across collections are checked by the server too. Ajv enforces the ' +
156
+ 'structural rules exactly; these are server-side.',
155
157
  'storage-collection-schema-server-only-rules': 'A collection `schema` (civitai/civitai#7491): the canonical encodes the keyword subset, each ' +
156
158
  'keyword\'s shape, the 256-character `pattern` bound, "a pattern needs a maxLength of at most ' +
157
159
  '1000" and "no schema on write none", and Ajv enforces those exactly. It states in prose only ' +
@@ -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, BlockStorageCollectionSchema, BlockStorageDeclaration, BlockStorageImport, BlockStorageIndexes, BlockStorageIndexType, BlockStorageMigrationKeyword, BlockStorageMigrationOp, BlockStoragePrivateCollectionDeclaration, BlockStorageSchemaType, BlockStorageSharedCollectionDeclaration, } from '../blocks/types.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';
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.83.0",
3
+ "version": "0.84.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",
@@ -528,6 +528,10 @@
528
528
  "minItems": 1,
529
529
  "maxItems": 32,
530
530
  "items": { "$ref": "#/$defs/storageMigrationOp" }
531
+ },
532
+ "hook": {
533
+ "description": "RESERVED — civitai.com refuses this field until permission hooks are enabled, so do not declare it yet. Optional. 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.",
534
+ "$ref": "#/$defs/storageCollectionHook"
531
535
  }
532
536
  },
533
537
  "allOf": [
@@ -733,6 +737,32 @@
733
737
  },
734
738
  "storageCollectionSchemaType": {
735
739
  "enum": ["object", "array", "string", "number", "integer", "boolean", "null"]
740
+ },
741
+ "storageCollectionHook": {
742
+ "type": "object",
743
+ "description": "A collection's permission hook (see `storage.collections.<name>.hook`). Whether `file` is inside `outputDir`, whether it exists in the bundle with this sha256, its size, and two collections pinning one file with different digests are checked by the server, not by this schema.",
744
+ "additionalProperties": false,
745
+ "required": ["file", "sha256"],
746
+ "properties": {
747
+ "file": {
748
+ "type": "string",
749
+ "description": "The hook's relative path in the bundle: \"/\"-separated segments, each starting with a letter, digit, _ or - and then letters, digits, _, . or - (so no \".\" or \"..\" segment, no hidden file, no leading \"/\"), ending .js or .mjs, at most 200 characters, with no node_modules segment.",
750
+ "maxLength": 200,
751
+ "pattern": "^([A-Za-z0-9_-][A-Za-z0-9_.-]*/)*[A-Za-z0-9_-][A-Za-z0-9_.-]*\\.m?js$",
752
+ "not": { "pattern": "(^|/)node_modules(/|$)" }
753
+ },
754
+ "sha256": {
755
+ "type": "string",
756
+ "description": "The SHA-256 of the file's bytes, as 64 lowercase hex characters.",
757
+ "pattern": "^[0-9a-f]{64}$"
758
+ },
759
+ "timeoutMs": {
760
+ "type": "integer",
761
+ "description": "The most milliseconds one call of the hook may take, from 1 to 500. Omitted means 50.",
762
+ "minimum": 1,
763
+ "maximum": 500
764
+ }
765
+ }
736
766
  }
737
767
  },
738
768
  "allOf": [