@civitai/app-sdk 0.81.0 → 0.83.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 +67 -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 +11 -2
- package/dist/manifest/index.d.ts +1 -1
- package/package.json +1 -1
- package/schemas/app-block/v1.json +90 -4
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, 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';
|
|
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';
|
|
120
120
|
/**
|
|
121
121
|
* Host bounds for an inline `customComfy` graph, mirrored from civitai/civitai —
|
|
122
122
|
* see `WorkflowBodyCustomComfyInline.workflow`.
|
package/dist/blocks/types.d.ts
CHANGED
|
@@ -2745,11 +2745,59 @@ export interface BlockStorageCollectionSchema {
|
|
|
2745
2745
|
maxItems?: number;
|
|
2746
2746
|
description?: string;
|
|
2747
2747
|
}
|
|
2748
|
+
/**
|
|
2749
|
+
* The schema keyword of the one breaking change an `acknowledge`
|
|
2750
|
+
* {@link BlockStorageMigrationOp} accepts. `'required'` is not one: a newly required field can
|
|
2751
|
+
* only be covered by a `default`.
|
|
2752
|
+
*/
|
|
2753
|
+
export type BlockStorageMigrationKeyword = 'type' | 'const' | 'enum' | 'minimum' | 'maximum' | 'minLength' | 'maxLength' | 'minItems' | 'maxItems' | 'pattern' | 'additionalProperties' | 'properties';
|
|
2754
|
+
/**
|
|
2755
|
+
* One declarative MIGRATION op on a collection's stored documents (civitai/civitai#7661),
|
|
2756
|
+
* discriminated on `op`. Mirrors the canonical schema's `$defs.storageMigrationOp`.
|
|
2757
|
+
*
|
|
2758
|
+
* At submit, civitai.com compares the collection's `schema` with the previous approved
|
|
2759
|
+
* version's (statically; stored documents are never read) and refuses every BREAKING change
|
|
2760
|
+
* (a newly required property, a narrowed type / enum / const / bound / pattern,
|
|
2761
|
+
* `additionalProperties` closed, a declared property removed under
|
|
2762
|
+
* `additionalProperties: false`, or a schema added where there was none) that no op covers:
|
|
2763
|
+
*
|
|
2764
|
+
* - `default` covers a newly required property at `path`, setting `value` where the field is
|
|
2765
|
+
* missing (its parent object exists). `value` must match the new schema there; at most 4096
|
|
2766
|
+
* bytes of JSON. It is the only op that can cover a newly required property.
|
|
2767
|
+
* - `rename` covers a declared property removed under `additionalProperties: false`, at `from`.
|
|
2768
|
+
* - `remove` covers any breaking change at or under a field the new schema does not require.
|
|
2769
|
+
* - `acknowledge` covers exactly the one breaking change whose pointer EQUALS `path` (never a
|
|
2770
|
+
* prefix) with that `keyword`, and changes nothing: documents that violate it are refused on
|
|
2771
|
+
* their next write until reshaped. Its `path` may be `""` (the document root) and may use the
|
|
2772
|
+
* segment `*` for a change inside `items` or an `additionalProperties` schema (`"/tags/*"`).
|
|
2773
|
+
*
|
|
2774
|
+
* The `path` / `from` / `to` of `default`, `rename` and `remove` are JSON Pointers to one field
|
|
2775
|
+
* of a document's `data` (`"/meta/title"`): 1 to 15 non-empty segments, `~` written `~0` and `/`
|
|
2776
|
+
* written `~1`, no `*` segment. Every op is idempotent, and the fields `default`, `rename` and
|
|
2777
|
+
* `remove` touch must be disjoint. Only the ops that cover a breaking change of THIS version run,
|
|
2778
|
+
* once, when it is approved; an op that covers nothing is reported at submit and never runs.
|
|
2779
|
+
*/
|
|
2780
|
+
export type BlockStorageMigrationOp = {
|
|
2781
|
+
op: 'default';
|
|
2782
|
+
path: string;
|
|
2783
|
+
value: unknown;
|
|
2784
|
+
} | {
|
|
2785
|
+
op: 'rename';
|
|
2786
|
+
from: string;
|
|
2787
|
+
to: string;
|
|
2788
|
+
} | {
|
|
2789
|
+
op: 'remove';
|
|
2790
|
+
path: string;
|
|
2791
|
+
} | {
|
|
2792
|
+
op: 'acknowledge';
|
|
2793
|
+
path: string;
|
|
2794
|
+
keyword: BlockStorageMigrationKeyword;
|
|
2795
|
+
};
|
|
2748
2796
|
/**
|
|
2749
2797
|
* A PRIVATE collection — a separate key space per viewer, read and written
|
|
2750
2798
|
* only by that viewer. Carries none of the shared-only fields (`write`,
|
|
2751
2799
|
* `counters`, `marks`, `showAuthor`, `dailyWritesPerAuthor`,
|
|
2752
|
-
* `ownedModelVersions`); the canonical
|
|
2800
|
+
* `ownedModelVersions`, `registry`); the canonical
|
|
2753
2801
|
* forbids them here. See {@link BlockStorageSharedCollectionDeclaration} for
|
|
2754
2802
|
* the fields both kinds share.
|
|
2755
2803
|
*/
|
|
@@ -2768,6 +2816,8 @@ export interface BlockStoragePrivateCollectionDeclaration {
|
|
|
2768
2816
|
exportable?: boolean;
|
|
2769
2817
|
/** See {@link BlockStorageCollectionSchema}. */
|
|
2770
2818
|
schema?: BlockStorageCollectionSchema;
|
|
2819
|
+
/** See {@link BlockStorageSharedCollectionDeclaration.migrations}. */
|
|
2820
|
+
migrations?: BlockStorageMigrationOp[];
|
|
2771
2821
|
}
|
|
2772
2822
|
/**
|
|
2773
2823
|
* A SHARED collection — one key space for the whole app, read by every viewer
|
|
@@ -2868,11 +2918,27 @@ export interface BlockStorageSharedCollectionDeclaration {
|
|
|
2868
2918
|
* `false` refuses every import of it with 403 `not_exportable`.
|
|
2869
2919
|
*/
|
|
2870
2920
|
exportable?: boolean;
|
|
2921
|
+
/**
|
|
2922
|
+
* RESERVED — civitai.com refuses this field until publishing to registries
|
|
2923
|
+
* is enabled, so do not declare it yet. Shared collections only.
|
|
2924
|
+
* `'public'` publishes the collection's visible shared documents, read-only,
|
|
2925
|
+
* to every registry that follows Civitai's apps, as entities of the
|
|
2926
|
+
* collection's schema; hidden documents and every private document never
|
|
2927
|
+
* leave. Absent (the default): the collection is not published. A moderator
|
|
2928
|
+
* sees the change at review.
|
|
2929
|
+
*/
|
|
2930
|
+
registry?: 'public';
|
|
2871
2931
|
/**
|
|
2872
2932
|
* The schema every document's `data` must match — see {@link BlockStorageCollectionSchema}.
|
|
2873
2933
|
* Not allowed with `write` `'none'` (no document bodies are written there).
|
|
2874
2934
|
*/
|
|
2875
2935
|
schema?: BlockStorageCollectionSchema;
|
|
2936
|
+
/**
|
|
2937
|
+
* 1 to 32 ops applied to the documents ALREADY STORED when this version is approved, for a
|
|
2938
|
+
* `schema` change that would otherwise leave them unwritable — see
|
|
2939
|
+
* {@link BlockStorageMigrationOp}. Not allowed with `write` `'none'`.
|
|
2940
|
+
*/
|
|
2941
|
+
migrations?: BlockStorageMigrationOp[];
|
|
2876
2942
|
}
|
|
2877
2943
|
/**
|
|
2878
2944
|
* 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
|
-
*
|
|
28
|
+
* 213 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 213 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
|
+
* 213 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 213 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
|
|
@@ -98,6 +98,7 @@ export declare const KNOWN_GAPS: {
|
|
|
98
98
|
readonly 'settings-meta-schema-not-vendored': string;
|
|
99
99
|
readonly 'storage-server-only-rules': string;
|
|
100
100
|
readonly 'storage-collection-schema-server-only-rules': string;
|
|
101
|
+
readonly 'storage-migrations-server-only-rules': string;
|
|
101
102
|
readonly 'format-uri-not-enforced': string;
|
|
102
103
|
};
|
|
103
104
|
/** The canonical schema object, parsed once. Exported for tests and tooling. */
|
|
@@ -149,8 +149,8 @@ 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`, `write`
|
|
153
|
-
'"owner") validate offline and are refused at submit. Ajv enforces the structural rules ' +
|
|
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
154
|
'exactly; these are server-side.',
|
|
155
155
|
'storage-collection-schema-server-only-rules': 'A collection `schema` (civitai/civitai#7491): the canonical encodes the keyword subset, each ' +
|
|
156
156
|
'keyword\'s shape, the 256-character `pattern` bound, "a pattern needs a maxLength of at most ' +
|
|
@@ -160,6 +160,15 @@ export const KNOWN_GAPS = {
|
|
|
160
160
|
'its max, a pattern that compiles as a JavaScript regular expression with the `u` flag, ' +
|
|
161
161
|
'and no pattern that can backtrack ' +
|
|
162
162
|
'catastrophically. Those validate here and are refused at submit.',
|
|
163
|
+
'storage-migrations-server-only-rules': 'A collection\'s `migrations` (civitai/civitai#7661): the canonical encodes each op\'s shape ' +
|
|
164
|
+
'(`default` / `rename` / `remove` / `acknowledge`), the JSON Pointer form of its paths, the ' +
|
|
165
|
+
'acknowledge-only `""` and `*`, the `keyword` list, 1 to 32 ops and "no migrations on write ' +
|
|
166
|
+
'none", and Ajv enforces those exactly. The rest is the server\'s, at submit. Which schema ' +
|
|
167
|
+
'changes are breaking, and whether an op covers one, needs the PREVIOUS approved manifest, so ' +
|
|
168
|
+
'a breaking change no op covers and an op that covers nothing (reported, never run) are ' +
|
|
169
|
+
'decided there. So are the canonical\'s prose-only rules: a `default` value must match the new ' +
|
|
170
|
+
'schema at its path and be at most 4096 bytes of JSON, and the ops must touch disjoint ' +
|
|
171
|
+
'fields. All of those validate here.',
|
|
163
172
|
'format-uri-not-enforced': '`assetBundleUrl` carries `format: "uri"` in addition to `pattern: "^https://"`. Ajv ignores ' +
|
|
164
173
|
'unknown formats unless `ajv-formats` is installed, which would be a second optional peer for ' +
|
|
165
174
|
'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, BlockStorageCollectionSchema, BlockStorageDeclaration, BlockStorageImport, BlockStorageIndexes, BlockStorageIndexType, BlockStoragePrivateCollectionDeclaration, BlockStorageSchemaType, BlockStorageSharedCollectionDeclaration, } from '../blocks/types.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';
|
|
19
19
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -503,6 +503,10 @@
|
|
|
503
503
|
"type": "boolean",
|
|
504
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
505
|
},
|
|
506
|
+
"registry": {
|
|
507
|
+
"enum": ["public"],
|
|
508
|
+
"description": "RESERVED — civitai.com refuses this field until publishing to registries is enabled, so do not declare it yet. Shared collections only. \"public\" publishes the collection's visible shared documents, read-only, to every registry that follows Civitai's apps, as entities of the collection's schema; hidden documents and every private document never leave. Absent (the default): the collection is not published. A moderator sees the change at review."
|
|
509
|
+
},
|
|
506
510
|
"ownedModelVersions": {
|
|
507
511
|
"type": "array",
|
|
508
512
|
"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.",
|
|
@@ -515,18 +519,25 @@
|
|
|
515
519
|
}
|
|
516
520
|
},
|
|
517
521
|
"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.
|
|
522
|
+
"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. A change that narrows the schema against the previous approved version (a newly required property; a type, enum, const, bound or pattern narrowed; `additionalProperties` closed or newly a schema; a declared property removed under `additionalProperties: false`; or a schema added where there was none) is refused at submit unless `migrations` covers it. The covering ops run over the documents already stored when the version is approved; a document an \"acknowledge\" op covers is left as stored and checked when next written.",
|
|
519
523
|
"$ref": "#/$defs/storageCollectionSchema"
|
|
524
|
+
},
|
|
525
|
+
"migrations": {
|
|
526
|
+
"type": "array",
|
|
527
|
+
"description": "Optional. Declarative ops applied to this collection's documents ALREADY STORED in production when this version is approved, for a schema change that would otherwise leave them unwritable. Submit compares this collection's `schema` with the previous approved version's (statically; stored documents are never read) and refuses every BREAKING change no op here covers: \"default\" covers a newly required property at its `path` (`value` must match the new schema there) — the only op that can; \"rename\" covers a declared property removed under `additionalProperties: false`, at `from`; \"remove\" covers any breaking change at or under a field the new schema does not require; \"acknowledge\" covers exactly the one breaking change whose pointer is its `path` (\"\" for the document root, \"*\" for an `items` or `additionalProperties` schema, matched literally, never as a prefix) with its `keyword` and changes nothing — documents that violate it are refused on their next write until reshaped. A first schema on a collection that had none is compared with accept-anything, so each of its constraints is its own breaking change. The paths of default, rename and remove are JSON Pointers to one field of a document's data (\"/meta/title\"). Every op is idempotent, and default, rename and remove ops must touch disjoint fields, so a re-run changes nothing. Only the ops that cover a breaking change of THIS version run, once, in bounded batches; an op that covers nothing is reported at submit and never runs, so a list left in a later version is inert. Not allowed on a `write` \"none\" collection. 1 to 32 ops.",
|
|
528
|
+
"minItems": 1,
|
|
529
|
+
"maxItems": 32,
|
|
530
|
+
"items": { "$ref": "#/$defs/storageMigrationOp" }
|
|
520
531
|
}
|
|
521
532
|
},
|
|
522
533
|
"allOf": [
|
|
523
534
|
{
|
|
524
|
-
"$comment": "No document body is ever written in a write:\"none\" collection, so a schema there would check nothing.",
|
|
535
|
+
"$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.",
|
|
525
536
|
"if": {
|
|
526
537
|
"required": ["write"],
|
|
527
538
|
"properties": { "write": { "const": "none" } }
|
|
528
539
|
},
|
|
529
|
-
"then": { "properties": { "schema": false } }
|
|
540
|
+
"then": { "properties": { "schema": false, "migrations": false } }
|
|
530
541
|
},
|
|
531
542
|
{
|
|
532
543
|
"$comment": "A shared collection must state its write policy; a private one carries none of the shared-only fields.",
|
|
@@ -542,7 +553,8 @@
|
|
|
542
553
|
"marks": false,
|
|
543
554
|
"showAuthor": false,
|
|
544
555
|
"dailyWritesPerAuthor": false,
|
|
545
|
-
"ownedModelVersions": false
|
|
556
|
+
"ownedModelVersions": false,
|
|
557
|
+
"registry": false
|
|
546
558
|
}
|
|
547
559
|
}
|
|
548
560
|
},
|
|
@@ -645,6 +657,80 @@
|
|
|
645
657
|
"if": { "required": ["pattern"] },
|
|
646
658
|
"then": { "required": ["maxLength"], "properties": { "maxLength": { "maximum": 1000 } } }
|
|
647
659
|
},
|
|
660
|
+
"storageMigrationPath": {
|
|
661
|
+
"type": "string",
|
|
662
|
+
"description": "A JSON Pointer to one field of a document's data: 1 to 15 non-empty segments, each \"/\" then the field name with ~ written ~0 and / written ~1. No \"*\" segment.",
|
|
663
|
+
"maxLength": 512,
|
|
664
|
+
"pattern": "^(/([^/~]|~[01])+){1,15}$",
|
|
665
|
+
"not": { "pattern": "/\\*(/|$)" }
|
|
666
|
+
},
|
|
667
|
+
"storageMigrationOp": {
|
|
668
|
+
"description": "One migration op. See `storage.collections.<name>.migrations`.",
|
|
669
|
+
"oneOf": [
|
|
670
|
+
{
|
|
671
|
+
"type": "object",
|
|
672
|
+
"additionalProperties": false,
|
|
673
|
+
"required": ["op", "path", "value"],
|
|
674
|
+
"properties": {
|
|
675
|
+
"op": { "const": "default" },
|
|
676
|
+
"path": { "$ref": "#/$defs/storageMigrationPath" },
|
|
677
|
+
"value": {
|
|
678
|
+
"description": "Set where the field is missing (its parent object exists). Must match the new schema at `path`; at most 4096 bytes of JSON."
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
"type": "object",
|
|
684
|
+
"additionalProperties": false,
|
|
685
|
+
"required": ["op", "from", "to"],
|
|
686
|
+
"properties": {
|
|
687
|
+
"op": { "const": "rename" },
|
|
688
|
+
"from": { "$ref": "#/$defs/storageMigrationPath" },
|
|
689
|
+
"to": { "$ref": "#/$defs/storageMigrationPath" }
|
|
690
|
+
}
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
"type": "object",
|
|
694
|
+
"additionalProperties": false,
|
|
695
|
+
"required": ["op", "path"],
|
|
696
|
+
"properties": {
|
|
697
|
+
"op": { "const": "remove" },
|
|
698
|
+
"path": { "$ref": "#/$defs/storageMigrationPath" }
|
|
699
|
+
}
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
"type": "object",
|
|
703
|
+
"additionalProperties": false,
|
|
704
|
+
"required": ["op", "path", "keyword"],
|
|
705
|
+
"properties": {
|
|
706
|
+
"op": { "const": "acknowledge" },
|
|
707
|
+
"path": {
|
|
708
|
+
"type": "string",
|
|
709
|
+
"description": "The JSON Pointer of the one breaking change accepted, matched EXACTLY (never as a prefix): \"\" for a change at the document root, or up to 15 non-empty segments, where the segment \"*\" is the pointer of a change inside `items` or an `additionalProperties` schema (\"/tags/*\").",
|
|
710
|
+
"maxLength": 512,
|
|
711
|
+
"pattern": "^(/([^/~]|~[01])+){0,15}$"
|
|
712
|
+
},
|
|
713
|
+
"keyword": {
|
|
714
|
+
"description": "The schema keyword of the one breaking change accepted at `path`. A newly required field (\"required\") cannot be acknowledged: cover it with a \"default\".",
|
|
715
|
+
"enum": [
|
|
716
|
+
"type",
|
|
717
|
+
"const",
|
|
718
|
+
"enum",
|
|
719
|
+
"minimum",
|
|
720
|
+
"maximum",
|
|
721
|
+
"minLength",
|
|
722
|
+
"maxLength",
|
|
723
|
+
"minItems",
|
|
724
|
+
"maxItems",
|
|
725
|
+
"pattern",
|
|
726
|
+
"additionalProperties",
|
|
727
|
+
"properties"
|
|
728
|
+
]
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
]
|
|
733
|
+
},
|
|
648
734
|
"storageCollectionSchemaType": {
|
|
649
735
|
"enum": ["object", "array", "string", "number", "integer", "boolean", "null"]
|
|
650
736
|
}
|