@civitai/app-sdk 0.94.0 → 0.95.1

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.
@@ -233,6 +233,27 @@ export interface BlockInitPayload {
233
233
  * than the exact string must be treated as absent.
234
234
  */
235
235
  storageMode?: 'local-preview';
236
+ /**
237
+ * Where this app's DOCUMENT STORE is served when the host has moved the app
238
+ * to the app-data service: `url` is the service's base URL (`https:`, no
239
+ * credentials, query or fragment) and `slug` is the app's blockId, as the
240
+ * service names apps in its routes (`/v1/apps/<slug>/…`). The host sets it
241
+ * from its own per-app decision, and only for a production token; never from
242
+ * anything the block sent. Absent on every other surface, and never together
243
+ * with `storageMode: 'local-preview'` (if both arrive, the local preview wins).
244
+ *
245
+ * `@civitai/sdk`'s `initialize()` reads it once and sends
246
+ * `app.storage.collection(name)` (this app's own collections) and
247
+ * `app.storage.info()` to the service instead of `/api/v1/blocks/storage`.
248
+ * Nothing in this package or in `@civitai/blocks-react` acts on it.
249
+ *
250
+ * ADDITIVE + OPTIONAL. A host that predates it omits the field; any other
251
+ * shape must be treated as absent, which keeps the site's routes.
252
+ */
253
+ appData?: {
254
+ url: string;
255
+ slug: string;
256
+ };
236
257
  }
237
258
  /**
238
259
  * Why a `CONSENT_UNAVAILABLE` push was sent.
@@ -30,8 +30,9 @@ export const BLOCK_SCOPES = {
30
30
  // apps:storage / apps:storage:publish — the DOCUMENT STORE, declared per
31
31
  // collection in the manifest's `storage` block, that succeeds the four
32
32
  // scopes above (which stay live until apps migrate). Same no-OAuth-bit
33
- // posture. `apps:storage` covers reads, the viewer's private collections,
34
- // marks and counters, and is CONSENT-EXEMPT; any manifest declaring a
33
+ // posture. `apps:storage` covers reads, the viewer's private collections and
34
+ // deleting the viewer's own shared documents (marks and counters, which it
35
+ // also covered, were removed from civitai.com), and is CONSENT-EXEMPT; any manifest declaring a
35
36
  // collection must request it. `apps:storage:publish` writes documents in a
36
37
  // SHARED collection under the viewer's identity — SENSITIVE (needs a
37
38
  // `scopeJustifications` entry) and CONSENT-GATED. `apps:storage` is the one
@@ -3322,7 +3322,7 @@ export type BlockStorageSchemaType = 'object' | 'array' | 'string' | 'number' |
3322
3322
  * checked. The server checks every create and put, and refuses a document that does not match
3323
3323
  * with 400 `schema_violation`. The refusal's message and `details.pointer` name the FIRST
3324
3324
  * failing JSON pointer into `data` (for example `/title`), and `details.keyword` names the
3325
- * keyword it failed. Counters and marks are not checked. Changing a schema does not re-check
3325
+ * keyword it failed. Changing a schema does not re-check
3326
3326
  * stored documents; each is checked the next time it is written.
3327
3327
  *
3328
3328
  * Only these keywords exist; any other is refused at submit by name. Semantics: a keyword for
@@ -3336,8 +3336,8 @@ export type BlockStorageSchemaType = 'object' | 'array' | 'string' | 'number' |
3336
3336
  * bytes of JSON and 16 patterns per collection schema, and 32 patterns across all of the
3337
3337
  * manifest's collection schemas together; a `pattern` is at most 256 characters,
3338
3338
  * must compile, needs a `maxLength` of at most 1000 on the same schema, and must not backtrack
3339
- * catastrophically; no `min*` above its `max*`. Not allowed on a `write: 'none'` collection,
3340
- * which has no document bodies. Mirrors the canonical schema's
3339
+ * catastrophically; no `min*` above its `max*`. Not allowed on a `write: 'none'` collection
3340
+ * (REMOVED: read-only, no document bodies are written there). Mirrors the canonical schema's
3341
3341
  * `$defs.storageCollectionSchema`.
3342
3342
  */
3343
3343
  export interface BlockStorageCollectionSchema {
@@ -3453,7 +3453,7 @@ export interface BlockStorageCollectionHook {
3453
3453
  /**
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
- * `counters`, `marks`, `showAuthor`, `dailyWritesPerAuthor`,
3456
+ * the removed `counters` and `marks`, `showAuthor`, `dailyWritesPerAuthor`,
3457
3457
  * `ownedModelVersions`, `registry`, `keyedBy`); the canonical
3458
3458
  * forbids them here. See {@link BlockStorageSharedCollectionDeclaration} for
3459
3459
  * the fields both kinds share.
@@ -3496,30 +3496,44 @@ export interface BlockStorageSharedCollectionDeclaration {
3496
3496
  * Who may create, update and delete documents.
3497
3497
  *
3498
3498
  * - `'own'` — eligible signed-in viewers create documents; only a document's
3499
- * author updates or deletes it.
3500
- * - `'none'` — nobody writes documents; viewers only increment the declared
3501
- * `counters` and set the declared `marks`. Must declare at least one
3502
- * counter or mark.
3499
+ * author updates or deletes it. A vote, like or per-viewer entry is a
3500
+ * viewer-keyed `'own'` collection (`keyedBy`).
3501
+ * - `'none'` — REMOVED (it existed for counters, which were removed):
3502
+ * civitai.com refuses it on a collection that the app's previous approved
3503
+ * version did not already declare with `'none'`, and serves a collection
3504
+ * that keeps it READ-ONLY (nobody creates, updates or deletes its
3505
+ * documents). Use `'own'` with `keyedBy` (a viewer-keyed collection)
3506
+ * instead. Still typed so a manifest that already declares it compiles.
3503
3507
  * - `'anyone'` — RESERVED (refused at submit until enabled): eligible
3504
3508
  * signed-in viewers update or delete any document.
3505
3509
  * - `'owner'` — RESERVED (refused at submit until enabled): only the app
3506
- * owner writes documents; viewers can still mark and count.
3510
+ * owner writes documents.
3507
3511
  *
3508
- * `'own'` and `'anyone'` require the `apps:storage:publish` scope.
3512
+ * `'own'` and `'anyone'` require the `apps:storage:publish` scope. Available
3513
+ * today: `'own'` (and `'none'` only where already declared, as above).
3509
3514
  */
3510
3515
  write: 'own' | 'anyone' | 'owner' | 'none';
3511
3516
  /**
3512
- * Names of the atomic counters each document carries (for example `plays`).
3513
- * At most 8 distinct lowercase snake_case names (`^[a-z][a-z0-9_]{0,31}$`),
3514
- * never `report`, and never a name also used by a mark.
3517
+ * Still typed so a manifest that already declares counters compiles; a declared one does
3518
+ * nothing. At most 8 distinct lowercase snake_case names (`^[a-z][a-z0-9_]{0,31}$`), never
3519
+ * `report`, and never a name also used by a mark.
3520
+ *
3521
+ * @deprecated REMOVED — use a viewer-keyed collection (`keyedBy`) instead. civitai.com serves
3522
+ * no counters: a declared one does nothing, and documents carry no counts. civitai.com refuses
3523
+ * a counter that the collection did not already declare in the app's previous approved
3524
+ * version; a collection may keep the counters it already declares (inert) or drop them.
3515
3525
  */
3516
3526
  counters?: string[];
3517
3527
  /**
3518
- * Names of the per-viewer marks a viewer can set on a document (for example
3519
- * `vote`), at most one of each per viewer per document. A reader sees each
3520
- * mark's count and whether THEY set it, never who else did. At most 8
3521
- * distinct lowercase snake_case names. `report` is built in on every shared
3522
- * collection and must NOT be declared.
3528
+ * Still typed so a manifest that already declares marks compiles; a declared one does
3529
+ * nothing. At most 8 distinct lowercase snake_case names. `report` is reserved and must NOT
3530
+ * be declared.
3531
+ *
3532
+ * @deprecated REMOVED — use a viewer-keyed collection (`keyedBy`) instead: each viewer's own
3533
+ * document is their vote or entry. To report a document, use the moderation report API.
3534
+ * civitai.com serves no marks: a declared one does nothing. civitai.com refuses a mark that
3535
+ * the collection did not already declare in the app's previous approved version; a
3536
+ * collection may keep the marks it already declares (inert) or drop them.
3523
3537
  */
3524
3538
  marks?: string[];
3525
3539
  /** See {@link BlockStorageIndexes}. */
@@ -3588,8 +3602,9 @@ export interface BlockStorageSharedCollectionDeclaration {
3588
3602
  */
3589
3603
  registry?: 'public';
3590
3604
  /**
3591
- * Viewer-keyed documents. `write` `'own'` collections only, never with
3592
- * `kind` `'log'`, and never beside `counters` or `marks` — the canonical
3605
+ * Viewer-keyed documents — what replaces the removed `counters` and `marks`: each viewer's
3606
+ * own document is their vote or entry, counted by listing. `write` `'own'` collections only,
3607
+ * never with `kind` `'log'`, and never beside the removed `counters` or `marks` — the canonical
3593
3608
  * refuses it under `'anyone'`, `'owner'` and `'none'`, on log and private
3594
3609
  * collections, and with either of those fields.
3595
3610
  *
@@ -3610,13 +3625,13 @@ export interface BlockStorageSharedCollectionDeclaration {
3610
3625
  keyedBy?: 'viewer' | 'parent+viewer';
3611
3626
  /**
3612
3627
  * The schema every document's `data` must match — see {@link BlockStorageCollectionSchema}.
3613
- * Not allowed with `write` `'none'` (no document bodies are written there).
3628
+ * Not allowed with the removed `write` `'none'` (no document bodies are written there).
3614
3629
  */
3615
3630
  schema?: BlockStorageCollectionSchema;
3616
3631
  /**
3617
3632
  * 1 to 32 ops applied to the documents ALREADY STORED when this version is approved, for a
3618
3633
  * `schema` change that would otherwise leave them unwritable — see
3619
- * {@link BlockStorageMigrationOp}. Not allowed with `write` `'none'`.
3634
+ * {@link BlockStorageMigrationOp}. Not allowed with the removed `write` `'none'`.
3620
3635
  */
3621
3636
  migrations?: BlockStorageMigrationOp[];
3622
3637
  /**
@@ -3657,9 +3672,9 @@ export interface BlockStorageImport {
3657
3672
  /** 1 to 16 distinct names of collections the source declares. */
3658
3673
  collections: string[];
3659
3674
  /**
3660
- * `'read'`: reads only; every write, counter and mark is refused (`write_policy`).
3661
- * `'readwrite'`: also writes, under the source collection's own write policy. A write,
3662
- * counter or mark in one of the source's SHARED collections also needs the viewer's own
3675
+ * `'read'`: reads only; every write and report is refused (`write_policy`).
3676
+ * `'readwrite'`: also writes, under the source collection's own write policy. A write
3677
+ * or report in one of the source's SHARED collections also needs the viewer's own
3663
3678
  * `apps:storage:publish` grant IN THE SOURCE APP; a private collection needs only the
3664
3679
  * import grant.
3665
3680
  */
@@ -148,7 +148,10 @@ export const KNOWN_GAPS = {
148
148
  '"own" or "anyone") also requires `apps:storage:publish`, declaring `imports` requires ' +
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
- 'most once, a counter may not share a name with a mark, and the ' +
151
+ 'most once, a counter may not share a name with a mark, `counters`, `marks` and `write` ' +
152
+ '"none" are REMOVED (civitai.com serves none of them and refuses one a collection did not ' +
153
+ 'already declare in the app\'s previous approved version; use a viewer-keyed collection, ' +
154
+ '`keyedBy`, instead), and the ' +
152
155
  'RESERVED features (`kind` "log", `ttlSeconds`, `dailyWritesPerAuthor`, `registry`, ' +
153
156
  '`write` "anyone" / "owner") validate offline and are refused at submit. A new or changed ' +
154
157
  '`hook` is in a limited rollout: it validates offline and is refused at submit for an author ' +
@@ -175,7 +178,7 @@ export const KNOWN_GAPS = {
175
178
  'fields. All of those validate here.',
176
179
  'storage-keyedBy-immutable': 'A collection\'s `keyedBy` (viewer-keyed documents): the canonical encodes its values ' +
177
180
  '("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 ' +
181
+ 'only, never `kind` "log", never beside the removed `counters` or `marks` — and Ajv enforces those ' +
179
182
  'exactly. That it cannot be added, removed or changed on a collection ANY previously ' +
180
183
  'approved version declared needs those approved manifests, so it is decided by the server at ' +
181
184
  'submit. A change to it validates here.',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@civitai/app-sdk",
3
- "version": "0.94.0",
3
+ "version": "0.95.1",
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",
@@ -442,12 +442,13 @@
442
442
  },
443
443
  "write": {
444
444
  "type": "string",
445
- "description": "Shared collections only, and REQUIRED on them. Who may create, update and delete documents. \"own\": eligible signed-in viewers create documents, and only a document's author updates or deletes it. \"anyone\": eligible signed-in viewers may update or delete any document — RESERVED: civitai.com refuses \"anyone\" until it is enabled. \"none\": nobody creates, updates or deletes documents — viewers may only increment the declared `counters` and set the declared `marks`, and incrementing a counter on a document that does not exist creates an empty one authored by no viewer; a \"none\" collection must declare at least one counter or mark. \"owner\": only the app owner writes documents; viewers can still mark and count. Only \"own\" and \"anyone\" require the `apps:storage:publish` scope. RESERVED: civitai.com refuses \"owner\" until owner-written documents are enabled. Available today: \"own\" and \"none\".",
445
+ "description": "Shared collections only, and REQUIRED on them. Who may create, update and delete documents. \"own\": eligible signed-in viewers create documents, and only a document's author updates or deletes it. \"anyone\": eligible signed-in viewers may update or delete any document — RESERVED: civitai.com refuses \"anyone\" until it is enabled. \"none\" is REMOVED (it existed for counters, which were removed): civitai.com refuses it on a collection that the app's previous approved version did not already declare with \"none\", and serves a collection that keeps it READ-ONLY (nobody creates, updates or deletes its documents). Use \"own\" with `keyedBy` (a viewer-keyed collection) instead. \"owner\": only the app owner writes documents. Only \"own\" and \"anyone\" require the `apps:storage:publish` scope. RESERVED: civitai.com refuses \"owner\" until owner-written documents are enabled. Available today: \"own\" (and \"none\" only where already declared, as above).",
446
446
  "enum": ["own", "anyone", "owner", "none"]
447
447
  },
448
448
  "counters": {
449
449
  "type": "array",
450
- "description": "Shared collections only. Names of the counters each document carries — atomic tallies the app increments (for example plays). At most 8 distinct names, each lowercase snake_case: a letter, then up to 31 of a-z, 0-9 or _. A counter may not share a name with a mark on the same collection, or with the built-in `report` mark.",
450
+ "deprecated": true,
451
+ "description": "REMOVED — use a viewer-keyed collection (`keyedBy`) instead. civitai.com serves no counters: a declared one does nothing, and documents carry no counts. civitai.com refuses a counter that the collection did not already declare in the app's previous approved version; a collection may keep the counters it already declares (inert) or drop them. Shared collections only. At most 8 distinct names, each lowercase snake_case: a letter, then up to 31 of a-z, 0-9 or _. A counter may not share a name with a mark on the same collection, or with the reserved `report` name.",
451
452
  "maxItems": 8,
452
453
  "uniqueItems": true,
453
454
  "items": {
@@ -458,7 +459,8 @@
458
459
  },
459
460
  "marks": {
460
461
  "type": "array",
461
- "description": "Shared collections only. Names of the per-user marks a viewer can set on a document (for example vote) — at most one of each per viewer per document. A reader sees each mark's count and whether THEY set it, never who else did. At most 8 distinct names, each lowercase snake_case: a letter, then up to 31 of a-z, 0-9 or _. `report` is built in on every shared collection and must NOT be declared. A mark may not share a name with a counter on the same collection.",
462
+ "deprecated": true,
463
+ "description": "REMOVED — use a viewer-keyed collection (`keyedBy`) instead: each viewer's own document is their vote or entry. To report a document, use the moderation report API. civitai.com serves no marks: a declared one does nothing. civitai.com refuses a mark that the collection did not already declare in the app's previous approved version; a collection may keep the marks it already declares (inert) or drop them. Shared collections only. At most 8 distinct names, each lowercase snake_case: a letter, then up to 31 of a-z, 0-9 or _. `report` is reserved and must NOT be declared. A mark may not share a name with a counter on the same collection.",
462
464
  "maxItems": 8,
463
465
  "uniqueItems": true,
464
466
  "items": {