@sanity/workbench 0.1.0-alpha.6 → 0.1.0-alpha.7
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/{log.js → _chunks-es/index.js} +1 -1
- package/dist/_chunks-es/index.js.map +1 -0
- package/dist/_internal.d.ts +13 -6
- package/dist/_internal.js +19 -3
- package/dist/_internal.js.map +1 -1
- package/dist/core.d.ts +906 -0
- package/dist/core.js +642 -0
- package/dist/core.js.map +1 -0
- package/package.json +10 -4
- package/src/_exports/core.ts +1 -0
- package/src/_internal/index.ts +2 -1
- package/src/_internal/render.test.ts +56 -1
- package/src/_internal/render.ts +51 -24
- package/src/core/__tests__/__fixtures__.ts +248 -0
- package/src/core/applications/application-list.test.ts +222 -0
- package/src/core/applications/application-list.ts +103 -0
- package/src/core/applications/application.ts +78 -0
- package/src/core/applications/local-application.test.ts +93 -0
- package/src/core/applications/local-application.ts +52 -0
- package/src/core/canvases.test.ts +38 -0
- package/src/core/canvases.ts +81 -0
- package/src/core/config.ts +34 -0
- package/src/core/index.ts +12 -0
- package/src/core/media-libraries.test.ts +38 -0
- package/src/core/media-libraries.ts +83 -0
- package/src/core/organizations.test.ts +134 -0
- package/src/core/organizations.ts +115 -0
- package/src/core/projects.test.ts +248 -0
- package/src/core/projects.ts +114 -0
- package/src/core/shared/urls.test.ts +182 -0
- package/src/core/shared/urls.ts +128 -0
- package/src/core/user-applications/core-app.test.ts +151 -0
- package/src/core/user-applications/core-app.ts +57 -0
- package/src/core/user-applications/studio.test.ts +928 -0
- package/src/core/user-applications/studio.ts +656 -0
- package/src/core/user-applications/user-application.test.ts +126 -0
- package/src/core/user-applications/user-application.ts +76 -0
- package/src/vite-env.d.ts +8 -0
- package/dist/log.d.ts +0 -48
- package/dist/log.js.map +0 -1
- package/src/_exports/log.ts +0 -1
- /package/src/{log → core/log}/index.test.ts +0 -0
- /package/src/{log → core/log}/index.ts +0 -0
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,906 @@
|
|
|
1
|
+
import type { ApplicationResource } from "@sanity/message-protocol";
|
|
2
|
+
import type { CanvasResource } from "@sanity/message-protocol";
|
|
3
|
+
import type { CoreApplication } from "@sanity/message-protocol";
|
|
4
|
+
import type { MediaResource } from "@sanity/message-protocol";
|
|
5
|
+
import type { Resource } from "@sanity/message-protocol";
|
|
6
|
+
import type { StudioApplication as StudioApplication_2 } from "@sanity/message-protocol";
|
|
7
|
+
import type { StudioResource } from "@sanity/message-protocol";
|
|
8
|
+
import type { UserApplication as UserApplication_2 } from "@sanity/message-protocol";
|
|
9
|
+
import type { WorkspaceManifest } from "@sanity/message-protocol";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export declare abstract class AbstractApplication<
|
|
16
|
+
TType extends AbstractApplicationType,
|
|
17
|
+
TProtocolResource extends Resource = Extract<
|
|
18
|
+
Resource,
|
|
19
|
+
{
|
|
20
|
+
type: TType;
|
|
21
|
+
}
|
|
22
|
+
>,
|
|
23
|
+
> {
|
|
24
|
+
readonly type: TType;
|
|
25
|
+
constructor(type: TType);
|
|
26
|
+
abstract get href(): string;
|
|
27
|
+
abstract get title(): string;
|
|
28
|
+
abstract get id(): string;
|
|
29
|
+
get initials(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Converts the resource to a protocol resource that comlink expects
|
|
32
|
+
* for backwards compatibility with the old API format.
|
|
33
|
+
*/
|
|
34
|
+
abstract toProtocolResource(): TProtocolResource;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare type AbstractApplicationType =
|
|
41
|
+
| "studio"
|
|
42
|
+
| "coreApp"
|
|
43
|
+
| "canvas"
|
|
44
|
+
| "media-library"
|
|
45
|
+
| "workspace";
|
|
46
|
+
|
|
47
|
+
declare type Application =
|
|
48
|
+
| CoreAppApplication
|
|
49
|
+
| StudioApplication
|
|
50
|
+
| StudioWorkspace
|
|
51
|
+
| CanvasApplication
|
|
52
|
+
| MediaLibraryApplication
|
|
53
|
+
| LocalApplication;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export declare class ApplicationList<
|
|
59
|
+
TApplication extends Application = Application,
|
|
60
|
+
> {
|
|
61
|
+
readonly applications: TApplication[];
|
|
62
|
+
/**
|
|
63
|
+
* @param applications - The applications to initialize the list with.
|
|
64
|
+
*/
|
|
65
|
+
constructor(applications: TApplication[]);
|
|
66
|
+
findApplicationsByType<T extends TApplication["type"]>(
|
|
67
|
+
type: T,
|
|
68
|
+
): Extract<
|
|
69
|
+
TApplication,
|
|
70
|
+
{
|
|
71
|
+
type: T;
|
|
72
|
+
}
|
|
73
|
+
>[];
|
|
74
|
+
findApplicationsByType<T extends TApplication["type"][]>(
|
|
75
|
+
types: T,
|
|
76
|
+
): Extract<
|
|
77
|
+
TApplication,
|
|
78
|
+
{
|
|
79
|
+
type: T[number];
|
|
80
|
+
}
|
|
81
|
+
>[];
|
|
82
|
+
findApplication(type: "media-library"):
|
|
83
|
+
| Extract<
|
|
84
|
+
TApplication,
|
|
85
|
+
{
|
|
86
|
+
type: "media-library";
|
|
87
|
+
}
|
|
88
|
+
>
|
|
89
|
+
| undefined;
|
|
90
|
+
findApplication(type: "canvas"):
|
|
91
|
+
| Extract<
|
|
92
|
+
TApplication,
|
|
93
|
+
{
|
|
94
|
+
type: "canvas";
|
|
95
|
+
}
|
|
96
|
+
>
|
|
97
|
+
| undefined;
|
|
98
|
+
findApplication(
|
|
99
|
+
type: "coreApp",
|
|
100
|
+
id: UserApplicationId,
|
|
101
|
+
):
|
|
102
|
+
| Extract<
|
|
103
|
+
TApplication,
|
|
104
|
+
{
|
|
105
|
+
type: "coreApp";
|
|
106
|
+
}
|
|
107
|
+
>
|
|
108
|
+
| undefined;
|
|
109
|
+
findApplication(
|
|
110
|
+
type: "studio",
|
|
111
|
+
id: UserApplicationId,
|
|
112
|
+
):
|
|
113
|
+
| Extract<
|
|
114
|
+
TApplication,
|
|
115
|
+
{
|
|
116
|
+
type: "studio";
|
|
117
|
+
}
|
|
118
|
+
>
|
|
119
|
+
| undefined;
|
|
120
|
+
findApplication(
|
|
121
|
+
type: "workspace",
|
|
122
|
+
id: string,
|
|
123
|
+
):
|
|
124
|
+
| Extract<
|
|
125
|
+
TApplication,
|
|
126
|
+
{
|
|
127
|
+
type: "workspace";
|
|
128
|
+
}
|
|
129
|
+
>
|
|
130
|
+
| undefined;
|
|
131
|
+
toProtocolResources(): Resource[];
|
|
132
|
+
static areApplicationsEqual(
|
|
133
|
+
application1?: Application,
|
|
134
|
+
application2?: Application,
|
|
135
|
+
): boolean;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Validates and brands a string as a CanvasId.
|
|
140
|
+
* @public
|
|
141
|
+
*/
|
|
142
|
+
export declare function brandCanvasId(id: string): CanvasId;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Validates and brands a string as a MediaLibraryId.
|
|
146
|
+
* @public
|
|
147
|
+
*/
|
|
148
|
+
export declare function brandMediaLibraryId(id: string): MediaLibraryId;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Validates and brands a string as an OrganizationId.
|
|
152
|
+
* @public
|
|
153
|
+
*/
|
|
154
|
+
export declare function brandOrganizationId(id: string): OrganizationId;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Validates and brands a string as a ProjectId.
|
|
158
|
+
* @public
|
|
159
|
+
*/
|
|
160
|
+
export declare function brandProjectId(id: string): ProjectId;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Validates and brands a string as a UserApplicationId.
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
166
|
+
export declare function brandUserApplicationId(id: string): UserApplicationId;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Represents a Canvas resource as returned from the API.
|
|
170
|
+
* @public
|
|
171
|
+
*/
|
|
172
|
+
export declare type Canvas = z.output<typeof Canvas_2>;
|
|
173
|
+
|
|
174
|
+
declare const Canvas_2: z.ZodObject<
|
|
175
|
+
{
|
|
176
|
+
id: z.core.$ZodBranded<z.ZodString, "CanvasId", "out">;
|
|
177
|
+
organizationId: z.core.$ZodBranded<z.ZodString, "OrganizationId", "out">;
|
|
178
|
+
status: z.ZodEnum<{
|
|
179
|
+
active: "active";
|
|
180
|
+
provisioning: "provisioning";
|
|
181
|
+
}>;
|
|
182
|
+
},
|
|
183
|
+
z.core.$strip
|
|
184
|
+
>;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Represents a Canvas resource as returned from the API.
|
|
188
|
+
* @public
|
|
189
|
+
*/
|
|
190
|
+
declare type Canvas = z.output<typeof Canvas_2>;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Whilst the constructor takes an organization's canvas resource the existance
|
|
194
|
+
* therefore implies the organization has access to the canvas application which
|
|
195
|
+
* is what workbench most importantly wants to know.
|
|
196
|
+
* @public
|
|
197
|
+
*/
|
|
198
|
+
export declare class CanvasApplication extends AbstractApplication<"canvas"> {
|
|
199
|
+
private readonly canvas;
|
|
200
|
+
constructor(canvas: Canvas);
|
|
201
|
+
get id(): CanvasId;
|
|
202
|
+
get href(): string;
|
|
203
|
+
get title(): string;
|
|
204
|
+
toProtocolResource(): CanvasResource;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Canvas ID type, branded for type safety.
|
|
209
|
+
* @public
|
|
210
|
+
*/
|
|
211
|
+
export declare type CanvasId = z.output<typeof CanvasId_2>;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Canvas ID schema, branded for type safety.
|
|
215
|
+
* @public
|
|
216
|
+
*/
|
|
217
|
+
declare const CanvasId_2: z.core.$ZodBranded<z.ZodString, "CanvasId", "out">;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Canvas ID type, branded for type safety.
|
|
221
|
+
* @public
|
|
222
|
+
*/
|
|
223
|
+
declare type CanvasId = z.output<typeof CanvasId_2>;
|
|
224
|
+
|
|
225
|
+
declare type CompatibilityStatus =
|
|
226
|
+
(typeof StudioApplication.CompatibilityStatuses)[keyof typeof StudioApplication.CompatibilityStatuses];
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Workbench configuration.
|
|
230
|
+
*
|
|
231
|
+
* @public
|
|
232
|
+
*/
|
|
233
|
+
export declare interface Config {
|
|
234
|
+
/**
|
|
235
|
+
* The organization ID to use when rendering the workbench.
|
|
236
|
+
*/
|
|
237
|
+
organizationId?: string;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* @internal
|
|
242
|
+
*/
|
|
243
|
+
export declare class CoreAppApplication extends UserApplication<
|
|
244
|
+
CoreApplication,
|
|
245
|
+
"coreApp",
|
|
246
|
+
ApplicationResource
|
|
247
|
+
> {
|
|
248
|
+
readonly activeDeployment: CoreApplication["activeDeployment"];
|
|
249
|
+
constructor(application: CoreApplication);
|
|
250
|
+
get href(): string;
|
|
251
|
+
get title(): string;
|
|
252
|
+
get subtitle(): undefined;
|
|
253
|
+
get updatedAt(): string;
|
|
254
|
+
get<TKey extends keyof CoreApplication>(attr: TKey): CoreApplication[TKey];
|
|
255
|
+
toProtocolResource(): ApplicationResource;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* @public
|
|
260
|
+
*/
|
|
261
|
+
export declare function createLogger({
|
|
262
|
+
namespace,
|
|
263
|
+
context: baseContext,
|
|
264
|
+
logLevel,
|
|
265
|
+
}?: LoggerOptions): Logger;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* An Application wrapping a locally-discovered CLI application.
|
|
269
|
+
* Provides a deterministic id, title and href suitable for use in navigation.
|
|
270
|
+
*
|
|
271
|
+
* @internal
|
|
272
|
+
*/
|
|
273
|
+
export declare class LocalApplication extends AbstractApplication<
|
|
274
|
+
"studio" | "coreApp",
|
|
275
|
+
never
|
|
276
|
+
> {
|
|
277
|
+
readonly localApplication: LocalApplicationData;
|
|
278
|
+
constructor(localApplication: LocalApplicationData);
|
|
279
|
+
get id(): string;
|
|
280
|
+
get title(): string;
|
|
281
|
+
get href(): string;
|
|
282
|
+
toProtocolResource(): never;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Raw data for a local application discovered by the CLI dev server.
|
|
287
|
+
*
|
|
288
|
+
* @experimental
|
|
289
|
+
* @public
|
|
290
|
+
*/
|
|
291
|
+
export declare interface LocalApplicationData {
|
|
292
|
+
host: string;
|
|
293
|
+
port: number;
|
|
294
|
+
type: "studio" | "coreApp";
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
declare type LogContext = {
|
|
298
|
+
[key: string]: unknown;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* @public
|
|
303
|
+
*/
|
|
304
|
+
export declare interface Logger {
|
|
305
|
+
error: (message: string, context?: LogContext) => void;
|
|
306
|
+
warn: (message: string, context?: LogContext) => void;
|
|
307
|
+
info: (message: string, context?: LogContext) => void;
|
|
308
|
+
debug: (message: string, context?: LogContext) => void;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
declare interface LoggerOptions {
|
|
312
|
+
namespace?: LogNamespace;
|
|
313
|
+
context?: LogContext;
|
|
314
|
+
logLevel?: LogLevel;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Log levels in order of verbosity (least to most)
|
|
319
|
+
* - none: Silent
|
|
320
|
+
* - error: Critical failures that prevent operation
|
|
321
|
+
* - warn: Issues that may cause problems but don't stop execution
|
|
322
|
+
* - info: High-level informational messages (default)
|
|
323
|
+
* - debug: Detailed debugging information (maintainer level)
|
|
324
|
+
* - trace: Very detailed tracing — sets `internal: true` on context
|
|
325
|
+
* @public
|
|
326
|
+
*/
|
|
327
|
+
export declare type LogLevel = "none" | "error" | "warn" | "info" | "debug";
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Namespaces organize logs by functional domain.
|
|
331
|
+
* @internal
|
|
332
|
+
*/
|
|
333
|
+
export declare type LogNamespace = string;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Represents a MediaLibrary resource as returned from the API.
|
|
337
|
+
* @public
|
|
338
|
+
*/
|
|
339
|
+
export declare type MediaLibrary = z.output<typeof MediaLibrary_2>;
|
|
340
|
+
|
|
341
|
+
declare const MediaLibrary_2: z.ZodObject<
|
|
342
|
+
{
|
|
343
|
+
id: z.core.$ZodBranded<z.ZodString, "MediaLibraryId", "out">;
|
|
344
|
+
organizationId: z.core.$ZodBranded<z.ZodString, "OrganizationId", "out">;
|
|
345
|
+
status: z.ZodEnum<{
|
|
346
|
+
active: "active";
|
|
347
|
+
provisioning: "provisioning";
|
|
348
|
+
}>;
|
|
349
|
+
aclMode: z.ZodEnum<{
|
|
350
|
+
private: "private";
|
|
351
|
+
public: "public";
|
|
352
|
+
}>;
|
|
353
|
+
},
|
|
354
|
+
z.core.$strip
|
|
355
|
+
>;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Represents a MediaLibrary resource as returned from the API.
|
|
359
|
+
* @public
|
|
360
|
+
*/
|
|
361
|
+
declare type MediaLibrary = z.output<typeof MediaLibrary_2>;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Whilst the constructor takes an organization's media library resource the existance
|
|
365
|
+
* therefore implies the organization has access to the media library application which
|
|
366
|
+
* is what workbench most importantly wants to know.
|
|
367
|
+
* @public
|
|
368
|
+
*/
|
|
369
|
+
export declare class MediaLibraryApplication extends AbstractApplication<"media-library"> {
|
|
370
|
+
private readonly library;
|
|
371
|
+
constructor(library: MediaLibrary);
|
|
372
|
+
get id(): string;
|
|
373
|
+
get href(): string;
|
|
374
|
+
get title(): string;
|
|
375
|
+
toProtocolResource(): MediaResource;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* MediaLibrary ID type, branded for type safety.
|
|
380
|
+
* @public
|
|
381
|
+
*/
|
|
382
|
+
export declare type MediaLibraryId = z.output<typeof MediaLibraryId_2>;
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Canvas ID schema, branded for type safety.
|
|
386
|
+
* @public
|
|
387
|
+
*/
|
|
388
|
+
declare const MediaLibraryId_2: z.core.$ZodBranded<
|
|
389
|
+
z.ZodString,
|
|
390
|
+
"MediaLibraryId",
|
|
391
|
+
"out"
|
|
392
|
+
>;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* MediaLibrary ID type, branded for type safety.
|
|
396
|
+
* @public
|
|
397
|
+
*/
|
|
398
|
+
declare type MediaLibraryId = z.output<typeof MediaLibraryId_2>;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Organization schema — validates and brands API responses
|
|
402
|
+
* from the `/organizations/:id` endpoint.
|
|
403
|
+
* @public
|
|
404
|
+
*/
|
|
405
|
+
export declare const Organization: z.ZodObject<
|
|
406
|
+
{
|
|
407
|
+
id: z.core.$ZodBranded<z.ZodString, "OrganizationId", "out">;
|
|
408
|
+
name: z.ZodString;
|
|
409
|
+
slug: z.ZodNullable<z.ZodString>;
|
|
410
|
+
createdAt: z.ZodString;
|
|
411
|
+
updatedAt: z.ZodString;
|
|
412
|
+
dashboardStatus: z.ZodEnum<{
|
|
413
|
+
enabled: "enabled";
|
|
414
|
+
disabled: "disabled";
|
|
415
|
+
}>;
|
|
416
|
+
aiFeaturesStatus: z.ZodEnum<{
|
|
417
|
+
enabled: "enabled";
|
|
418
|
+
disabled: "disabled";
|
|
419
|
+
}>;
|
|
420
|
+
defaultRoleName: z.ZodString;
|
|
421
|
+
},
|
|
422
|
+
z.core.$strip
|
|
423
|
+
>;
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Represents an organization with optional members and
|
|
427
|
+
* features arrays depending on the generic parameters.
|
|
428
|
+
* - `Organization` — base fields only (default)
|
|
429
|
+
* - `Organization<true>` — includes `members`
|
|
430
|
+
* - `Organization<true, true>` — includes both
|
|
431
|
+
* @public
|
|
432
|
+
*/
|
|
433
|
+
export declare type Organization<
|
|
434
|
+
IncludeMembers extends boolean = true,
|
|
435
|
+
IncludeFeatures extends boolean = true,
|
|
436
|
+
> = z.output<typeof Organization> &
|
|
437
|
+
(IncludeMembers extends true
|
|
438
|
+
? {
|
|
439
|
+
members: OrganizationMember[];
|
|
440
|
+
}
|
|
441
|
+
: unknown) &
|
|
442
|
+
(IncludeFeatures extends true
|
|
443
|
+
? {
|
|
444
|
+
features: string[];
|
|
445
|
+
}
|
|
446
|
+
: unknown);
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Organization ID schema, branded for type safety.
|
|
450
|
+
* @public
|
|
451
|
+
*/
|
|
452
|
+
export declare const OrganizationId: z.core.$ZodBranded<
|
|
453
|
+
z.ZodString,
|
|
454
|
+
"OrganizationId",
|
|
455
|
+
"out"
|
|
456
|
+
>;
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Organization ID type, branded for type safety.
|
|
460
|
+
* @public
|
|
461
|
+
*/
|
|
462
|
+
export declare type OrganizationId = z.output<typeof OrganizationId>;
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* @public
|
|
466
|
+
*/
|
|
467
|
+
export declare type OrganizationMember = z.output<typeof OrganizationMember_2>;
|
|
468
|
+
|
|
469
|
+
declare const OrganizationMember_2: z.ZodObject<
|
|
470
|
+
{
|
|
471
|
+
sanityUserId: z.ZodString;
|
|
472
|
+
isCurrentUser: z.ZodBoolean;
|
|
473
|
+
user: z.ZodObject<
|
|
474
|
+
{
|
|
475
|
+
id: z.ZodString;
|
|
476
|
+
displayName: z.ZodString;
|
|
477
|
+
familyName: z.ZodString;
|
|
478
|
+
givenName: z.ZodString;
|
|
479
|
+
middleName: z.ZodNullable<z.ZodString>;
|
|
480
|
+
imageUrl: z.ZodNullable<z.ZodString>;
|
|
481
|
+
email: z.ZodString;
|
|
482
|
+
loginProvider: z.ZodString;
|
|
483
|
+
},
|
|
484
|
+
z.core.$strip
|
|
485
|
+
>;
|
|
486
|
+
roles: z.ZodArray<
|
|
487
|
+
z.ZodObject<
|
|
488
|
+
{
|
|
489
|
+
name: z.ZodString;
|
|
490
|
+
title: z.ZodString;
|
|
491
|
+
description: z.ZodOptional<z.ZodString>;
|
|
492
|
+
},
|
|
493
|
+
z.core.$strip
|
|
494
|
+
>
|
|
495
|
+
>;
|
|
496
|
+
},
|
|
497
|
+
z.core.$strip
|
|
498
|
+
>;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* @public
|
|
502
|
+
*/
|
|
503
|
+
declare type OrganizationMember = z.output<typeof OrganizationMember_2>;
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Validates and parses a raw API response into a branded
|
|
507
|
+
* Canvas.
|
|
508
|
+
* @public
|
|
509
|
+
*/
|
|
510
|
+
export declare function parseCanvas(data: unknown): Canvas;
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Validates and parses a raw API response into a branded
|
|
514
|
+
* MediaLibrary.
|
|
515
|
+
* @public
|
|
516
|
+
*/
|
|
517
|
+
export declare function parseMediaLibrary(data: unknown): MediaLibrary;
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Validates and parses a raw API response into a branded
|
|
521
|
+
* Organization. The options control which schema is used —
|
|
522
|
+
* matching what the API returns based on query params.
|
|
523
|
+
* @public
|
|
524
|
+
*/
|
|
525
|
+
export declare function parseOrganization<
|
|
526
|
+
IncludeMembers extends boolean = true,
|
|
527
|
+
IncludeFeatures extends boolean = true,
|
|
528
|
+
>(
|
|
529
|
+
data: unknown,
|
|
530
|
+
options?: {
|
|
531
|
+
includeMembers?: IncludeMembers;
|
|
532
|
+
includeFeatures?: IncludeFeatures;
|
|
533
|
+
},
|
|
534
|
+
): Organization<IncludeMembers, IncludeFeatures>;
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Validates and parses a raw API response into a branded
|
|
538
|
+
* Project. The options control which schema is used —
|
|
539
|
+
* matching what the API returns based on query params.
|
|
540
|
+
* @public
|
|
541
|
+
*/
|
|
542
|
+
export declare function parseProject<
|
|
543
|
+
IncludeMembers extends boolean = true,
|
|
544
|
+
IncludeFeatures extends boolean = true,
|
|
545
|
+
>(
|
|
546
|
+
data: unknown,
|
|
547
|
+
options?: {
|
|
548
|
+
includeMembers?: IncludeMembers;
|
|
549
|
+
includeFeatures?: IncludeFeatures;
|
|
550
|
+
},
|
|
551
|
+
): Project<IncludeMembers, IncludeFeatures>;
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Project schema — validates and brands API responses
|
|
555
|
+
* from the `/projects/:id` endpoint.
|
|
556
|
+
* @public
|
|
557
|
+
*/
|
|
558
|
+
export declare const Project: z.ZodObject<
|
|
559
|
+
{
|
|
560
|
+
id: z.core.$ZodBranded<z.ZodString, "ProjectId", "out">;
|
|
561
|
+
displayName: z.ZodString;
|
|
562
|
+
studioHost: z.ZodNullable<z.ZodString>;
|
|
563
|
+
organizationId: z.core.$ZodBranded<z.ZodString, "OrganizationId", "out">;
|
|
564
|
+
metadata: z.ZodObject<
|
|
565
|
+
{
|
|
566
|
+
color: z.ZodOptional<z.ZodString>;
|
|
567
|
+
externalStudioHost: z.ZodOptional<z.ZodString>;
|
|
568
|
+
initialTemplate: z.ZodOptional<z.ZodString>;
|
|
569
|
+
cliInitializedAt: z.ZodOptional<z.ZodString>;
|
|
570
|
+
integration: z.ZodLiteral<"manage" | "cli">;
|
|
571
|
+
},
|
|
572
|
+
z.core.$strip
|
|
573
|
+
>;
|
|
574
|
+
isBlocked: z.ZodBoolean;
|
|
575
|
+
isDisabled: z.ZodBoolean;
|
|
576
|
+
isDisabledByUser: z.ZodBoolean;
|
|
577
|
+
activityFeedEnabled: z.ZodBoolean;
|
|
578
|
+
createdAt: z.ZodString;
|
|
579
|
+
updatedAt: z.ZodString;
|
|
580
|
+
},
|
|
581
|
+
z.core.$strip
|
|
582
|
+
>;
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Represents a Sanity project with optional members and
|
|
586
|
+
* features arrays depending on the generic parameters.
|
|
587
|
+
* By default, neither members nor features are included.
|
|
588
|
+
* - `Project` — base fields only (default)
|
|
589
|
+
* - `Project<true>` — includes `members`
|
|
590
|
+
* - `Project<true, true>` — includes both
|
|
591
|
+
* @public
|
|
592
|
+
*/
|
|
593
|
+
export declare type Project<
|
|
594
|
+
IncludeMembers extends boolean = true,
|
|
595
|
+
IncludeFeatures extends boolean = true,
|
|
596
|
+
> = z.output<typeof Project> &
|
|
597
|
+
(IncludeMembers extends true
|
|
598
|
+
? {
|
|
599
|
+
members: ProjectMember[];
|
|
600
|
+
}
|
|
601
|
+
: unknown) &
|
|
602
|
+
(IncludeFeatures extends true
|
|
603
|
+
? {
|
|
604
|
+
features: string[];
|
|
605
|
+
}
|
|
606
|
+
: unknown);
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Project ID schema, branded for type safety.
|
|
610
|
+
* @public
|
|
611
|
+
*/
|
|
612
|
+
export declare const ProjectId: z.core.$ZodBranded<
|
|
613
|
+
z.ZodString,
|
|
614
|
+
"ProjectId",
|
|
615
|
+
"out"
|
|
616
|
+
>;
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Project ID type, branded for type safety.
|
|
620
|
+
* @public
|
|
621
|
+
*/
|
|
622
|
+
export declare type ProjectId = z.output<typeof ProjectId>;
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* @public
|
|
626
|
+
*/
|
|
627
|
+
export declare type ProjectMember = z.output<typeof ProjectMember_2>;
|
|
628
|
+
|
|
629
|
+
declare const ProjectMember_2: z.ZodObject<
|
|
630
|
+
{
|
|
631
|
+
id: z.ZodString;
|
|
632
|
+
createdAt: z.ZodString;
|
|
633
|
+
updatedAt: z.ZodString;
|
|
634
|
+
isCurrentUser: z.ZodBoolean;
|
|
635
|
+
isRobot: z.ZodBoolean;
|
|
636
|
+
roles: z.ZodArray<
|
|
637
|
+
z.ZodObject<
|
|
638
|
+
{
|
|
639
|
+
name: z.ZodString;
|
|
640
|
+
title: z.ZodString;
|
|
641
|
+
description: z.ZodString;
|
|
642
|
+
},
|
|
643
|
+
z.core.$strip
|
|
644
|
+
>
|
|
645
|
+
>;
|
|
646
|
+
},
|
|
647
|
+
z.core.$strip
|
|
648
|
+
>;
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* @public
|
|
652
|
+
*/
|
|
653
|
+
declare type ProjectMember = z.output<typeof ProjectMember_2>;
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Options for rendering a remote module, such as a user application.
|
|
657
|
+
*
|
|
658
|
+
* @public
|
|
659
|
+
*/
|
|
660
|
+
export declare interface RemoteModuleRenderOptions {
|
|
661
|
+
reactStrictMode?: boolean;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* The resolved configuration after processing
|
|
666
|
+
* and validating the provided config.
|
|
667
|
+
*
|
|
668
|
+
* @public
|
|
669
|
+
*/
|
|
670
|
+
export declare type ResolvedConfig = Omit<Config, "organizationId"> & {
|
|
671
|
+
organizationId: OrganizationId;
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* @internal
|
|
676
|
+
*/
|
|
677
|
+
export declare class StudioApplication extends UserApplication<
|
|
678
|
+
StudioApplication_2,
|
|
679
|
+
"studio",
|
|
680
|
+
never
|
|
681
|
+
> {
|
|
682
|
+
/**
|
|
683
|
+
* Returns a list of studio workspaces based on the application manifest.
|
|
684
|
+
* If there is no manifest, or alternatively it is not valid, then we create a default workspace.
|
|
685
|
+
*/
|
|
686
|
+
readonly workspaces: readonly StudioWorkspace[];
|
|
687
|
+
readonly project: Project<false, false>;
|
|
688
|
+
/**
|
|
689
|
+
* @param application - The studio application to create a list of workspaces for
|
|
690
|
+
* @param projects - The projects available in the organization. It's not enough to just pass
|
|
691
|
+
* the project that associates with the application because that is the project the app is deployed in relation to.
|
|
692
|
+
* The workspaces may have different projects completely.
|
|
693
|
+
*/
|
|
694
|
+
constructor(
|
|
695
|
+
application: StudioApplication_2,
|
|
696
|
+
projects: Project<false, false>[],
|
|
697
|
+
);
|
|
698
|
+
get href(): string;
|
|
699
|
+
get title(): string;
|
|
700
|
+
get subtitle(): string;
|
|
701
|
+
get<TKey extends keyof StudioApplication_2>(
|
|
702
|
+
attr: TKey,
|
|
703
|
+
): StudioApplication_2[TKey];
|
|
704
|
+
get hasManifest(): boolean;
|
|
705
|
+
get hasSchema(): boolean;
|
|
706
|
+
private resolveVersion;
|
|
707
|
+
get version(): string | null;
|
|
708
|
+
get compatibilityStatus(): CompatibilityStatus;
|
|
709
|
+
/**
|
|
710
|
+
* Used to calculate the compatibility status of a given studio application.
|
|
711
|
+
* Optionally if you've resolved the version elsewhere provide that value to
|
|
712
|
+
* get the new compatibility status without mutating the application.
|
|
713
|
+
*/
|
|
714
|
+
static resolveCompatibilityStatus(
|
|
715
|
+
application: StudioApplication,
|
|
716
|
+
version?: string | null,
|
|
717
|
+
): CompatibilityStatus;
|
|
718
|
+
get isAutoRedirecting(): boolean;
|
|
719
|
+
/**
|
|
720
|
+
* Mirrors the `isRedirectable` function from Saison defined in
|
|
721
|
+
* https://github.com/sanity-io/saison/blob/83556405d23e07f6d3a71c76249c67e33fe1101f/src/utils/applications.ts
|
|
722
|
+
*
|
|
723
|
+
* Returns whether a studio application is auto-redirecting, meaning it can only be accessed in the context of
|
|
724
|
+
* Dashboard.
|
|
725
|
+
*/
|
|
726
|
+
static resolveIsAutoRedirecting(
|
|
727
|
+
application: StudioApplication,
|
|
728
|
+
versionArg?: string | null,
|
|
729
|
+
): boolean;
|
|
730
|
+
/**
|
|
731
|
+
* Returns a list of issues that prevent the studio from functioning properly in the Dashboard.
|
|
732
|
+
* This static value depends on the version of the studio that comes from the `activeDeployment` property.
|
|
733
|
+
* As such, if the studio is auto-updating, this list will be incorrect & instead you should use
|
|
734
|
+
* the static method `resolveIssues` to get the correct issues by passing the resolved version.
|
|
735
|
+
*/
|
|
736
|
+
get issues(): StudioIssues;
|
|
737
|
+
static resolveIssues(
|
|
738
|
+
application: StudioApplication,
|
|
739
|
+
version?: string | null,
|
|
740
|
+
): StudioIssues;
|
|
741
|
+
protected isFeatureSupported(
|
|
742
|
+
feature: StudioDashboardIssue,
|
|
743
|
+
version?: string | null,
|
|
744
|
+
): boolean;
|
|
745
|
+
toProtocolResource(): never;
|
|
746
|
+
static CompatibilityStatuses: {
|
|
747
|
+
readonly UNKNOWN: "unknown";
|
|
748
|
+
readonly PARTIALLY_COMPATIBLE: "partially-compatible";
|
|
749
|
+
readonly FULLY_COMPATIBLE: "fully-compatible";
|
|
750
|
+
};
|
|
751
|
+
static StudioIssues: {
|
|
752
|
+
readonly ISSUE_ACTIVITY: "ACTIVITY";
|
|
753
|
+
readonly ISSUE_AGENT: "AGENT";
|
|
754
|
+
readonly ISSUE_FAVORITES: "FAVORITES";
|
|
755
|
+
readonly ISSUE_URL_SYNCING: "URL_SYNCING";
|
|
756
|
+
readonly ISSUE_UI_ADJUSTMENT: "UI_ADJUSTMENT";
|
|
757
|
+
readonly ISSUE_CONTENT_MAPPING: "CONTENT_MAPPING";
|
|
758
|
+
readonly ISSUE_LOGIN: "LOGIN";
|
|
759
|
+
readonly ISSUE_MANIFEST: "MANIFEST";
|
|
760
|
+
};
|
|
761
|
+
static Features: (
|
|
762
|
+
| {
|
|
763
|
+
id: "AGENT";
|
|
764
|
+
version: string;
|
|
765
|
+
}
|
|
766
|
+
| {
|
|
767
|
+
id: "FAVORITES";
|
|
768
|
+
version: string;
|
|
769
|
+
}
|
|
770
|
+
| {
|
|
771
|
+
id: "ACTIVITY";
|
|
772
|
+
version: string;
|
|
773
|
+
}
|
|
774
|
+
| {
|
|
775
|
+
id: "URL_SYNCING";
|
|
776
|
+
version: string;
|
|
777
|
+
}
|
|
778
|
+
| {
|
|
779
|
+
id: "UI_ADJUSTMENT";
|
|
780
|
+
version: string;
|
|
781
|
+
}
|
|
782
|
+
| {
|
|
783
|
+
id: "CONTENT_MAPPING";
|
|
784
|
+
version: string;
|
|
785
|
+
}
|
|
786
|
+
| {
|
|
787
|
+
id: "LOGIN";
|
|
788
|
+
version: string;
|
|
789
|
+
}
|
|
790
|
+
)[];
|
|
791
|
+
static MinimumStudioVersion: "2.28.0";
|
|
792
|
+
static MinimumStudioVersionWithNoIssues: string | undefined;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
declare type StudioDashboardIssue =
|
|
796
|
+
(typeof StudioApplication.StudioIssues)[keyof typeof StudioApplication.StudioIssues];
|
|
797
|
+
|
|
798
|
+
declare type StudioIssues = Array<{
|
|
799
|
+
id: StudioDashboardIssue;
|
|
800
|
+
version?: string;
|
|
801
|
+
}>;
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* @internal
|
|
805
|
+
*/
|
|
806
|
+
export declare class StudioWorkspace extends AbstractApplication<
|
|
807
|
+
"workspace",
|
|
808
|
+
StudioResource
|
|
809
|
+
> {
|
|
810
|
+
/**
|
|
811
|
+
* Workspaces always belong to a studio application.
|
|
812
|
+
* They do not exist on their own & therefore can access
|
|
813
|
+
* information about the studio they're in via this property.
|
|
814
|
+
*/
|
|
815
|
+
private readonly studioApplication;
|
|
816
|
+
private readonly workspace;
|
|
817
|
+
readonly project: Project<false, false>;
|
|
818
|
+
private readonly isDefaultWorkspace;
|
|
819
|
+
constructor(
|
|
820
|
+
studioApplication: StudioApplication,
|
|
821
|
+
workspace: Workspace,
|
|
822
|
+
project: Project<false, false>,
|
|
823
|
+
isDefaultWorkspace: boolean,
|
|
824
|
+
);
|
|
825
|
+
/**
|
|
826
|
+
* The studio application that this workspace belongs to.
|
|
827
|
+
*/
|
|
828
|
+
get studio(): StudioApplication;
|
|
829
|
+
get id(): string;
|
|
830
|
+
get href(): string;
|
|
831
|
+
get title(): string;
|
|
832
|
+
get subtitle(): string | null | undefined;
|
|
833
|
+
get<TKey extends Exclude<keyof Workspace, "id" | "icon" | "title">>(
|
|
834
|
+
attr: TKey,
|
|
835
|
+
): Workspace[TKey];
|
|
836
|
+
/**
|
|
837
|
+
* With comlink, studio-applications were not considered applications at all, only workspaces. This is partially why
|
|
838
|
+
* we create default workspaces when the application has no manifest or the manifest has no workspaces.
|
|
839
|
+
*
|
|
840
|
+
* Thereby, to create it we depend on a lot of information from the parent application even if it's duplicated across
|
|
841
|
+
* different workspaces.
|
|
842
|
+
*/
|
|
843
|
+
toProtocolResource(): StudioResource;
|
|
844
|
+
/**
|
|
845
|
+
* @returns the URL to the workspace of a studio application.
|
|
846
|
+
*/
|
|
847
|
+
get url(): URL;
|
|
848
|
+
static makeId(
|
|
849
|
+
applicationId: UserApplicationId,
|
|
850
|
+
workspaceName: string,
|
|
851
|
+
): string;
|
|
852
|
+
static splitId(id: string): [string, string];
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* @internal
|
|
857
|
+
*/
|
|
858
|
+
export declare abstract class UserApplication<
|
|
859
|
+
TUserApplication extends UserApplication_2,
|
|
860
|
+
TType extends Extract<AbstractApplicationType, "coreApp" | "studio">,
|
|
861
|
+
TProtocolResource extends Resource = Extract<
|
|
862
|
+
Resource,
|
|
863
|
+
{
|
|
864
|
+
type: TType;
|
|
865
|
+
}
|
|
866
|
+
>,
|
|
867
|
+
> extends AbstractApplication<TType, TProtocolResource> {
|
|
868
|
+
readonly application: TUserApplication;
|
|
869
|
+
readonly id: UserApplicationId;
|
|
870
|
+
constructor(application: TUserApplication, type: TType);
|
|
871
|
+
abstract get subtitle(): string | undefined;
|
|
872
|
+
/**
|
|
873
|
+
* @returns A fully resolved URL instance for the application.
|
|
874
|
+
* For internal applications, constructs a URL using the Sanity studio domain
|
|
875
|
+
* pattern resolved from the environment at the consuming app's build time.
|
|
876
|
+
* For external applications, returns the provided app host as a URL.
|
|
877
|
+
*/
|
|
878
|
+
get url(): URL;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* User application ID schema, branded for type safety.
|
|
883
|
+
* @public
|
|
884
|
+
*/
|
|
885
|
+
export declare const UserApplicationId: z.core.$ZodBranded<
|
|
886
|
+
z.ZodString,
|
|
887
|
+
"UserApplicationId",
|
|
888
|
+
"out"
|
|
889
|
+
>;
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* User application ID type, branded for type safety.
|
|
893
|
+
* @public
|
|
894
|
+
*/
|
|
895
|
+
export declare type UserApplicationId = z.output<typeof UserApplicationId>;
|
|
896
|
+
|
|
897
|
+
declare type Workspace = Omit<
|
|
898
|
+
WorkspaceManifest,
|
|
899
|
+
"dataset" | "schema" | "projectId"
|
|
900
|
+
> & {
|
|
901
|
+
projectId: ProjectId;
|
|
902
|
+
dataset?: string;
|
|
903
|
+
schema?: string;
|
|
904
|
+
};
|
|
905
|
+
|
|
906
|
+
export {};
|