@civitai/app-sdk 0.93.0 → 0.94.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/types.d.ts
CHANGED
|
@@ -3418,8 +3418,8 @@ export type BlockStorageMigrationOp = {
|
|
|
3418
3418
|
keyword: BlockStorageMigrationKeyword;
|
|
3419
3419
|
};
|
|
3420
3420
|
/**
|
|
3421
|
-
*
|
|
3422
|
-
*
|
|
3421
|
+
* In a limited rollout — civitai.com accepts a new or changed hook only from
|
|
3422
|
+
* authors the rollout includes, and refuses it otherwise. A collection's permission hook: one ES module of the
|
|
3423
3423
|
* bundle whose default export decides, for every write to the collection,
|
|
3424
3424
|
* whether the write is allowed. It runs after the collection `schema` check,
|
|
3425
3425
|
* never instead of it. Mirrors the canonical schema's
|
|
@@ -3454,7 +3454,7 @@ export interface BlockStorageCollectionHook {
|
|
|
3454
3454
|
* A PRIVATE collection — a separate key space per viewer, read and written
|
|
3455
3455
|
* only by that viewer. Carries none of the shared-only fields (`write`,
|
|
3456
3456
|
* `counters`, `marks`, `showAuthor`, `dailyWritesPerAuthor`,
|
|
3457
|
-
* `ownedModelVersions`, `registry`); the canonical
|
|
3457
|
+
* `ownedModelVersions`, `registry`, `keyedBy`); the canonical
|
|
3458
3458
|
* forbids them here. See {@link BlockStorageSharedCollectionDeclaration} for
|
|
3459
3459
|
* the fields both kinds share.
|
|
3460
3460
|
*/
|
|
@@ -3475,7 +3475,7 @@ export interface BlockStoragePrivateCollectionDeclaration {
|
|
|
3475
3475
|
schema?: BlockStorageCollectionSchema;
|
|
3476
3476
|
/** See {@link BlockStorageSharedCollectionDeclaration.migrations}. */
|
|
3477
3477
|
migrations?: BlockStorageMigrationOp[];
|
|
3478
|
-
/**
|
|
3478
|
+
/** Limited rollout — see {@link BlockStorageSharedCollectionDeclaration.hook}. */
|
|
3479
3479
|
hook?: BlockStorageCollectionHook;
|
|
3480
3480
|
}
|
|
3481
3481
|
/**
|
|
@@ -3587,6 +3587,27 @@ export interface BlockStorageSharedCollectionDeclaration {
|
|
|
3587
3587
|
* sees the change at review.
|
|
3588
3588
|
*/
|
|
3589
3589
|
registry?: 'public';
|
|
3590
|
+
/**
|
|
3591
|
+
* Viewer-keyed documents. `write` `'own'` collections only, never with
|
|
3592
|
+
* `kind` `'log'`, and never beside `counters` or `marks` — the canonical
|
|
3593
|
+
* refuses it under `'anyone'`, `'owner'` and `'none'`, on log and private
|
|
3594
|
+
* collections, and with either of those fields.
|
|
3595
|
+
*
|
|
3596
|
+
* The server derives each document's key from the signed-in viewer, so each
|
|
3597
|
+
* viewer has at most one document (`'viewer'`) or at most one per parent key
|
|
3598
|
+
* the app names (`'parent+viewer'`), and no viewer can write another's. The
|
|
3599
|
+
* app reads and writes it at `/:collection/@me` or `/:collection/@me/:parent`,
|
|
3600
|
+
* where a parent is 1 to 96 characters of `A-Z`, `a-z`, `0-9`, `.`, `_` or
|
|
3601
|
+
* `-` (not only dots); a `'parent+viewer'` key is `<parent>:<digest>`, so
|
|
3602
|
+
* listing with `keyPrefix=<parent>:` returns one parent's documents. Writing
|
|
3603
|
+
* such a collection by key, creating in it and publishing into it are
|
|
3604
|
+
* refused.
|
|
3605
|
+
*
|
|
3606
|
+
* Cannot be added, removed or changed on a collection any approved version
|
|
3607
|
+
* declared: declare a new collection instead. That is checked at submit, not
|
|
3608
|
+
* by `defineBlock` — see `KNOWN_GAPS['storage-keyedBy-immutable']`.
|
|
3609
|
+
*/
|
|
3610
|
+
keyedBy?: 'viewer' | 'parent+viewer';
|
|
3590
3611
|
/**
|
|
3591
3612
|
* The schema every document's `data` must match — see {@link BlockStorageCollectionSchema}.
|
|
3592
3613
|
* Not allowed with `write` `'none'` (no document bodies are written there).
|
|
@@ -3599,8 +3620,8 @@ export interface BlockStorageSharedCollectionDeclaration {
|
|
|
3599
3620
|
*/
|
|
3600
3621
|
migrations?: BlockStorageMigrationOp[];
|
|
3601
3622
|
/**
|
|
3602
|
-
*
|
|
3603
|
-
*
|
|
3623
|
+
* In a limited rollout — civitai.com accepts a new or changed hook only from
|
|
3624
|
+
* authors the rollout includes, and refuses it otherwise. A permission hook that decides, for every
|
|
3604
3625
|
* write to this collection, whether it is allowed — see
|
|
3605
3626
|
* {@link BlockStorageCollectionHook}. Allowed on every collection kind,
|
|
3606
3627
|
* private and shared alike.
|
|
@@ -99,6 +99,7 @@ export declare const KNOWN_GAPS: {
|
|
|
99
99
|
readonly 'storage-server-only-rules': string;
|
|
100
100
|
readonly 'storage-collection-schema-server-only-rules': string;
|
|
101
101
|
readonly 'storage-migrations-server-only-rules': string;
|
|
102
|
+
readonly 'storage-keyedBy-immutable': string;
|
|
102
103
|
readonly 'format-uri-not-enforced': string;
|
|
103
104
|
};
|
|
104
105
|
/** The canonical schema object, parsed once. Exported for tests and tooling. */
|
|
@@ -149,8 +149,10 @@ 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`,
|
|
153
|
-
'`write` "anyone" / "owner") validate offline and are refused at submit. A
|
|
152
|
+
'RESERVED features (`kind` "log", `ttlSeconds`, `dailyWritesPerAuthor`, `registry`, ' +
|
|
153
|
+
'`write` "anyone" / "owner") validate offline and are refused at submit. A new or changed ' +
|
|
154
|
+
'`hook` is in a limited rollout: it validates offline and is refused at submit for an author ' +
|
|
155
|
+
'the rollout does not include. A `hook`\'s `file` ' +
|
|
154
156
|
'being outside `outputDir`, present in the bundle with its `sha256`, its size, and one file ' +
|
|
155
157
|
'pinned with one digest across collections are checked by the server too. Ajv enforces the ' +
|
|
156
158
|
'structural rules exactly; these are server-side.',
|
|
@@ -171,6 +173,12 @@ export const KNOWN_GAPS = {
|
|
|
171
173
|
'decided there. So are the canonical\'s prose-only rules: a `default` value must match the new ' +
|
|
172
174
|
'schema at its path and be at most 4096 bytes of JSON, and the ops must touch disjoint ' +
|
|
173
175
|
'fields. All of those validate here.',
|
|
176
|
+
'storage-keyedBy-immutable': 'A collection\'s `keyedBy` (viewer-keyed documents): the canonical encodes its values ' +
|
|
177
|
+
'("viewer" / "parent+viewer") and where it may appear — shared `write` "own" collections ' +
|
|
178
|
+
'only, never `kind` "log", never beside `counters` or `marks` — and Ajv enforces those ' +
|
|
179
|
+
'exactly. That it cannot be added, removed or changed on a collection ANY previously ' +
|
|
180
|
+
'approved version declared needs those approved manifests, so it is decided by the server at ' +
|
|
181
|
+
'submit. A change to it validates here.',
|
|
174
182
|
'format-uri-not-enforced': '`assetBundleUrl` carries `format: "uri"` in addition to `pattern: "^https://"`. Ajv ignores ' +
|
|
175
183
|
'unknown formats unless `ajv-formats` is installed, which would be a second optional peer for ' +
|
|
176
184
|
'one field whose pattern is already enforced. The pattern IS enforced; the `uri` format is ' +
|
package/package.json
CHANGED
|
@@ -536,8 +536,13 @@
|
|
|
536
536
|
"maxItems": 32,
|
|
537
537
|
"items": { "$ref": "#/$defs/storageMigrationOp" }
|
|
538
538
|
},
|
|
539
|
+
"keyedBy": {
|
|
540
|
+
"type": "string",
|
|
541
|
+
"description": "Shared collections with `write` \"own\" only (not kind \"log\"). The server derives each document's key from the signed-in viewer, so each viewer has at most one document (\"viewer\") or at most one per parent key the app names (\"parent+viewer\"), and no viewer can write another's. The app reads and writes it at `/:collection/@me` or `/:collection/@me/:parent`, where a parent is 1 to 96 characters of A-Z, a-z, 0-9, `.`, `_` or `-` (not only dots); a \"parent+viewer\" key is `<parent>:<digest>`, so listing with `keyPrefix=<parent>:` returns one parent's documents. Writing such a collection by key, creating in it, publishing into it and counters or marks on it are refused (it declares none). Cannot be added, removed or changed on a collection any approved version declared: declare a new collection instead.",
|
|
542
|
+
"enum": ["viewer", "parent+viewer"]
|
|
543
|
+
},
|
|
539
544
|
"hook": {
|
|
540
|
-
"description": "
|
|
545
|
+
"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.",
|
|
541
546
|
"$ref": "#/$defs/storageCollectionHook"
|
|
542
547
|
}
|
|
543
548
|
},
|
|
@@ -565,7 +570,8 @@
|
|
|
565
570
|
"showAuthor": false,
|
|
566
571
|
"dailyWritesPerAuthor": false,
|
|
567
572
|
"ownedModelVersions": false,
|
|
568
|
-
"registry": false
|
|
573
|
+
"registry": false,
|
|
574
|
+
"keyedBy": false
|
|
569
575
|
}
|
|
570
576
|
}
|
|
571
577
|
},
|
|
@@ -593,6 +599,24 @@
|
|
|
593
599
|
},
|
|
594
600
|
"then": { "properties": { "ownedModelVersions": false } }
|
|
595
601
|
},
|
|
602
|
+
{
|
|
603
|
+
"$comment": "A viewer-keyed collection's viewer is the author of every key they address, so it is declared only under write:\"own\" (private collections are refused above); log entries have server keys.",
|
|
604
|
+
"if": {
|
|
605
|
+
"anyOf": [
|
|
606
|
+
{
|
|
607
|
+
"required": ["write"],
|
|
608
|
+
"properties": { "write": { "enum": ["anyone", "owner", "none"] } }
|
|
609
|
+
},
|
|
610
|
+
{ "required": ["kind"], "properties": { "kind": { "const": "log" } } }
|
|
611
|
+
]
|
|
612
|
+
},
|
|
613
|
+
"then": { "properties": { "keyedBy": false } }
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
"$comment": "A viewer-keyed document is itself the viewer's vote or entry, so a viewer-keyed collection declares no counters or marks.",
|
|
617
|
+
"if": { "required": ["keyedBy"] },
|
|
618
|
+
"then": { "properties": { "counters": false, "marks": false } }
|
|
619
|
+
},
|
|
596
620
|
{
|
|
597
621
|
"$comment": "A write:\"none\" collection is written only through counters and marks, so it must declare at least one.",
|
|
598
622
|
"if": {
|