@speckle/shared
Version:
Shared code between various Speckle JS packages
95 lines • 3.98 kB
TypeScript
export declare const ViewerResourceType: {
readonly Model: "Model";
readonly Object: "Object";
readonly ModelFolder: "ModelFolder";
readonly AllModels: "all-models";
};
export type ViewerResourceType = (typeof ViewerResourceType)[keyof typeof ViewerResourceType];
export interface ViewerResource {
type: ViewerResourceType;
toString(): string;
}
export declare class ViewerAllModelsResource implements ViewerResource {
type: ViewerResourceType;
toString(): string;
}
export declare class ViewerModelResource implements ViewerResource {
type: ViewerResourceType;
modelId: string;
versionId?: string;
constructor(modelId: string, versionId?: string);
toString(): string;
}
export declare class ViewerVersionResource extends ViewerModelResource {
versionId: string;
constructor(modelId: string, versionId: string);
toJSON(): string;
}
export declare class ViewerObjectResource implements ViewerResource {
type: ViewerResourceType;
objectId: string;
constructor(objectId: string);
toString(): string;
}
export declare class ViewerModelFolderResource implements ViewerResource {
type: ViewerResourceType;
folderName: string;
constructor(folderName: string);
toString(): string;
}
export declare const parseResourceFromString: (resourceId: string) => ViewerResource;
export declare function parseUrlParameters(resourceGetParam: string): ViewerResource[];
export declare function createGetParamFromResources(resources: ViewerResource[]): string;
export declare const isAllModelsResource: (r: ViewerResource) => r is ViewerAllModelsResource;
export declare const isModelResource: (r: ViewerResource) => r is ViewerModelResource;
export declare const isObjectResource: (r: ViewerResource) => r is ViewerObjectResource;
export declare const isModelFolderResource: (r: ViewerResource) => r is ViewerModelFolderResource;
type StringViewerResourcesTarget = string | string[];
export type ViewerResourcesTarget = ViewerResourceBuilder | ViewerResource[] | ViewerResource | StringViewerResourcesTarget;
declare class ViewerResourceBuilder implements Iterable<ViewerResource> {
#private;
addAllModels(): this;
addModel(modelId: string, versionId?: string): this;
addModelFolder(folderName: string): this;
addObject(objectId: string): this;
/**
* @deprecated Use 'addResources' or 'addNew' instead
*/
addFromString(stringResources: StringViewerResourcesTarget): this;
addResources(res: ViewerResourcesTarget): this;
/**
* Only add those resources that are not already in the builder.
*/
addNew(incoming: ViewerResourcesTarget, options?: {
/**
* If true, will require exact version matches for model resources
* Default: false
*/
requireExactMatch?: boolean;
}): this;
toString(): string;
toResources(): ViewerResource[];
toResourceIds(): string[];
clear(): this;
clone(): ViewerResourceBuilder;
get length(): number;
/**
* Remove specified versionIds from any model resources
*/
clearVersions(): this;
isEqualTo(resource: ViewerResourcesTarget): boolean;
forEach(callback: (resource: ViewerResource) => void): this;
filter<Res extends ViewerResource>(callback: (resource: ViewerResource) => resource is Res): Res[];
filter(callback: (resource: ViewerResource) => boolean): ViewerResource[];
find<Res extends ViewerResource>(callback: (resource: ViewerResource) => resource is Res): Res | undefined;
find(callback: (resource: ViewerResource) => boolean): ViewerResource | undefined;
map<T>(callback: (resource: ViewerResource) => T): T[];
[Symbol.iterator](): Iterator<ViewerResource>;
}
/**
* Fluent API for easier resource building
*/
export declare function resourceBuilder(): ViewerResourceBuilder;
export type ResourceBuilder = ReturnType<typeof resourceBuilder>;
export {};
//# sourceMappingURL=route.d.ts.map