@civitai/app-sdk 0.85.0 → 0.86.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.
@@ -3256,6 +3256,15 @@ export interface BlockManifestV1 {
3256
3256
  * locally is necessary, not sufficient.
3257
3257
  */
3258
3258
  repository?: string;
3259
+ /**
3260
+ * Optional PUBLIC issue-tracker / support link, rendered as a `Support` row
3261
+ * on the app's store detail page. A URL string only (the npm-style
3262
+ * `{ url, email }` object is refused), `https://`, at most 200 chars, any
3263
+ * host. `defineBlock` mirrors the canonical's COARSE pattern; the server also
3264
+ * refuses embedded credentials and a port, so passing locally is necessary,
3265
+ * not sufficient.
3266
+ */
3267
+ bugs?: string;
3259
3268
  preview?: ManifestPreview;
3260
3269
  promotionEligible?: boolean;
3261
3270
  /** Optional; dot-separated integers (e.g. `"1"` or `"1.0"`). Informational. */
@@ -272,6 +272,41 @@ function toManifestError(error, manifest, discriminator) {
272
272
  }
273
273
  return new BlockManifestError(message, field);
274
274
  }
275
+ /**
276
+ * What a manifest that declares no surface is told. Worded as civitai/civitai's
277
+ * `manifestSurfaceError` (block-manifest-validator.service.ts) words the same
278
+ * refusal at submit, so the build and the platform name the same two fixes.
279
+ */
280
+ const NO_SURFACE_MESSAGE = 'manifest must declare at least one surface: add a "page" object for a full-page app ' +
281
+ '(e.g. "page": { "path": "/", "title": "My App" }), or a non-empty "targets" array for a ' +
282
+ 'model-page slot app (e.g. "targets": [{ "slotId": "model.sidebar_top" }])';
283
+ const sameStrings = (a, b) => Array.isArray(a) && a.length === b.length && a.every((v, i) => v === b[i]);
284
+ /**
285
+ * True when `error` comes from the canonical's surface rule: an `anyOf` whose
286
+ * members are exactly "requires `targets`" and "requires `page`" (the
287
+ * top-level `allOf` clause from civitai/civitai#8735). The site is found by
288
+ * reading each failed `anyOf`'s own members off the error list (Ajv's
289
+ * `verbose: true` puts them on `schema`), not by a fixed schema path, so it
290
+ * follows the clause if the canonical reorders its `allOf`.
291
+ *
292
+ * Ajv reports the first member's complaint for that site — "`targets` is
293
+ * required", or "`targets` must NOT have fewer than 1 items" — which names only
294
+ * one of the two fixes, and the one a full-page app does not want. This changes
295
+ * the MESSAGE only: the error was already picked, so the verdict is Ajv's.
296
+ */
297
+ function isSurfaceError(error, errors) {
298
+ return errors.some((site) => {
299
+ if (site.keyword !== 'anyOf')
300
+ return false;
301
+ const members = site.schema;
302
+ if (!Array.isArray(members) || members.length !== 2)
303
+ return false;
304
+ const required = members.map((m) => m?.required);
305
+ if (!sameStrings(required[0], ['targets']) || !sameStrings(required[1], ['page']))
306
+ return false;
307
+ return error.schemaPath === site.schemaPath || error.schemaPath.startsWith(`${site.schemaPath}/`);
308
+ });
309
+ }
275
310
  /**
276
311
  * Validates the manifest against the canonical schema and returns it unchanged.
277
312
  * Acts as a typed identity function — call it from the build (see
@@ -323,6 +358,9 @@ export function defineBlock(config) {
323
358
  /* c8 ignore next */
324
359
  if (!picked)
325
360
  throw new BlockManifestError('manifest failed schema validation');
361
+ if (isSurfaceError(picked.error, validate.errors ?? [])) {
362
+ throw new BlockManifestError(NO_SURFACE_MESSAGE, 'targets');
363
+ }
326
364
  throw toManifestError(picked.error, manifest, picked.discriminator);
327
365
  }
328
366
  // (2) The prose-only server rejections. Strictly additive, one per
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@civitai/app-sdk",
3
- "version": "0.85.0",
3
+ "version": "0.86.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",
@@ -42,6 +42,13 @@
42
42
  "maxLength": 200,
43
43
  "pattern": "^https://(github\\.com|gitlab\\.com|codeberg\\.org)/[^/]+/[^/]+/?$"
44
44
  },
45
+ "bugs": {
46
+ "type": "string",
47
+ "description": "Optional PUBLIC ISSUE-TRACKER / SUPPORT link: a URL string, like `repository`. The npm-style object form (`{ \"url\": ..., \"email\": ... }`) is NOT supported and is refused. Rendered as a `Support` row on the app's `/apps` store DETAIL page. Manifest-governed like `repository`: it flows to the store listing on moderator-approve and is re-synced on every approved version; remove the key and the link is cleared. Must be an `https://` URL, carry no embedded credentials and no port, and be at most 200 characters (MAX_ISSUE_TRACKER_URL_LENGTH in src/server/schema/blocks/external-app.schema.ts). Any host is accepted. Treat passing local validation as necessary, not sufficient — `validateIssueTrackerUrl` in that file is authoritative.",
48
+ "minLength": 1,
49
+ "maxLength": 200,
50
+ "pattern": "^https://"
51
+ },
45
52
  "type": {
46
53
  "type": "string",
47
54
  "description": "Free-form descriptor used by some examples (e.g. \"block\"). Not validated by the platform.",
@@ -194,7 +201,7 @@
194
201
  },
195
202
  "page": {
196
203
  "type": "object",
197
- "description": "Full-page surface descriptor (W10). Page apps mount at /apps/run/<slug>.",
204
+ "description": "Full-page surface descriptor (W10). Page apps mount at /apps/run/<slug>. A manifest without non-empty `targets` must declare `page`.",
198
205
  "additionalProperties": false,
199
206
  "required": ["path", "title"],
200
207
  "properties": {
@@ -607,7 +614,7 @@
607
614
  },
608
615
  "targets": {
609
616
  "type": "array",
610
- "description": "Model-page slot targets. Each target's slotId must be a known registered model slot (not the page slot). Optional for page-only apps.",
617
+ "description": "Model-page slot targets. Each target's slotId must be a known registered model slot (not the page slot). Optional for a page app; a manifest without `page` must declare at least one target.",
611
618
  "maxItems": 16,
612
619
  "items": {
613
620
  "type": "object",
@@ -774,6 +781,20 @@
774
781
  "then": {
775
782
  "required": ["outputDir"]
776
783
  }
784
+ },
785
+ {
786
+ "$comment": "A manifest must declare at least one surface: a non-empty `targets` array (model-page slots) or a `page` object (a full-page app). The platform refuses a submission with neither, and the build would fail it.",
787
+ "anyOf": [
788
+ {
789
+ "required": ["targets"],
790
+ "properties": {
791
+ "targets": { "minItems": 1 }
792
+ }
793
+ },
794
+ {
795
+ "required": ["page"]
796
+ }
797
+ ]
777
798
  }
778
799
  ]
779
800
  }