@civitai/app-sdk 0.13.1 → 0.15.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.
Files changed (41) hide show
  1. package/README.md +16 -10
  2. package/dist/blocks/browsingLevel.d.ts +1 -1
  3. package/dist/blocks/browsingLevel.js +1 -1
  4. package/dist/blocks/defineBlock.d.ts +22 -1
  5. package/dist/blocks/defineBlock.d.ts.map +1 -1
  6. package/dist/blocks/defineBlock.js +52 -9
  7. package/dist/blocks/defineBlock.js.map +1 -1
  8. package/dist/blocks/index.d.ts +3 -3
  9. package/dist/blocks/index.d.ts.map +1 -1
  10. package/dist/blocks/index.js +1 -1
  11. package/dist/blocks/messages.d.ts +138 -0
  12. package/dist/blocks/messages.d.ts.map +1 -1
  13. package/dist/blocks/messages.js.map +1 -1
  14. package/dist/blocks/scopes.d.ts +14 -3
  15. package/dist/blocks/scopes.d.ts.map +1 -1
  16. package/dist/blocks/scopes.js +17 -3
  17. package/dist/blocks/scopes.js.map +1 -1
  18. package/dist/blocks/types.d.ts +30 -0
  19. package/dist/blocks/types.d.ts.map +1 -1
  20. package/dist/oauth/authorize.d.ts +13 -0
  21. package/dist/oauth/authorize.d.ts.map +1 -1
  22. package/dist/oauth/authorize.js +13 -0
  23. package/dist/oauth/authorize.js.map +1 -1
  24. package/dist/oauth/pkce.d.ts +11 -1
  25. package/dist/oauth/pkce.d.ts.map +1 -1
  26. package/dist/oauth/pkce.js +11 -1
  27. package/dist/oauth/pkce.js.map +1 -1
  28. package/dist/oauth/token.d.ts +45 -4
  29. package/dist/oauth/token.d.ts.map +1 -1
  30. package/dist/oauth/token.js +45 -4
  31. package/dist/oauth/token.js.map +1 -1
  32. package/dist/orchestrator/index.d.ts +62 -4
  33. package/dist/orchestrator/index.d.ts.map +1 -1
  34. package/dist/orchestrator/index.js +62 -4
  35. package/dist/orchestrator/index.js.map +1 -1
  36. package/dist/scopes/index.d.ts +28 -4
  37. package/dist/scopes/index.d.ts.map +1 -1
  38. package/dist/scopes/index.js +28 -4
  39. package/dist/scopes/index.js.map +1 -1
  40. package/package.json +1 -1
  41. package/schemas/app-block/v1.json +145 -134
@@ -48,12 +48,36 @@ export declare const TokenScopePresets: {
48
48
  readonly Full: number;
49
49
  };
50
50
  export type TokenScopePresetKey = keyof typeof TokenScopePresets;
51
- /** True if the given bitmask grants the named scope. */
51
+ /**
52
+ * True if the given bitmask grants the named scope.
53
+ *
54
+ * @example
55
+ * if (hasScope(token.scope, TokenScope.AIServicesWrite)) allowGeneration();
56
+ */
52
57
  export declare function hasScope(bitmask: number, scope: number): boolean;
53
- /** Return the list of named scopes contained in a bitmask. */
58
+ /**
59
+ * Return the list of named scopes contained in a bitmask (excludes the
60
+ * `None`/`Full` aggregates). The inverse of {@link bitmaskFromScopes}.
61
+ *
62
+ * @example
63
+ * scopesFromBitmask(token.scope); // e.g. ['UserRead', 'AIServicesWrite', 'BuzzRead']
64
+ */
54
65
  export declare function scopesFromBitmask(bitmask: number): TokenScopeKey[];
55
- /** Combine a list of named scopes into a single bitmask. */
66
+ /**
67
+ * Combine a list of named scopes into a single bitmask — use this to build the
68
+ * `scope` you pass to {@link buildAuthorizeUrl} instead of a magic number.
69
+ *
70
+ * @example
71
+ * const scope = bitmaskFromScopes(['AIServicesWrite', 'BuzzRead', 'UserRead']);
72
+ */
56
73
  export declare function bitmaskFromScopes(scopes: readonly TokenScopeKey[]): number;
57
- /** Human-readable label for a tokenScope bitmask (matches the Civitai UI). */
74
+ /**
75
+ * Human-readable label for a tokenScope bitmask (matches the Civitai UI).
76
+ * Returns a preset name (`Full Access`/`Read Only`/`Creator`/`AI Services`),
77
+ * `Legacy` for `null`/`undefined`, or `Custom` for any other combination.
78
+ *
79
+ * @example
80
+ * getScopeLabel(token.scope); // 'AI Services' | 'Custom' | …
81
+ */
58
82
  export declare function getScopeLabel(tokenScope: number | null | undefined): string;
59
83
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scopes/index.ts"],"names":[],"mappings":"AASA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmDb,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,OAAO,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AAC9E,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAE3E,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA0BnD,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;CAmCpB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAEjE,wDAAwD;AACxD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAEhE;AAED,8DAA8D;AAC9D,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,EAAE,CASlE;AAED,4DAA4D;AAC5D,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,MAAM,CAI1E;AAED,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAO3E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scopes/index.ts"],"names":[],"mappings":"AASA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmDb,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,OAAO,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AAC9E,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAE3E,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA0BnD,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;CAmCpB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAEjE;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAEhE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,EAAE,CASlE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,MAAM,CAI1E;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAO3E"}
@@ -118,11 +118,22 @@ export const TokenScopePresets = {
118
118
  TokenScope.BuzzRead,
119
119
  Full: TokenScope.Full,
120
120
  };
121
- /** True if the given bitmask grants the named scope. */
121
+ /**
122
+ * True if the given bitmask grants the named scope.
123
+ *
124
+ * @example
125
+ * if (hasScope(token.scope, TokenScope.AIServicesWrite)) allowGeneration();
126
+ */
122
127
  export function hasScope(bitmask, scope) {
123
128
  return (bitmask & scope) === scope;
124
129
  }
125
- /** Return the list of named scopes contained in a bitmask. */
130
+ /**
131
+ * Return the list of named scopes contained in a bitmask (excludes the
132
+ * `None`/`Full` aggregates). The inverse of {@link bitmaskFromScopes}.
133
+ *
134
+ * @example
135
+ * scopesFromBitmask(token.scope); // e.g. ['UserRead', 'AIServicesWrite', 'BuzzRead']
136
+ */
126
137
  export function scopesFromBitmask(bitmask) {
127
138
  const out = [];
128
139
  for (const [name, bit] of Object.entries(TokenScope)) {
@@ -134,14 +145,27 @@ export function scopesFromBitmask(bitmask) {
134
145
  }
135
146
  return out;
136
147
  }
137
- /** Combine a list of named scopes into a single bitmask. */
148
+ /**
149
+ * Combine a list of named scopes into a single bitmask — use this to build the
150
+ * `scope` you pass to {@link buildAuthorizeUrl} instead of a magic number.
151
+ *
152
+ * @example
153
+ * const scope = bitmaskFromScopes(['AIServicesWrite', 'BuzzRead', 'UserRead']);
154
+ */
138
155
  export function bitmaskFromScopes(scopes) {
139
156
  let mask = 0;
140
157
  for (const s of scopes)
141
158
  mask |= TokenScope[s];
142
159
  return mask;
143
160
  }
144
- /** Human-readable label for a tokenScope bitmask (matches the Civitai UI). */
161
+ /**
162
+ * Human-readable label for a tokenScope bitmask (matches the Civitai UI).
163
+ * Returns a preset name (`Full Access`/`Read Only`/`Creator`/`AI Services`),
164
+ * `Legacy` for `null`/`undefined`, or `Custom` for any other combination.
165
+ *
166
+ * @example
167
+ * getScopeLabel(token.scope); // 'AI Services' | 'Custom' | …
168
+ */
145
169
  export function getScopeLabel(tokenScope) {
146
170
  if (tokenScope == null)
147
171
  return 'Legacy';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/scopes/index.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,gDAAgD;AAChD,mEAAmE;AACnE,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,6EAA6E;AAC7E,sCAAsC;AAEtC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,CAAC;IAEP,oBAAoB;IACpB,QAAQ,EAAE,CAAC,IAAI,CAAC;IAChB,SAAS,EAAE,CAAC,IAAI,CAAC;IAEjB,qBAAqB;IACrB,UAAU,EAAE,CAAC,IAAI,CAAC;IAClB,WAAW,EAAE,CAAC,IAAI,CAAC;IACnB,YAAY,EAAE,CAAC,IAAI,CAAC;IAEpB,wCAAwC;IACxC,SAAS,EAAE,CAAC,IAAI,CAAC;IACjB,UAAU,EAAE,CAAC,IAAI,CAAC;IAClB,WAAW,EAAE,CAAC,IAAI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,IAAI,MAAM;QAAE,IAAI,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAC9C,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,UAAqC;IACjE,IAAI,UAAU,IAAI,IAAI;QAAE,OAAO,QAAQ,CAAC;IACxC,IAAI,UAAU,KAAK,UAAU,CAAC,IAAI;QAAE,OAAO,aAAa,CAAC;IACzD,IAAI,UAAU,KAAK,iBAAiB,CAAC,QAAQ;QAAE,OAAO,WAAW,CAAC;IAClE,IAAI,UAAU,KAAK,iBAAiB,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/D,IAAI,UAAU,KAAK,iBAAiB,CAAC,UAAU;QAAE,OAAO,aAAa,CAAC;IACtE,OAAO,QAAQ,CAAC;AAClB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@civitai/app-sdk",
3
- "version": "0.13.1",
3
+ "version": "0.15.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",
@@ -1,184 +1,195 @@
1
1
  {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://civitai.com/schemas/app-block/v1.json",
4
- "title": "Civitai App Block Manifest v1",
5
- "description": "Manifest shape for a Civitai App Block. Mirrors the runtime check performed by defineBlock() in @civitai/app-sdk/blocks.",
4
+ "title": "Civitai App Block Manifest",
5
+ "description": "THE canonical, server-published schema for block.manifest.json — the ONLY mandatory file in a Civitai App Block. Published at https://civitai.com/schemas/app-block/v1.json. This is the single source of truth for the block manifest contract: the platform's server-side validator (src/server/services/block-manifest-validator.service.ts) and the `civitai` CLI both validate against these same rules. Set this URL as your manifest's `$schema` for editor validation.",
6
6
  "type": "object",
7
- "required": [
8
- "$schema",
9
- "appId",
10
- "blockId",
11
- "version",
12
- "name",
13
- "type",
14
- "targets",
15
- "scopes",
16
- "iframe",
17
- "contentRating",
18
- "minApiVersion"
19
- ],
20
- "additionalProperties": true,
7
+ "required": ["blockId", "version", "name", "contentRating", "scopes"],
21
8
  "properties": {
22
9
  "$schema": {
23
10
  "type": "string",
24
- "const": "https://civitai.com/schemas/app-block/v1.json"
25
- },
26
- "appId": {
27
- "type": "string",
28
- "minLength": 1
11
+ "description": "Optional JSON-Schema reference; ignored by the platform validator."
29
12
  },
30
13
  "blockId": {
31
14
  "type": "string",
32
- "pattern": "^[a-z0-9-]{3,64}$",
33
- "description": "Immutable block identifier. Lowercase letters, digits, and hyphens; 3-64 characters."
15
+ "description": "The block slug. Becomes the canonical submission slug. Lowercase, starts with a letter, hyphen-separated, 3-40 chars.",
16
+ "minLength": 3,
17
+ "maxLength": 40,
18
+ "pattern": "^[a-z][a-z0-9-]*[a-z0-9]$"
34
19
  },
35
20
  "version": {
36
21
  "type": "string",
37
- "pattern": "^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$",
38
- "description": "Semver."
22
+ "description": "Semantic version (x.y.z, optional -prerelease).",
23
+ "minLength": 1,
24
+ "pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
39
25
  },
40
26
  "name": {
41
27
  "type": "string",
42
- "minLength": 1,
43
- "maxLength": 80
28
+ "description": "Human-readable display name. The server only requires a non-empty string (no length cap), so the CLI does not impose one either.",
29
+ "minLength": 1
44
30
  },
45
31
  "type": {
46
32
  "type": "string",
47
- "enum": ["block", "embed"]
33
+ "description": "Free-form descriptor used by some examples (e.g. \"block\"). Not validated by the platform.",
34
+ "enum": ["block"]
48
35
  },
49
- "targets": {
36
+ "contentRating": {
37
+ "type": "string",
38
+ "description": "Content rating of the app surface.",
39
+ "enum": ["g", "pg", "pg13", "r", "x"]
40
+ },
41
+ "renderMode": {
42
+ "type": "string",
43
+ "description": "How the block renders. Defaults to \"iframe\". \"inline\"/\"hybrid\" require a verified/internal trust tier (server-assigned), so authors should leave this as iframe.",
44
+ "enum": ["iframe", "inline", "hybrid"]
45
+ },
46
+ "trustTier": {
47
+ "type": "string",
48
+ "description": "SERVER-OWNED. Do NOT set this in your manifest — the platform assigns the trust tier during review. Present here only to reject dev-set values.",
49
+ "$comment": "Rejected via 'not' below.",
50
+ "enum": ["unverified", "verified", "internal"]
51
+ },
52
+ "scopes": {
50
53
  "type": "array",
51
- "minItems": 1,
54
+ "description": "Capabilities the block requests. Must be a strict subset of what review grants. Each scope is lowercase colon-separated.",
52
55
  "items": {
53
- "type": "object",
54
- "required": ["slotId", "priority"],
55
- "properties": {
56
- "slotId": { "type": "string", "minLength": 1 },
57
- "priority": { "type": "integer" },
58
- "requiredContext": {
59
- "type": "array",
60
- "items": { "type": "string" }
61
- }
62
- }
56
+ "type": "string",
57
+ "enum": [
58
+ "models:read:self",
59
+ "media:read:owned",
60
+ "user:read:self",
61
+ "ai:write:budgeted",
62
+ "buzz:read:self",
63
+ "block:settings:read",
64
+ "block:settings:write",
65
+ "social:tip:self",
66
+ "apps:storage:read",
67
+ "apps:storage:write"
68
+ ]
63
69
  }
64
70
  },
65
- "scopes": {
71
+ "minApiVersion": {
72
+ "type": "string",
73
+ "description": "Minimum App SDK API version the block targets (informational).",
74
+ "pattern": "^\\d+(\\.\\d+)*$"
75
+ },
76
+ "buildCommand": {
77
+ "type": "string",
78
+ "description": "Config-as-code: command the platform runs to build the static bundle (e.g. \"npm run build\"). Omit for no-build (static) apps. When set, outputDir must also be set.",
79
+ "minLength": 1,
80
+ "maxLength": 256
81
+ },
82
+ "outputDir": {
83
+ "type": "string",
84
+ "description": "Config-as-code: directory (relative to the project root) the buildCommand emits static files into (e.g. \"dist\"). Required when buildCommand is set.",
85
+ "minLength": 1,
86
+ "maxLength": 256,
87
+ "pattern": "^[^/].*"
88
+ },
89
+ "publicSettingsKeys": {
66
90
  "type": "array",
67
- "minItems": 1,
91
+ "description": "Allowlist of settings keys exposed to anonymous viewers. Default (omitted) = none exposed.",
92
+ "maxItems": 32,
68
93
  "items": {
69
94
  "type": "string",
70
- "pattern": "^[a-z]+:[a-z]+:[a-z]+$",
71
- "description": "Colon-separated lowercase, e.g. models:read:self. PascalCase is rejected."
95
+ "minLength": 1,
96
+ "maxLength": 64
72
97
  }
73
98
  },
99
+ "assetBundleUrl": {
100
+ "type": "string",
101
+ "description": "Optional v2 surface — HTTPS URL to a hosted asset bundle. Must be a public https URL.",
102
+ "format": "uri",
103
+ "pattern": "^https://"
104
+ },
74
105
  "iframe": {
75
106
  "type": "object",
76
- "required": ["src", "minHeight", "resizable", "sandbox"],
107
+ "description": "iframe envelope. NOTE: iframe.src is SERVER-OWNED — do NOT set it; the platform stamps the canonical bundle URL during build/approve.",
108
+ "additionalProperties": false,
77
109
  "properties": {
78
110
  "src": {
79
- "type": "string",
80
- "description": "HTTPS URL of the block app. http://localhost or http://127.0.0.1 also accepted for local dev."
111
+ "description": "SERVER-OWNED. Do NOT set iframe.src — the platform assigns it. Present here only so the schema can reject dev-set values.",
112
+ "$comment": "Rejected via 'not' below."
113
+ },
114
+ "minHeight": {
115
+ "type": "integer",
116
+ "description": "Minimum iframe height in px.",
117
+ "minimum": 40,
118
+ "maximum": 4000
119
+ },
120
+ "maxHeight": {
121
+ "description": "Maximum iframe height in px, or null for unbounded.",
122
+ "type": ["integer", "null"],
123
+ "minimum": 40,
124
+ "maximum": 4000
125
+ },
126
+ "resizable": {
127
+ "type": "boolean",
128
+ "description": "Whether the host honours RESIZE_IFRAME messages."
81
129
  },
82
- "minHeight": { "type": "integer", "exclusiveMinimum": 0 },
83
- "maxHeight": { "type": ["integer", "null"] },
84
- "resizable": { "type": "boolean" },
85
130
  "sandbox": {
86
131
  "type": "string",
87
- "allOf": [
88
- {
89
- "not": { "pattern": "(^|\\s)allow-same-origin(\\s|$)" },
90
- "description": "Must not contain allow-same-origin — combined with allow-scripts it defeats the sandbox."
91
- },
92
- {
93
- "not": { "pattern": "(^|\\s)allow-top-navigation(\\s|$)" },
94
- "description": "Must not contain allow-top-navigation — use the NAVIGATE postMessage instead."
95
- },
96
- {
97
- "not": { "pattern": "(^|\\s)allow-top-navigation-by-user-activation(\\s|$)" },
98
- "description": "Must not contain allow-top-navigation-by-user-activation — same threat as allow-top-navigation, gated on a user gesture."
99
- },
100
- {
101
- "not": { "pattern": "(^|\\s)allow-top-navigation-to-custom-protocols(\\s|$)" },
102
- "description": "Must not contain allow-top-navigation-to-custom-protocols — same threat as allow-top-navigation, restricted to non-fetch schemes."
103
- }
104
- ]
132
+ "description": "Space-separated iframe sandbox tokens. Unverified tier allows only: allow-scripts, allow-forms. Never combine allow-same-origin with allow-scripts.",
133
+ "minLength": 1
105
134
  }
106
135
  }
107
136
  },
108
- "assets": {
109
- "type": "array",
110
- "items": {
111
- "type": "object",
112
- "required": ["url", "integrity"],
113
- "properties": {
114
- "url": { "type": "string" },
115
- "integrity": {
116
- "type": "string",
117
- "pattern": "^sha(256|384|512)-[A-Za-z0-9+/=]+$"
118
- }
137
+ "page": {
138
+ "type": "object",
139
+ "description": "Full-page surface descriptor (W10). Page apps mount at /apps/run/<slug>.",
140
+ "additionalProperties": false,
141
+ "required": ["path", "title"],
142
+ "properties": {
143
+ "path": {
144
+ "type": "string",
145
+ "description": "Sub-path the page mounts at; must start with '/'.",
146
+ "minLength": 1,
147
+ "maxLength": 256,
148
+ "pattern": "^/"
149
+ },
150
+ "title": {
151
+ "type": "string",
152
+ "description": "Title shown in host chrome.",
153
+ "minLength": 1,
154
+ "maxLength": 128
155
+ },
156
+ "icon": {
157
+ "type": "string",
158
+ "description": "Optional icon name.",
159
+ "maxLength": 128
160
+ },
161
+ "buzzBudgetPerGen": {
162
+ "type": "integer",
163
+ "description": "Optional per-generation Buzz budget for ai:write:budgeted tokens. Positive integer; server-clamped to the per-gen cap.",
164
+ "exclusiveMinimum": 0
119
165
  }
120
166
  }
121
167
  },
122
- "settings": {
168
+ "targets": {
123
169
  "type": "array",
170
+ "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.",
171
+ "maxItems": 16,
124
172
  "items": {
125
173
  "type": "object",
126
- "required": ["id", "type", "label"],
174
+ "required": ["slotId"],
127
175
  "properties": {
128
- "id": { "type": "string", "minLength": 1 },
129
- "type": { "type": "string", "enum": ["string", "number", "boolean", "select"] },
130
- "label": { "type": "string", "minLength": 1 },
131
- "default": {},
132
- "options": {
133
- "type": "array",
134
- "items": {
135
- "type": "object",
136
- "required": ["value", "label"],
137
- "properties": {
138
- "value": { "type": "string" },
139
- "label": { "type": "string" }
140
- }
141
- }
142
- },
143
- "min": { "type": "number" },
144
- "max": { "type": "number" },
145
- "required": { "type": "boolean" }
146
- }
147
- }
148
- },
149
- "contentRating": {
150
- "type": "string",
151
- "enum": ["g", "pg", "pg13", "r", "x"]
152
- },
153
- "preview": {
154
- "type": "object",
155
- "required": ["thumbnail", "description"],
156
- "properties": {
157
- "thumbnail": { "type": "string" },
158
- "description": { "type": "string" },
159
- "screenshots": {
160
- "type": "array",
161
- "items": { "type": "string" }
176
+ "slotId": {
177
+ "type": "string",
178
+ "minLength": 1
179
+ }
162
180
  }
163
181
  }
164
- },
165
- "promotionEligible": { "type": "boolean" },
166
- "minApiVersion": { "type": "string" },
167
- "renderMode": {
168
- "type": "string",
169
- "enum": ["iframe", "inline", "hybrid"],
170
- "description": "Optional. Defaults to iframe. v1 manifests may omit."
171
- },
172
- "assetBundle": {
173
- "type": "object",
174
- "properties": {
175
- "url": { "type": ["string", "null"] },
176
- "sha256": { "type": ["string", "null"] }
182
+ }
183
+ },
184
+ "allOf": [
185
+ {
186
+ "$comment": "outputDir is required whenever buildCommand is set. NOTE: the server-owned iframe.src and trustTier fields are rejected by the platform validator (and the CLI in Go) with clearer error messages than JSON Schema's `not`; they are declared in `properties` above only so the schema documents them.",
187
+ "if": {
188
+ "required": ["buildCommand"]
189
+ },
190
+ "then": {
191
+ "required": ["outputDir"]
177
192
  }
178
- },
179
- "trustTier": {
180
- "type": "string",
181
- "enum": ["unverified", "verified", "internal"]
182
193
  }
183
- }
194
+ ]
184
195
  }