├── .fernignore ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .prettierrc.yml ├── README.md ├── package.json ├── src ├── Client.ts ├── api │ ├── index.ts │ └── resources │ │ ├── batches │ │ ├── client │ │ │ ├── Client.ts │ │ │ ├── index.ts │ │ │ └── requests │ │ │ │ ├── CreateBatchRequest.ts │ │ │ │ ├── ListBatchesRequest.ts │ │ │ │ └── index.ts │ │ ├── index.ts │ │ └── types │ │ │ ├── Batch.ts │ │ │ ├── BatchList.ts │ │ │ ├── BatchStatus.ts │ │ │ ├── BatchStatusResponse.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── projects │ │ ├── client │ │ │ ├── Client.ts │ │ │ ├── index.ts │ │ │ └── requests │ │ │ │ ├── CreateProjectRequest.ts │ │ │ │ ├── ListProjectsRequest.ts │ │ │ │ ├── SetOntologyRequest.ts │ │ │ │ ├── UpdateProjectParametersRequest.ts │ │ │ │ └── index.ts │ │ ├── index.ts │ │ └── types │ │ │ ├── Project.ts │ │ │ ├── ProjectPramHistory.ts │ │ │ └── index.ts │ │ ├── studio │ │ ├── client │ │ │ ├── Client.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ └── resources │ │ │ ├── assignments │ │ │ ├── client │ │ │ │ ├── Client.ts │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ └── types │ │ │ │ ├── AssignTeammate.ts │ │ │ │ ├── Assignment.ts │ │ │ │ └── index.ts │ │ │ ├── batches │ │ │ ├── client │ │ │ │ ├── Client.ts │ │ │ │ ├── index.ts │ │ │ │ └── requests │ │ │ │ │ ├── SetBatchGroupRequest.ts │ │ │ │ │ ├── SetBatchPrioritiesRequest.ts │ │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ └── types │ │ │ │ ├── Batch.ts │ │ │ │ ├── BatchName.ts │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ └── projectGroups │ │ │ ├── client │ │ │ ├── Client.ts │ │ │ ├── index.ts │ │ │ └── requests │ │ │ │ ├── CreateProjectGroupRequest.ts │ │ │ │ ├── UpdateProjectGroupRequest.ts │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ └── types │ │ │ ├── ProjectGroup.ts │ │ │ ├── Workers.ts │ │ │ └── index.ts │ │ ├── tasks │ │ ├── client │ │ │ ├── Client.ts │ │ │ ├── index.ts │ │ │ └── requests │ │ │ │ ├── CancelTasksRequest.ts │ │ │ │ ├── ListTasksRequest.ts │ │ │ │ ├── SetTaskMetadataRequest.ts │ │ │ │ └── index.ts │ │ ├── index.ts │ │ └── types │ │ │ ├── Annotations.ts │ │ │ ├── ListTasksResponse.ts │ │ │ ├── Task.ts │ │ │ ├── TaskGeometries.ts │ │ │ ├── TaskParams.ts │ │ │ ├── TaskType.ts │ │ │ └── index.ts │ │ ├── teammates │ │ ├── client │ │ │ ├── Client.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ └── types │ │ │ ├── Teammate.ts │ │ │ ├── TeamsInvite.ts │ │ │ └── index.ts │ │ └── video │ │ ├── client │ │ ├── Client.ts │ │ └── index.ts │ │ ├── index.ts │ │ └── types │ │ ├── AnnotationAttribute.ts │ │ ├── Box.ts │ │ ├── CameraIntrinsics.ts │ │ ├── CameraRotationQuaternion.ts │ │ ├── Cuboid.ts │ │ ├── Ellipse.ts │ │ ├── Geometries.ts │ │ ├── Line.ts │ │ ├── Links.ts │ │ ├── ObjectsToAnnotate.ts │ │ ├── Point.ts │ │ ├── Polygon.ts │ │ ├── VideoPlaybackAnnotationRequest.ts │ │ ├── VideoPlaybackAnnotationResponse.ts │ │ ├── VideoPlaybackGeometries.ts │ │ ├── VideoPlaybackParams.ts │ │ └── index.ts ├── core │ ├── auth │ │ ├── BasicAuth.ts │ │ ├── BearerToken.ts │ │ └── index.ts │ ├── fetcher │ │ ├── APIResponse.ts │ │ ├── Fetcher.ts │ │ ├── Supplier.ts │ │ └── index.ts │ ├── index.ts │ └── schemas │ │ ├── Schema.ts │ │ ├── builders │ │ ├── date │ │ │ ├── date.ts │ │ │ └── index.ts │ │ ├── enum │ │ │ ├── enum.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── lazy │ │ │ ├── index.ts │ │ │ ├── lazy.ts │ │ │ └── lazyObject.ts │ │ ├── list │ │ │ ├── index.ts │ │ │ └── list.ts │ │ ├── literals │ │ │ ├── index.ts │ │ │ └── stringLiteral.ts │ │ ├── object-like │ │ │ ├── getObjectLikeUtils.ts │ │ │ ├── index.ts │ │ │ └── types.ts │ │ ├── object │ │ │ ├── index.ts │ │ │ ├── object.ts │ │ │ ├── property.ts │ │ │ └── types.ts │ │ ├── primitives │ │ │ ├── any.ts │ │ │ ├── boolean.ts │ │ │ ├── index.ts │ │ │ ├── number.ts │ │ │ ├── string.ts │ │ │ └── unknown.ts │ │ ├── record │ │ │ ├── index.ts │ │ │ ├── record.ts │ │ │ └── types.ts │ │ ├── schema-utils │ │ │ ├── JsonError.ts │ │ │ ├── ParseError.ts │ │ │ ├── getSchemaUtils.ts │ │ │ ├── index.ts │ │ │ └── stringifyValidationErrors.ts │ │ ├── set │ │ │ ├── index.ts │ │ │ └── set.ts │ │ └── union │ │ │ ├── discriminant.ts │ │ │ ├── index.ts │ │ │ ├── types.ts │ │ │ └── union.ts │ │ ├── index.ts │ │ └── utils │ │ ├── MaybePromise.ts │ │ ├── OptionalRecord.ts │ │ ├── addQuestionMarksToNullableProperties.ts │ │ ├── createIdentitySchemaCreator.ts │ │ ├── entries.ts │ │ ├── filterObject.ts │ │ ├── isPlainObject.ts │ │ ├── keys.ts │ │ └── partition.ts ├── environments.ts ├── errors │ ├── ScaleError.ts │ ├── ScaleTimeoutError.ts │ └── index.ts ├── index.ts └── serialization │ ├── index.ts │ └── resources │ ├── batches │ ├── client │ │ ├── index.ts │ │ └── requests │ │ │ ├── CreateBatchRequest.ts │ │ │ └── index.ts │ ├── index.ts │ └── types │ │ ├── Batch.ts │ │ ├── BatchList.ts │ │ ├── BatchStatus.ts │ │ ├── BatchStatusResponse.ts │ │ └── index.ts │ ├── index.ts │ ├── projects │ ├── client │ │ ├── index.ts │ │ ├── list.ts │ │ └── requests │ │ │ ├── CreateProjectRequest.ts │ │ │ ├── SetOntologyRequest.ts │ │ │ ├── UpdateProjectParametersRequest.ts │ │ │ └── index.ts │ ├── index.ts │ └── types │ │ ├── Project.ts │ │ ├── ProjectPramHistory.ts │ │ └── index.ts │ ├── studio │ ├── index.ts │ └── resources │ │ ├── assignments │ │ ├── client │ │ │ ├── index.ts │ │ │ └── list.ts │ │ ├── index.ts │ │ └── types │ │ │ ├── AssignTeammate.ts │ │ │ ├── Assignment.ts │ │ │ └── index.ts │ │ ├── batches │ │ ├── client │ │ │ ├── index.ts │ │ │ ├── list.ts │ │ │ ├── requests │ │ │ │ ├── SetBatchGroupRequest.ts │ │ │ │ ├── SetBatchPrioritiesRequest.ts │ │ │ │ └── index.ts │ │ │ ├── resetPriorities.ts │ │ │ └── setPriorities.ts │ │ ├── index.ts │ │ └── types │ │ │ ├── Batch.ts │ │ │ ├── BatchName.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ └── projectGroups │ │ ├── client │ │ ├── index.ts │ │ └── requests │ │ │ ├── CreateProjectGroupRequest.ts │ │ │ ├── UpdateProjectGroupRequest.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ └── types │ │ ├── ProjectGroup.ts │ │ ├── Workers.ts │ │ └── index.ts │ ├── tasks │ ├── client │ │ ├── index.ts │ │ └── requests │ │ │ ├── SetTaskMetadataRequest.ts │ │ │ └── index.ts │ ├── index.ts │ └── types │ │ ├── Annotations.ts │ │ ├── ListTasksResponse.ts │ │ ├── Task.ts │ │ ├── TaskGeometries.ts │ │ ├── TaskParams.ts │ │ ├── TaskType.ts │ │ └── index.ts │ ├── teammates │ ├── client │ │ ├── index.ts │ │ └── list.ts │ ├── index.ts │ └── types │ │ ├── Teammate.ts │ │ ├── TeamsInvite.ts │ │ └── index.ts │ └── video │ ├── index.ts │ └── types │ ├── AnnotationAttribute.ts │ ├── Box.ts │ ├── CameraIntrinsics.ts │ ├── CameraRotationQuaternion.ts │ ├── Cuboid.ts │ ├── Ellipse.ts │ ├── Geometries.ts │ ├── Line.ts │ ├── Links.ts │ ├── ObjectsToAnnotate.ts │ ├── Point.ts │ ├── Polygon.ts │ ├── VideoPlaybackAnnotationRequest.ts │ ├── VideoPlaybackAnnotationResponse.ts │ ├── VideoPlaybackGeometries.ts │ ├── VideoPlaybackParams.ts │ └── index.ts ├── static ├── compile-error.png ├── hero.png ├── method-autocomplete.png └── property-autocomplete.png ├── tsconfig.json └── yarn.lock /.fernignore: -------------------------------------------------------------------------------- 1 | # Specify files that shouldn't be modified by Fern 2 | 3 | README.md 4 | static 5 | src/core/auth/BearerToken.ts -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: [push] 4 | 5 | jobs: 6 | compile: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - name: Checkout repo 11 | uses: actions/checkout@v3 12 | 13 | - name: Set up node 14 | uses: actions/setup-node@v3 15 | 16 | - name: Compile 17 | run: yarn && yarn build 18 | 19 | publish: 20 | needs: [ compile ] 21 | if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') 22 | runs-on: ubuntu-latest 23 | 24 | steps: 25 | - name: Checkout repo 26 | uses: actions/checkout@v3 27 | 28 | - name: Set up node 29 | uses: actions/setup-node@v3 30 | 31 | - name: Install dependencies 32 | run: yarn install 33 | 34 | - name: Build 35 | run: yarn build 36 | 37 | - name: Publish to npm 38 | run: | 39 | npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} 40 | npm publish --access public 41 | env: 42 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | /dist 4 | /Client.d.ts 5 | /Client.js 6 | /environments.d.ts 7 | /environments.js 8 | /index.d.ts 9 | /index.js 10 | /api 11 | /core 12 | /errors 13 | /serialization 14 | 15 | # yarn berry 16 | .pnp.* 17 | .yarn/* 18 | !.yarn/patches 19 | !.yarn/plugins 20 | !.yarn/releases 21 | !.yarn/sdks 22 | !.yarn/versions -------------------------------------------------------------------------------- /.prettierrc.yml: -------------------------------------------------------------------------------- 1 | tabWidth: 4 2 | printWidth: 120 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Hero](static/hero.png) 2 | 3 | # Scale Node Library 4 | 5 | [![npm shield](https://img.shields.io/npm/v/scaleapi)](https://www.npmjs.com/package/scaleapi) 6 | [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen)](https://github.com/fern-api/fern) 7 | 8 | The Scale Node.js library provides access to the Scale API from JavaScript/TypeScript. 9 | 10 | ## Documentation 11 | 12 | API reference documentation is available [here](https://docs.scale.com/reference/introduction). 13 | 14 | ## Installation 15 | 16 | ``` 17 | npm install scaleapi 18 | ``` 19 | 20 | or 21 | 22 | ``` 23 | yarn add scaleapi 24 | ``` 25 | 26 | ## Usage 27 | 28 | [![Try it out](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/typescript-scaleapi-sdk?file=app.ts&view=editor) 29 | 30 | ```typescript 31 | import { ScaleClient } from 'scaleapi'; 32 | 33 | const scale = new ScaleClient({ 34 | token: 'YOUR_API_KEY', 35 | }); 36 | 37 | const batch = await scale.batches.create({ 38 | project: 'project-id', 39 | name: 'My project', 40 | }); 41 | 42 | console.log('Received response from Scale', response); 43 | ``` 44 | 45 | ### Authentication 46 | 47 | You can find your API keys on your [dashboard](https://scale.com/dashboard), which you can access by [logging in](https://scale.com/login) or [signing up](https://scale.com/signup). 48 | 49 | When you constuct the `ScaleClient`, you can pass in your API key. 50 | 51 | ```typescript 52 | import { ScaleClient } from 'scaleapi'; 53 | 54 | const scale = new ScaleClient({ 55 | token: process.env.SCALE_API_KEY, 56 | }); 57 | ``` 58 | 59 | You can also pass a function: 60 | 61 | ```typescript 62 | import { ScaleClient } from 'scaleapi'; 63 | 64 | const scale = new ScaleClient({ 65 | token: getScaleApiKey, 66 | }); 67 | 68 | function getScaleApiKey() { 69 | ... 70 | } 71 | ``` 72 | 73 | ### IDE integration 74 | 75 | The Scale SDK is crafted to give you a great experience in your IDE. All types are nested 76 | in the `Scale` export. 77 | 78 | ```typescript 79 | import { ScaleClient, Scale } from 'scaleapi'; 80 | 81 | const scale = new ScaleClient({ 82 | token: process.env.SCALE_API_KEY, 83 | }); 84 | 85 | const batch: Scale.Batch = await scale.batches.create({ 86 | project: 'project-id', 87 | name: 'My project', 88 | }); 89 | ``` 90 | 91 | You'll get autocomplete for methods: 92 | 93 | ![Method autocomplete](static/method-autocomplete.png) 94 | 95 | and properties: 96 | 97 | ![Property autocomplete](static/property-autocomplete.png) 98 | 99 | The SDK is fully typed. If you're using TypeScript, you'll get compiler errors if misuse the SDK: 100 | 101 | ![Compile error](static/compile-error.png) 102 | 103 | ### Error handling 104 | 105 | When an error is encountered, a [`ScaleError`](src/errors/ScaleError.ts) is thrown. The error may contain 106 | a `message` or a response `body`, which you can log to see additional information. 107 | 108 | ```typescript 109 | import { ScaleClient, ScaleError } from 'scaleapi'; 110 | 111 | const scale = new ScaleClient({ 112 | token: process.env.SCALE_API_KEY, 113 | }); 114 | 115 | try { 116 | const batch = await scale.batches.create({ 117 | project: 'project-id', 118 | name: 'My project', 119 | }); 120 | ... 121 | } catch (error) { 122 | if (error instanceof ScaleError) { 123 | console.error("Failed to create batch", error.message, error.body); 124 | } else { 125 | console.error(error); 126 | } 127 | } 128 | ``` 129 | 130 | #### Timeouts 131 | 132 | The Scale SDK will timeout after 60 seconds. When this happens, a [`ScaleTimeoutError`](src/errors/ScaleTimeoutError.ts) 133 | is thrown: 134 | 135 | ```typescript 136 | import { ScaleClient, ScaleTimeoutError } from 'scaleapi'; 137 | 138 | const scale = new ScaleClient({ 139 | token: process.env.SCALE_API_KEY, 140 | }); 141 | 142 | try { 143 | const batch = await scale.batches.create({ 144 | project: 'project-id', 145 | name: 'My project', 146 | }); 147 | ... 148 | } catch (error) { 149 | if (error instanceof ScaleTimeoutError) { 150 | console.error("Timed out while trying to create batch."); 151 | } else { 152 | console.error(error); 153 | } 154 | } 155 | ``` 156 | 157 | ## Beta status 158 | 159 | This SDK is in beta, and there may be breaking changes between versions without 160 | a major version update. Therefore, we recommend pinning the package version to a 161 | specific version in your package.json file. This way, you can install the same 162 | version each time without breaking changes unless you are intentionally looking 163 | for the latest version. 164 | 165 | ## Contributing 166 | 167 | While we value open-source contributions to this SDK, this library is generated 168 | programmatically. Additions made directly to this library would have to be moved 169 | over to our generation code, otherwise they would be overwritten upon the next 170 | generated release. Feel free to open a PR as a proof of concept, but know that 171 | we will not be able to merge it as-is. We suggest [opening an 172 | issue](https://github.com/scaleapi/scaleapi-node/issues) first to discuss with 173 | us! 174 | 175 | On the other hand, contributions to the README are always very welcome! 176 | 177 | ### 🌿 This SDK was generated by [Fern](https://github.com/fern-api/fern) -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "scaleapi", 3 | "version": "3.0.2", 4 | "private": false, 5 | "repository": "https://github.com/scaleapi/scaleapi-node", 6 | "files": [ 7 | "Client.d.ts", 8 | "Client.js", 9 | "environments.d.ts", 10 | "environments.js", 11 | "index.d.ts", 12 | "index.js", 13 | "api", 14 | "core", 15 | "errors", 16 | "serialization" 17 | ], 18 | "main": "./index.js", 19 | "types": "./index.d.ts", 20 | "scripts": { 21 | "format": "prettier --write 'src/**/*.ts'", 22 | "build": "tsc && tsc-alias", 23 | "prepack": "cp -rv dist/. ." 24 | }, 25 | "dependencies": { 26 | "url-join": "4.0.1", 27 | "@types/url-join": "4.0.1", 28 | "basic-auth": "2.0.1", 29 | "@types/basic-auth": "1.1.3", 30 | "js-base64": "3.7.2", 31 | "buffer": "6.0.3", 32 | "axios": "0.27.2" 33 | }, 34 | "devDependencies": { 35 | "@types/node": "17.0.33", 36 | "prettier": "2.7.1", 37 | "tsc-alias": "1.7.1", 38 | "typescript": "4.6.4" 39 | } 40 | } -------------------------------------------------------------------------------- /src/Client.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as environments from "./environments"; 6 | import * as core from "./core"; 7 | import { Batches } from "./api/resources/batches/client/Client"; 8 | import { Projects } from "./api/resources/projects/client/Client"; 9 | import { Studio } from "./api/resources/studio/client/Client"; 10 | import { Tasks } from "./api/resources/tasks/client/Client"; 11 | import { Teammates } from "./api/resources/teammates/client/Client"; 12 | import { Video } from "./api/resources/video/client/Client"; 13 | 14 | export declare namespace ScaleClient { 15 | interface Options { 16 | environment?: environments.ScaleEnvironment | string; 17 | token?: core.Supplier; 18 | } 19 | } 20 | 21 | export class ScaleClient { 22 | constructor(private readonly options: ScaleClient.Options) {} 23 | 24 | private _batches: Batches | undefined; 25 | 26 | public get batches(): Batches { 27 | return (this._batches ??= new Batches(this.options)); 28 | } 29 | 30 | private _projects: Projects | undefined; 31 | 32 | public get projects(): Projects { 33 | return (this._projects ??= new Projects(this.options)); 34 | } 35 | 36 | private _studio: Studio | undefined; 37 | 38 | public get studio(): Studio { 39 | return (this._studio ??= new Studio(this.options)); 40 | } 41 | 42 | private _tasks: Tasks | undefined; 43 | 44 | public get tasks(): Tasks { 45 | return (this._tasks ??= new Tasks(this.options)); 46 | } 47 | 48 | private _teammates: Teammates | undefined; 49 | 50 | public get teammates(): Teammates { 51 | return (this._teammates ??= new Teammates(this.options)); 52 | } 53 | 54 | private _video: Video | undefined; 55 | 56 | public get video(): Video { 57 | return (this._video ??= new Video(this.options)); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/api/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./resources"; 2 | -------------------------------------------------------------------------------- /src/api/resources/batches/client/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./requests"; 2 | -------------------------------------------------------------------------------- /src/api/resources/batches/client/requests/CreateBatchRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface CreateBatchRequest { 6 | project: string; 7 | name: string; 8 | callback?: string; 9 | calibrationBatch?: boolean; 10 | selfLabelBatch?: boolean; 11 | } 12 | -------------------------------------------------------------------------------- /src/api/resources/batches/client/requests/ListBatchesRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface ListBatchesRequest { 6 | /** 7 | * Project name to filter batches by 8 | */ 9 | project?: string; 10 | /** 11 | * Status to filter batches by (`staging` or `in_progress` or `completed`) 12 | */ 13 | status?: string; 14 | /** 15 | * The minimum value of `created_at` for batches to be returned 16 | */ 17 | startTime?: string; 18 | /** 19 | * The maximum value of `created_at` for batches to be returned 20 | */ 21 | endTime?: string; 22 | /** 23 | * The minimum value of 'completed_at' for batches to be returned 24 | */ 25 | completedAfter?: string; 26 | /** 27 | * The maximum value of 'completed_at' for batches to be returned 28 | */ 29 | completedBefore?: string; 30 | /** 31 | * The minimum value of 'last_audited_at' for batches to be returned 32 | */ 33 | auditedAfter?: string; 34 | /** 35 | * The maximum value of 'last_audited_at' for batches to be returned 36 | */ 37 | auditedBefore?: string; 38 | /** 39 | * Number between 1–100, number of results per page (default 100) 40 | */ 41 | limit?: number; 42 | /** 43 | * Number of results to skip for showing following pages (default 0) 44 | */ 45 | offset?: number; 46 | } 47 | -------------------------------------------------------------------------------- /src/api/resources/batches/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { ListBatchesRequest } from "./ListBatchesRequest"; 2 | export { CreateBatchRequest } from "./CreateBatchRequest"; 3 | -------------------------------------------------------------------------------- /src/api/resources/batches/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./client"; 3 | -------------------------------------------------------------------------------- /src/api/resources/batches/types/Batch.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface Batch { 6 | project?: string; 7 | name?: string; 8 | status?: string; 9 | callback?: string; 10 | createdAt?: string; 11 | } 12 | -------------------------------------------------------------------------------- /src/api/resources/batches/types/BatchList.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import { Scale } from "@fern-api/scale"; 6 | 7 | export interface BatchList { 8 | docs?: Scale.Batch[]; 9 | total?: number; 10 | limit?: number; 11 | offset?: number; 12 | hasMore?: boolean; 13 | } 14 | -------------------------------------------------------------------------------- /src/api/resources/batches/types/BatchStatus.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export type BatchStatus = "staging" | "in_progress" | "completed"; 6 | 7 | export const BatchStatus = { 8 | Staging: "staging", 9 | InProgress: "in_progress", 10 | Completed: "completed", 11 | } as const; 12 | -------------------------------------------------------------------------------- /src/api/resources/batches/types/BatchStatusResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import { Scale } from "@fern-api/scale"; 6 | 7 | export interface BatchStatusResponse { 8 | status?: Scale.BatchStatus; 9 | pending?: number; 10 | error?: number; 11 | completed?: number; 12 | canceled?: number; 13 | } 14 | -------------------------------------------------------------------------------- /src/api/resources/batches/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./BatchList"; 2 | export * from "./Batch"; 3 | export * from "./BatchStatusResponse"; 4 | export * from "./BatchStatus"; 5 | -------------------------------------------------------------------------------- /src/api/resources/index.ts: -------------------------------------------------------------------------------- 1 | export * as batches from "./batches"; 2 | export * from "./batches/types"; 3 | export * as projects from "./projects"; 4 | export * from "./projects/types"; 5 | export * as studio from "./studio"; 6 | export * as tasks from "./tasks"; 7 | export * from "./tasks/types"; 8 | export * as teammates from "./teammates"; 9 | export * from "./teammates/types"; 10 | export * as video from "./video"; 11 | export * from "./video/types"; 12 | export * from "./batches/client/requests"; 13 | export * from "./projects/client/requests"; 14 | export * from "./tasks/client/requests"; 15 | -------------------------------------------------------------------------------- /src/api/resources/projects/client/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./requests"; 2 | -------------------------------------------------------------------------------- /src/api/resources/projects/client/requests/CreateProjectRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import { Scale } from "@fern-api/scale"; 6 | 7 | export interface CreateProjectRequest { 8 | type: Scale.TaskType; 9 | name: string; 10 | rapid?: boolean; 11 | params?: Record; 12 | } 13 | -------------------------------------------------------------------------------- /src/api/resources/projects/client/requests/ListProjectsRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface ListProjectsRequest { 6 | /** 7 | * List information for only archived or only unarchived projects. If omitted, information for all projects will be listed. 8 | */ 9 | archived?: boolean; 10 | } 11 | -------------------------------------------------------------------------------- /src/api/resources/projects/client/requests/SetOntologyRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface SetOntologyRequest { 6 | ontology: unknown[]; 7 | name?: string; 8 | } 9 | -------------------------------------------------------------------------------- /src/api/resources/projects/client/requests/UpdateProjectParametersRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface UpdateProjectParametersRequest { 6 | patch?: boolean; 7 | instruction?: string; 8 | } 9 | -------------------------------------------------------------------------------- /src/api/resources/projects/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { ListProjectsRequest } from "./ListProjectsRequest"; 2 | export { CreateProjectRequest } from "./CreateProjectRequest"; 3 | export { UpdateProjectParametersRequest } from "./UpdateProjectParametersRequest"; 4 | export { SetOntologyRequest } from "./SetOntologyRequest"; 5 | -------------------------------------------------------------------------------- /src/api/resources/projects/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./client"; 3 | -------------------------------------------------------------------------------- /src/api/resources/projects/types/Project.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import { Scale } from "@fern-api/scale"; 6 | 7 | export interface Project { 8 | type?: string; 9 | name?: string; 10 | paramHistory?: Scale.ProjectPramHistory[]; 11 | createdAt?: string; 12 | } 13 | -------------------------------------------------------------------------------- /src/api/resources/projects/types/ProjectPramHistory.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface ProjectPramHistory { 6 | instruction?: string; 7 | version?: number; 8 | createdAt?: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/api/resources/projects/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./Project"; 2 | export * from "./ProjectPramHistory"; 3 | -------------------------------------------------------------------------------- /src/api/resources/studio/client/Client.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as environments from "../../../../environments"; 6 | import * as core from "../../../../core"; 7 | import { Assignments } from "../resources/assignments/client/Client"; 8 | import { Batches } from "../resources/batches/client/Client"; 9 | import { ProjectGroups } from "../resources/projectGroups/client/Client"; 10 | 11 | export declare namespace Studio { 12 | interface Options { 13 | environment?: environments.ScaleEnvironment | string; 14 | token?: core.Supplier; 15 | } 16 | } 17 | 18 | export class Studio { 19 | constructor(private readonly options: Studio.Options) {} 20 | 21 | private _assignments: Assignments | undefined; 22 | 23 | public get assignments(): Assignments { 24 | return (this._assignments ??= new Assignments(this.options)); 25 | } 26 | 27 | private _batches: Batches | undefined; 28 | 29 | public get batches(): Batches { 30 | return (this._batches ??= new Batches(this.options)); 31 | } 32 | 33 | private _projectGroups: ProjectGroups | undefined; 34 | 35 | public get projectGroups(): ProjectGroups { 36 | return (this._projectGroups ??= new ProjectGroups(this.options)); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/api/resources/studio/client/index.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /src/api/resources/studio/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./resources"; 2 | export * from "./client"; 3 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/assignments/client/Client.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as environments from "../../../../../../environments"; 6 | import * as core from "../../../../../../core"; 7 | import { Scale } from "@fern-api/scale"; 8 | import urlJoin from "url-join"; 9 | import * as serializers from "../../../../../../serialization"; 10 | import * as errors from "../../../../../../errors"; 11 | 12 | export declare namespace Assignments { 13 | interface Options { 14 | environment?: environments.ScaleEnvironment | string; 15 | token?: core.Supplier; 16 | } 17 | } 18 | 19 | export class Assignments { 20 | constructor(private readonly options: Assignments.Options) {} 21 | 22 | /** 23 | * Gets the current project assignments of all active users in your team (does not include “invited” or “disabled” team members). 24 | */ 25 | public async list(): Promise> { 26 | const _response = await core.fetcher({ 27 | url: urlJoin(this.options.environment ?? environments.ScaleEnvironment.Production, "/studio/assignments"), 28 | method: "GET", 29 | headers: { 30 | Authorization: core.BearerToken.toAuthorizationHeader(await core.Supplier.get(this.options.token)), 31 | }, 32 | }); 33 | if (_response.ok) { 34 | return await serializers.studio.assignments.list.Response.parseOrThrow( 35 | _response.body as serializers.studio.assignments.list.Response.Raw, 36 | { allowUnknownKeys: true } 37 | ); 38 | } 39 | 40 | if (_response.error.reason === "status-code") { 41 | throw new errors.ScaleError({ 42 | statusCode: _response.error.statusCode, 43 | body: _response.error.body, 44 | }); 45 | } 46 | 47 | switch (_response.error.reason) { 48 | case "non-json": 49 | throw new errors.ScaleError({ 50 | statusCode: _response.error.statusCode, 51 | body: _response.error.rawBody, 52 | }); 53 | case "timeout": 54 | throw new errors.ScaleTimeoutError(); 55 | case "unknown": 56 | throw new errors.ScaleError({ 57 | message: _response.error.errorMessage, 58 | }); 59 | } 60 | } 61 | 62 | /** 63 | * Assigns provided projects to specified team members. Returns all team members and their assignments. 64 | */ 65 | public async assignTeammate(request: Scale.studio.AssignTeammate): Promise { 66 | const _response = await core.fetcher({ 67 | url: urlJoin( 68 | this.options.environment ?? environments.ScaleEnvironment.Production, 69 | "/studio/assignments/add" 70 | ), 71 | method: "POST", 72 | headers: { 73 | Authorization: core.BearerToken.toAuthorizationHeader(await core.Supplier.get(this.options.token)), 74 | }, 75 | body: await serializers.studio.AssignTeammate.jsonOrThrow(request), 76 | }); 77 | if (_response.ok) { 78 | return; 79 | } 80 | 81 | if (_response.error.reason === "status-code") { 82 | throw new errors.ScaleError({ 83 | statusCode: _response.error.statusCode, 84 | body: _response.error.body, 85 | }); 86 | } 87 | 88 | switch (_response.error.reason) { 89 | case "non-json": 90 | throw new errors.ScaleError({ 91 | statusCode: _response.error.statusCode, 92 | body: _response.error.rawBody, 93 | }); 94 | case "timeout": 95 | throw new errors.ScaleTimeoutError(); 96 | case "unknown": 97 | throw new errors.ScaleError({ 98 | message: _response.error.errorMessage, 99 | }); 100 | } 101 | } 102 | 103 | /** 104 | * Unassigns provided projects from specified team members. Returns all team members and their assignments. 105 | */ 106 | public async unassignTeammate(request: Scale.studio.AssignTeammate): Promise { 107 | const _response = await core.fetcher({ 108 | url: urlJoin( 109 | this.options.environment ?? environments.ScaleEnvironment.Production, 110 | "/studio/assignments/remove" 111 | ), 112 | method: "POST", 113 | headers: { 114 | Authorization: core.BearerToken.toAuthorizationHeader(await core.Supplier.get(this.options.token)), 115 | }, 116 | body: await serializers.studio.AssignTeammate.jsonOrThrow(request), 117 | }); 118 | if (_response.ok) { 119 | return; 120 | } 121 | 122 | if (_response.error.reason === "status-code") { 123 | throw new errors.ScaleError({ 124 | statusCode: _response.error.statusCode, 125 | body: _response.error.body, 126 | }); 127 | } 128 | 129 | switch (_response.error.reason) { 130 | case "non-json": 131 | throw new errors.ScaleError({ 132 | statusCode: _response.error.statusCode, 133 | body: _response.error.rawBody, 134 | }); 135 | case "timeout": 136 | throw new errors.ScaleTimeoutError(); 137 | case "unknown": 138 | throw new errors.ScaleError({ 139 | message: _response.error.errorMessage, 140 | }); 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/assignments/client/index.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/assignments/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./client"; 3 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/assignments/types/AssignTeammate.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface AssignTeammate { 6 | /** Array of emails of teammates. */ 7 | emails: string[]; 8 | /** Array of projects to assign. */ 9 | projects: string[]; 10 | } 11 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/assignments/types/Assignment.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export type Assignment = string[]; 6 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/assignments/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./Assignment"; 2 | export * from "./AssignTeammate"; 3 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/batches/client/Client.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as environments from "../../../../../../environments"; 6 | import * as core from "../../../../../../core"; 7 | import { Scale } from "@fern-api/scale"; 8 | import urlJoin from "url-join"; 9 | import * as serializers from "../../../../../../serialization"; 10 | import * as errors from "../../../../../../errors"; 11 | 12 | export declare namespace Batches { 13 | interface Options { 14 | environment?: environments.ScaleEnvironment | string; 15 | token?: core.Supplier; 16 | } 17 | } 18 | 19 | export class Batches { 20 | constructor(private readonly options: Batches.Options) {} 21 | 22 | /** 23 | * Returns basic information about all pending batches, in order of priority. 24 | */ 25 | public async list(): Promise { 26 | const _response = await core.fetcher({ 27 | url: urlJoin(this.options.environment ?? environments.ScaleEnvironment.Production, "/studio/batches"), 28 | method: "GET", 29 | headers: { 30 | Authorization: core.BearerToken.toAuthorizationHeader(await core.Supplier.get(this.options.token)), 31 | }, 32 | }); 33 | if (_response.ok) { 34 | return await serializers.studio.batches.list.Response.parseOrThrow( 35 | _response.body as serializers.studio.batches.list.Response.Raw, 36 | { allowUnknownKeys: true } 37 | ); 38 | } 39 | 40 | if (_response.error.reason === "status-code") { 41 | throw new errors.ScaleError({ 42 | statusCode: _response.error.statusCode, 43 | body: _response.error.body, 44 | }); 45 | } 46 | 47 | switch (_response.error.reason) { 48 | case "non-json": 49 | throw new errors.ScaleError({ 50 | statusCode: _response.error.statusCode, 51 | body: _response.error.rawBody, 52 | }); 53 | case "timeout": 54 | throw new errors.ScaleTimeoutError(); 55 | case "unknown": 56 | throw new errors.ScaleError({ 57 | message: _response.error.errorMessage, 58 | }); 59 | } 60 | } 61 | 62 | /** 63 | * Sets (not adds to) labeler group assignment for the specified batch. You can add individual members as well by specifying their email as a group name. Returns information only about the specified batch. 64 | */ 65 | public async setGroups( 66 | batch: string, 67 | request: Scale.studio.SetBatchGroupRequest = {} 68 | ): Promise { 69 | const _response = await core.fetcher({ 70 | url: urlJoin( 71 | this.options.environment ?? environments.ScaleEnvironment.Production, 72 | `/studio/batches/${batch}` 73 | ), 74 | method: "PUT", 75 | headers: { 76 | Authorization: core.BearerToken.toAuthorizationHeader(await core.Supplier.get(this.options.token)), 77 | }, 78 | body: await serializers.studio.SetBatchGroupRequest.jsonOrThrow(request), 79 | }); 80 | if (_response.ok) { 81 | return await serializers.studio.Batch.parseOrThrow(_response.body as serializers.studio.Batch.Raw, { 82 | allowUnknownKeys: true, 83 | }); 84 | } 85 | 86 | if (_response.error.reason === "status-code") { 87 | throw new errors.ScaleError({ 88 | statusCode: _response.error.statusCode, 89 | body: _response.error.body, 90 | }); 91 | } 92 | 93 | switch (_response.error.reason) { 94 | case "non-json": 95 | throw new errors.ScaleError({ 96 | statusCode: _response.error.statusCode, 97 | body: _response.error.rawBody, 98 | }); 99 | case "timeout": 100 | throw new errors.ScaleTimeoutError(); 101 | case "unknown": 102 | throw new errors.ScaleError({ 103 | message: _response.error.errorMessage, 104 | }); 105 | } 106 | } 107 | 108 | /** 109 | * Sets the priority of your batches based on the order of your input. The batches field of the body must be an array of objects, each with variable “name”, each representing a pending batch. You can use the response from the batches endpoint to retrieve all pending Studio batches, then rearrange the batches in the returned array. You must include ALL of the pending batches in your request. Returns all batches in new priority order. 110 | */ 111 | public async setPriorities(request: Scale.studio.SetBatchPrioritiesRequest = {}): Promise { 112 | const _response = await core.fetcher({ 113 | url: urlJoin( 114 | this.options.environment ?? environments.ScaleEnvironment.Production, 115 | "/studio/batches/set_priorities" 116 | ), 117 | method: "POST", 118 | headers: { 119 | Authorization: core.BearerToken.toAuthorizationHeader(await core.Supplier.get(this.options.token)), 120 | }, 121 | body: await serializers.studio.SetBatchPrioritiesRequest.jsonOrThrow(request), 122 | }); 123 | if (_response.ok) { 124 | return await serializers.studio.batches.setPriorities.Response.parseOrThrow( 125 | _response.body as serializers.studio.batches.setPriorities.Response.Raw, 126 | { allowUnknownKeys: true } 127 | ); 128 | } 129 | 130 | if (_response.error.reason === "status-code") { 131 | throw new errors.ScaleError({ 132 | statusCode: _response.error.statusCode, 133 | body: _response.error.body, 134 | }); 135 | } 136 | 137 | switch (_response.error.reason) { 138 | case "non-json": 139 | throw new errors.ScaleError({ 140 | statusCode: _response.error.statusCode, 141 | body: _response.error.rawBody, 142 | }); 143 | case "timeout": 144 | throw new errors.ScaleTimeoutError(); 145 | case "unknown": 146 | throw new errors.ScaleError({ 147 | message: _response.error.errorMessage, 148 | }); 149 | } 150 | } 151 | 152 | /** 153 | * Restores batch priority order to default order. Default order is sorted by calibration batches first, then by creation date. Returns all batches in new priority order. 154 | */ 155 | public async resetPriorities(): Promise { 156 | const _response = await core.fetcher({ 157 | url: urlJoin( 158 | this.options.environment ?? environments.ScaleEnvironment.Production, 159 | "/studio/batches/reset_priorities" 160 | ), 161 | method: "POST", 162 | headers: { 163 | Authorization: core.BearerToken.toAuthorizationHeader(await core.Supplier.get(this.options.token)), 164 | }, 165 | }); 166 | if (_response.ok) { 167 | return await serializers.studio.batches.resetPriorities.Response.parseOrThrow( 168 | _response.body as serializers.studio.batches.resetPriorities.Response.Raw, 169 | { allowUnknownKeys: true } 170 | ); 171 | } 172 | 173 | if (_response.error.reason === "status-code") { 174 | throw new errors.ScaleError({ 175 | statusCode: _response.error.statusCode, 176 | body: _response.error.body, 177 | }); 178 | } 179 | 180 | switch (_response.error.reason) { 181 | case "non-json": 182 | throw new errors.ScaleError({ 183 | statusCode: _response.error.statusCode, 184 | body: _response.error.rawBody, 185 | }); 186 | case "timeout": 187 | throw new errors.ScaleTimeoutError(); 188 | case "unknown": 189 | throw new errors.ScaleError({ 190 | message: _response.error.errorMessage, 191 | }); 192 | } 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/batches/client/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./requests"; 2 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/batches/client/requests/SetBatchGroupRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface SetBatchGroupRequest { 6 | groups?: string[]; 7 | } 8 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/batches/client/requests/SetBatchPrioritiesRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import { Scale } from "@fern-api/scale"; 6 | 7 | export interface SetBatchPrioritiesRequest { 8 | groups?: Scale.studio.BatchName[]; 9 | } 10 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/batches/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { SetBatchGroupRequest } from "./SetBatchGroupRequest"; 2 | export { SetBatchPrioritiesRequest } from "./SetBatchPrioritiesRequest"; 3 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/batches/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./client"; 3 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/batches/types/Batch.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface Batch { 6 | /** Batch id */ 7 | id?: string; 8 | /** Batch name */ 9 | name?: string; 10 | /** Project id */ 11 | projectId?: string; 12 | /** Project name */ 13 | projectName?: string; 14 | /** Batch type, can be `Production` or `Calibration` */ 15 | batchType?: string; 16 | /** Priority of batch */ 17 | studioPriority?: number; 18 | /** Total tasks in batch */ 19 | total?: number; 20 | /** Completed tasks in batch */ 21 | completed?: number; 22 | /** List of project groups in batch */ 23 | groups?: string[]; 24 | } 25 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/batches/types/BatchName.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | /** 6 | * Batch name object 7 | */ 8 | export interface BatchName { 9 | /** Batch name */ 10 | name: string; 11 | } 12 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/batches/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./BatchName"; 2 | export * from "./Batch"; 3 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/index.ts: -------------------------------------------------------------------------------- 1 | export * as assignments from "./assignments"; 2 | export * from "./assignments/types"; 3 | export * as batches from "./batches"; 4 | export * from "./batches/types"; 5 | export * as projectGroups from "./projectGroups"; 6 | export * from "./projectGroups/types"; 7 | export * from "./batches/client/requests"; 8 | export * from "./projectGroups/client/requests"; 9 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/projectGroups/client/Client.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as environments from "../../../../../../environments"; 6 | import * as core from "../../../../../../core"; 7 | import { Scale } from "@fern-api/scale"; 8 | import urlJoin from "url-join"; 9 | import * as serializers from "../../../../../../serialization"; 10 | import * as errors from "../../../../../../errors"; 11 | 12 | export declare namespace ProjectGroups { 13 | interface Options { 14 | environment?: environments.ScaleEnvironment | string; 15 | token?: core.Supplier; 16 | } 17 | } 18 | 19 | export class ProjectGroups { 20 | constructor(private readonly options: ProjectGroups.Options) {} 21 | 22 | /** 23 | * Returns all labeler groups for the project specified in URL. 24 | */ 25 | public async list(project: string): Promise { 26 | const _response = await core.fetcher({ 27 | url: urlJoin( 28 | this.options.environment ?? environments.ScaleEnvironment.Production, 29 | `/studio/projects/${project}/groups` 30 | ), 31 | method: "GET", 32 | headers: { 33 | Authorization: core.BearerToken.toAuthorizationHeader(await core.Supplier.get(this.options.token)), 34 | }, 35 | }); 36 | if (_response.ok) { 37 | return await serializers.studio.ProjectGroup.parseOrThrow( 38 | _response.body as serializers.studio.ProjectGroup.Raw, 39 | { allowUnknownKeys: true } 40 | ); 41 | } 42 | 43 | if (_response.error.reason === "status-code") { 44 | throw new errors.ScaleError({ 45 | statusCode: _response.error.statusCode, 46 | body: _response.error.body, 47 | }); 48 | } 49 | 50 | switch (_response.error.reason) { 51 | case "non-json": 52 | throw new errors.ScaleError({ 53 | statusCode: _response.error.statusCode, 54 | body: _response.error.rawBody, 55 | }); 56 | case "timeout": 57 | throw new errors.ScaleTimeoutError(); 58 | case "unknown": 59 | throw new errors.ScaleError({ 60 | message: _response.error.errorMessage, 61 | }); 62 | } 63 | } 64 | 65 | /** 66 | * Creates a group with the provided name for the project specified in the URL and adds team members. Only returns information about that specific group. Team members must be assigned to the specified project to be added to a group in that project. 67 | */ 68 | public async create(project: string, request: Scale.studio.CreateProjectGroupRequest): Promise { 69 | const _response = await core.fetcher({ 70 | url: urlJoin( 71 | this.options.environment ?? environments.ScaleEnvironment.Production, 72 | `/studio/projects/${project}/groups` 73 | ), 74 | method: "POST", 75 | headers: { 76 | Authorization: core.BearerToken.toAuthorizationHeader(await core.Supplier.get(this.options.token)), 77 | }, 78 | body: await serializers.studio.CreateProjectGroupRequest.jsonOrThrow(request), 79 | }); 80 | if (_response.ok) { 81 | return; 82 | } 83 | 84 | if (_response.error.reason === "status-code") { 85 | throw new errors.ScaleError({ 86 | statusCode: _response.error.statusCode, 87 | body: _response.error.body, 88 | }); 89 | } 90 | 91 | switch (_response.error.reason) { 92 | case "non-json": 93 | throw new errors.ScaleError({ 94 | statusCode: _response.error.statusCode, 95 | body: _response.error.rawBody, 96 | }); 97 | case "timeout": 98 | throw new errors.ScaleTimeoutError(); 99 | case "unknown": 100 | throw new errors.ScaleError({ 101 | message: _response.error.errorMessage, 102 | }); 103 | } 104 | } 105 | 106 | /** 107 | * Adds or removes team members from specified labeler group. Only returns information about that specific group. 108 | */ 109 | public async update( 110 | project: string, 111 | group: string, 112 | request: Scale.studio.UpdateProjectGroupRequest = {} 113 | ): Promise { 114 | const _response = await core.fetcher({ 115 | url: urlJoin( 116 | this.options.environment ?? environments.ScaleEnvironment.Production, 117 | `/studio/projects/${project}/groups/${group}` 118 | ), 119 | method: "PUT", 120 | headers: { 121 | Authorization: core.BearerToken.toAuthorizationHeader(await core.Supplier.get(this.options.token)), 122 | }, 123 | body: await serializers.studio.UpdateProjectGroupRequest.jsonOrThrow(request), 124 | }); 125 | if (_response.ok) { 126 | return; 127 | } 128 | 129 | if (_response.error.reason === "status-code") { 130 | throw new errors.ScaleError({ 131 | statusCode: _response.error.statusCode, 132 | body: _response.error.body, 133 | }); 134 | } 135 | 136 | switch (_response.error.reason) { 137 | case "non-json": 138 | throw new errors.ScaleError({ 139 | statusCode: _response.error.statusCode, 140 | body: _response.error.rawBody, 141 | }); 142 | case "timeout": 143 | throw new errors.ScaleTimeoutError(); 144 | case "unknown": 145 | throw new errors.ScaleError({ 146 | message: _response.error.errorMessage, 147 | }); 148 | } 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/projectGroups/client/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./requests"; 2 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/projectGroups/client/requests/CreateProjectGroupRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface CreateProjectGroupRequest { 6 | emails: string[]; 7 | name: string; 8 | } 9 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/projectGroups/client/requests/UpdateProjectGroupRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface UpdateProjectGroupRequest { 6 | addEmails?: string[]; 7 | removeEmails?: string[]; 8 | } 9 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/projectGroups/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { CreateProjectGroupRequest } from "./CreateProjectGroupRequest"; 2 | export { UpdateProjectGroupRequest } from "./UpdateProjectGroupRequest"; 3 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/projectGroups/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./client"; 3 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/projectGroups/types/ProjectGroup.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import { Scale } from "@fern-api/scale"; 6 | 7 | export interface ProjectGroup { 8 | /** Project group id */ 9 | id?: string; 10 | /** Name of project group */ 11 | name?: string; 12 | /** Number of workers in project group */ 13 | numWorkers?: number; 14 | /** Is this project group for 1 teammate? */ 15 | isSingleton?: boolean; 16 | workers?: Scale.studio.Workers[]; 17 | } 18 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/projectGroups/types/Workers.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface Workers { 6 | /** worker id */ 7 | id: string; 8 | /** worker email */ 9 | email: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/api/resources/studio/resources/projectGroups/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./ProjectGroup"; 2 | export * from "./Workers"; 3 | -------------------------------------------------------------------------------- /src/api/resources/tasks/client/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./requests"; 2 | -------------------------------------------------------------------------------- /src/api/resources/tasks/client/requests/CancelTasksRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface CancelTasksRequest { 6 | /** 7 | * If `true`, will clear a task's `unique_id`, thus allowing the same unique id to be used in future tasks. 8 | */ 9 | clearUniqueId?: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/api/resources/tasks/client/requests/ListTasksRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface ListTasksRequest { 6 | /** 7 | * The minimum value of `created_at` for tasks to be returned 8 | */ 9 | startTime?: string; 10 | /** 11 | * The maximum value of `created_at` for tasks to be returned 12 | */ 13 | endTime?: string; 14 | /** 15 | * The minimum value of `completed_at` for tasks to be returned 16 | */ 17 | completedAfter?: string; 18 | /** 19 | * The maximum value of `completed_at` for tasks to be returned 20 | */ 21 | completedBefore?: string; 22 | /** 23 | * The minimum value of `updated_at` for tasks to be returned 24 | */ 25 | updatedAfter?: string; 26 | /** 27 | * The maximum value of `updated_at` for tasks to be returned 28 | */ 29 | updatedBefore?: string; 30 | /** 31 | * The status of the task - can be: `completed`, `pending`, or `canceled` 32 | */ 33 | status?: string; 34 | /** 35 | * The type of the task 36 | */ 37 | type?: string; 38 | /** 39 | * The name of the project that the returned tasks must belong to 40 | */ 41 | project?: string; 42 | /** 43 | * The name of the batch that the returned tasks must belong to 44 | */ 45 | batch?: string; 46 | /** 47 | * A number between 1 and 100, the maximum number of results to display per page | optional, default 100 48 | */ 49 | limit?: number; 50 | /** 51 | * Set to true if the returned Task Object should include presigned attachment urls. 52 | */ 53 | includeAttachmentUrl?: boolean; 54 | /** 55 | * A token used to retrieve the next page of results if there are more. 56 | */ 57 | nextToken?: string; 58 | } 59 | -------------------------------------------------------------------------------- /src/api/resources/tasks/client/requests/SetTaskMetadataRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface SetTaskMetadataRequest { 6 | docs: Record; 7 | } 8 | -------------------------------------------------------------------------------- /src/api/resources/tasks/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { ListTasksRequest } from "./ListTasksRequest"; 2 | export { CancelTasksRequest } from "./CancelTasksRequest"; 3 | export { SetTaskMetadataRequest } from "./SetTaskMetadataRequest"; 4 | -------------------------------------------------------------------------------- /src/api/resources/tasks/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./client"; 3 | -------------------------------------------------------------------------------- /src/api/resources/tasks/types/Annotations.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface Annotations { 6 | objectsToAnnotate?: string[]; 7 | } 8 | -------------------------------------------------------------------------------- /src/api/resources/tasks/types/ListTasksResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import { Scale } from "@fern-api/scale"; 6 | 7 | export interface ListTasksResponse { 8 | docs?: Scale.Task[]; 9 | total?: number; 10 | limit?: number; 11 | hasMore?: boolean; 12 | nextToken?: string; 13 | } 14 | -------------------------------------------------------------------------------- /src/api/resources/tasks/types/Task.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import { Scale } from "@fern-api/scale"; 6 | 7 | export interface Task { 8 | taskId?: string; 9 | createdAt?: string; 10 | callbackUrl?: string; 11 | type?: string; 12 | status?: string; 13 | instruction?: string; 14 | params?: Scale.TaskParams; 15 | /** A set of key/value pairs that you can attach to a task object. It can be useful for storing additional information about the task in a structured format. Max 10KB. */ 16 | metadata?: Record; 17 | } 18 | -------------------------------------------------------------------------------- /src/api/resources/tasks/types/TaskGeometries.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import { Scale } from "@fern-api/scale"; 6 | 7 | export interface TaskGeometries { 8 | box?: Scale.Annotations; 9 | } 10 | -------------------------------------------------------------------------------- /src/api/resources/tasks/types/TaskParams.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import { Scale } from "@fern-api/scale"; 6 | 7 | export interface TaskParams { 8 | attachment?: string; 9 | geometries?: Scale.TaskGeometries; 10 | } 11 | -------------------------------------------------------------------------------- /src/api/resources/tasks/types/TaskType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export type TaskType = 6 | | "annotation" 7 | | "categorization" 8 | | "comparison" 9 | | "cuboidannotation" 10 | | "datacollection" 11 | | "documentmodel" 12 | | "documenttranscription" 13 | | "imageannotation" 14 | | "laneannotation" 15 | | "lidarannotation" 16 | | "lidarlinking" 17 | | "lidarsegmentation" 18 | | "lidartopdown" 19 | | "lineannotation" 20 | | "namedentityrecognition" 21 | | "pointannotation" 22 | | "polygonannotation" 23 | | "segmentannotation" 24 | | "transcription" 25 | | "textcollection" 26 | | "videoannotation" 27 | | "videoboxannotation" 28 | | "videoplaybackannotation" 29 | | "videocuboidannotation"; 30 | 31 | export const TaskType = { 32 | Annotation: "annotation", 33 | Categorization: "categorization", 34 | Comparison: "comparison", 35 | CuboidAnnotation: "cuboidannotation", 36 | DataCollection: "datacollection", 37 | DocumentModel: "documentmodel", 38 | DocumentTranscription: "documenttranscription", 39 | ImageAnnotation: "imageannotation", 40 | LaneAnnotation: "laneannotation", 41 | LidarAnnotation: "lidarannotation", 42 | LidarLinking: "lidarlinking", 43 | LidarSegmentation: "lidarsegmentation", 44 | LidarTopdown: "lidartopdown", 45 | LineAnnotation: "lineannotation", 46 | NamedEntityRecognition: "namedentityrecognition", 47 | PointAnnotation: "pointannotation", 48 | PolygonAnnotation: "polygonannotation", 49 | SegmentAnnotation: "segmentannotation", 50 | Transcription: "transcription", 51 | TextCollection: "textcollection", 52 | VideoAnnotation: "videoannotation", 53 | VideoBoxAnnotation: "videoboxannotation", 54 | VideoPlaybackAnnotation: "videoplaybackannotation", 55 | VideoCuboidAnnotation: "videocuboidannotation", 56 | } as const; 57 | -------------------------------------------------------------------------------- /src/api/resources/tasks/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./ListTasksResponse"; 2 | export * from "./TaskType"; 3 | export * from "./Task"; 4 | export * from "./Annotations"; 5 | export * from "./TaskGeometries"; 6 | export * from "./TaskParams"; 7 | -------------------------------------------------------------------------------- /src/api/resources/teammates/client/Client.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as environments from "../../../../environments"; 6 | import * as core from "../../../../core"; 7 | import { Scale } from "@fern-api/scale"; 8 | import urlJoin from "url-join"; 9 | import * as serializers from "../../../../serialization"; 10 | import * as errors from "../../../../errors"; 11 | 12 | export declare namespace Teammates { 13 | interface Options { 14 | environment?: environments.ScaleEnvironment | string; 15 | token?: core.Supplier; 16 | } 17 | } 18 | 19 | export class Teammates { 20 | constructor(private readonly options: Teammates.Options) {} 21 | 22 | /** 23 | * Retrieves basic information about all team members associate with your account. 24 | */ 25 | public async list(): Promise { 26 | const _response = await core.fetcher({ 27 | url: urlJoin(this.options.environment ?? environments.ScaleEnvironment.Production, "/teams"), 28 | method: "GET", 29 | headers: { 30 | Authorization: core.BearerToken.toAuthorizationHeader(await core.Supplier.get(this.options.token)), 31 | }, 32 | }); 33 | if (_response.ok) { 34 | return await serializers.teammates.list.Response.parseOrThrow( 35 | _response.body as serializers.teammates.list.Response.Raw, 36 | { allowUnknownKeys: true } 37 | ); 38 | } 39 | 40 | if (_response.error.reason === "status-code") { 41 | throw new errors.ScaleError({ 42 | statusCode: _response.error.statusCode, 43 | body: _response.error.body, 44 | }); 45 | } 46 | 47 | switch (_response.error.reason) { 48 | case "non-json": 49 | throw new errors.ScaleError({ 50 | statusCode: _response.error.statusCode, 51 | body: _response.error.rawBody, 52 | }); 53 | case "timeout": 54 | throw new errors.ScaleTimeoutError(); 55 | case "unknown": 56 | throw new errors.ScaleError({ 57 | message: _response.error.errorMessage, 58 | }); 59 | } 60 | } 61 | 62 | /** 63 | * Invites one or multiple users by email to your team. `team_role` can be either `labeler`, `member`, or `manager`. Returns information about all team members. 64 | */ 65 | public async invite(request: Scale.TeamsInvite): Promise { 66 | const _response = await core.fetcher({ 67 | url: urlJoin(this.options.environment ?? environments.ScaleEnvironment.Production, "/teams/invite"), 68 | method: "POST", 69 | headers: { 70 | Authorization: core.BearerToken.toAuthorizationHeader(await core.Supplier.get(this.options.token)), 71 | }, 72 | body: await serializers.TeamsInvite.jsonOrThrow(request), 73 | }); 74 | if (_response.ok) { 75 | return; 76 | } 77 | 78 | if (_response.error.reason === "status-code") { 79 | throw new errors.ScaleError({ 80 | statusCode: _response.error.statusCode, 81 | body: _response.error.body, 82 | }); 83 | } 84 | 85 | switch (_response.error.reason) { 86 | case "non-json": 87 | throw new errors.ScaleError({ 88 | statusCode: _response.error.statusCode, 89 | body: _response.error.rawBody, 90 | }); 91 | case "timeout": 92 | throw new errors.ScaleTimeoutError(); 93 | case "unknown": 94 | throw new errors.ScaleError({ 95 | message: _response.error.errorMessage, 96 | }); 97 | } 98 | } 99 | 100 | /** 101 | * Changes the role of non-admin team members. `emails` should be a list of emails of team members who are either labelers, members, managers, or disabled. `team_role` should be one of `labeler`, `member`, or `manager`. Returns information about all members of your team. 102 | */ 103 | public async updateRole(request: Scale.TeamsInvite): Promise { 104 | const _response = await core.fetcher({ 105 | url: urlJoin(this.options.environment ?? environments.ScaleEnvironment.Production, "/teams/set_role"), 106 | method: "POST", 107 | headers: { 108 | Authorization: core.BearerToken.toAuthorizationHeader(await core.Supplier.get(this.options.token)), 109 | }, 110 | body: await serializers.TeamsInvite.jsonOrThrow(request), 111 | }); 112 | if (_response.ok) { 113 | return; 114 | } 115 | 116 | if (_response.error.reason === "status-code") { 117 | throw new errors.ScaleError({ 118 | statusCode: _response.error.statusCode, 119 | body: _response.error.body, 120 | }); 121 | } 122 | 123 | switch (_response.error.reason) { 124 | case "non-json": 125 | throw new errors.ScaleError({ 126 | statusCode: _response.error.statusCode, 127 | body: _response.error.rawBody, 128 | }); 129 | case "timeout": 130 | throw new errors.ScaleTimeoutError(); 131 | case "unknown": 132 | throw new errors.ScaleError({ 133 | message: _response.error.errorMessage, 134 | }); 135 | } 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/api/resources/teammates/client/index.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /src/api/resources/teammates/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./client"; 3 | -------------------------------------------------------------------------------- /src/api/resources/teammates/types/Teammate.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface Teammate { 6 | /** Teammate email */ 7 | email: string; 8 | /** Teammate role, can be of `labeler` (Studio only), `member`, `manager`. */ 9 | role: string; 10 | /** Teammate company */ 11 | company?: string; 12 | /** Teammate first name */ 13 | firstName?: string; 14 | /** Teammate last name */ 15 | lastName?: string; 16 | /** Is teammate a Studio labeler? */ 17 | isStudioLabeler?: boolean; 18 | /** If teammate status is `invited`, this field indicates when the invitation will expire. */ 19 | expiry?: string; 20 | } 21 | -------------------------------------------------------------------------------- /src/api/resources/teammates/types/TeamsInvite.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface TeamsInvite { 6 | /** Array of emails of teammates you want to invite. */ 7 | emails: string[]; 8 | /** Role of invited teammate. Allowed values are: `labeler` (Studio only), `member`, or `manager`. */ 9 | teamRole: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/api/resources/teammates/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./Teammate"; 2 | export * from "./TeamsInvite"; 3 | -------------------------------------------------------------------------------- /src/api/resources/video/client/Client.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as environments from "../../../../environments"; 6 | import * as core from "../../../../core"; 7 | import { Scale } from "@fern-api/scale"; 8 | import urlJoin from "url-join"; 9 | import * as serializers from "../../../../serialization"; 10 | import * as errors from "../../../../errors"; 11 | 12 | export declare namespace Video { 13 | interface Options { 14 | environment?: environments.ScaleEnvironment | string; 15 | token?: core.Supplier; 16 | } 17 | } 18 | 19 | export class Video { 20 | constructor(private readonly options: Video.Options) {} 21 | 22 | /** 23 | * This endpoint creates a `videoplaybackannotation` task. In this task, we will view the given video file and draw annotation around the specified objects. You are required to provide a URL to the video file as the `attachment`. It can be in `mp4`, `webm`, or `ogg` format. You can optionally provide additional markdown-enabled or Google Doc-based [instructions](https://scale.com/docs/instructions) via the `instruction` parameter. You may optionally specify a `frame_rate`, which will determine how many frames per second will be used to annotate the given video. The default value is `1`. You may also optionally specify `events_to_annotate`, a list of strings describing [events section](/reference/events) to annotate in the video. If the request is successful, Scale will return the generated task object, at which point you should store the `task_id` to have a permanent reference to the task. 24 | */ 25 | public async createPlaybackAnnotation( 26 | request: Scale.VideoPlaybackAnnotationRequest 27 | ): Promise { 28 | const _response = await core.fetcher({ 29 | url: urlJoin( 30 | this.options.environment ?? environments.ScaleEnvironment.Production, 31 | "task/videoplaybackannotation" 32 | ), 33 | method: "POST", 34 | headers: { 35 | Authorization: core.BearerToken.toAuthorizationHeader(await core.Supplier.get(this.options.token)), 36 | }, 37 | body: await serializers.VideoPlaybackAnnotationRequest.jsonOrThrow(request), 38 | }); 39 | if (_response.ok) { 40 | return await serializers.VideoPlaybackAnnotationResponse.parseOrThrow( 41 | _response.body as serializers.VideoPlaybackAnnotationResponse.Raw, 42 | { allowUnknownKeys: true } 43 | ); 44 | } 45 | 46 | if (_response.error.reason === "status-code") { 47 | throw new errors.ScaleError({ 48 | statusCode: _response.error.statusCode, 49 | body: _response.error.body, 50 | }); 51 | } 52 | 53 | switch (_response.error.reason) { 54 | case "non-json": 55 | throw new errors.ScaleError({ 56 | statusCode: _response.error.statusCode, 57 | body: _response.error.rawBody, 58 | }); 59 | case "timeout": 60 | throw new errors.ScaleTimeoutError(); 61 | case "unknown": 62 | throw new errors.ScaleError({ 63 | message: _response.error.errorMessage, 64 | }); 65 | } 66 | } 67 | 68 | /** 69 | * ### **Note: Scale Video is only available for our Enterprise customers**. If you want to learn more, please contact our [sales team](https://scale.com/sales). This endpoint creates a `videoannotation` task. Given a series of images sampled from a video (which we will refer to as "frames"), Scale will annotate each frame with the Geometries (`box`, `polygon`, `line`, `point`, `cuboid,` and `ellipse`) you specify. The required parameter for this task is `geometries`. You can optionally provide additional markdown-enabled or Google Doc-based [instructions](https://scale.com/docs/instructions) via the `instruction` parameter. You may also optionally specify `events_to_annotate`, a list of strings describing [events section](/reference/events) to annotate in the video. If the request is successful, Scale will return the generated task object, at which point you should store the `task_id` to have a permanent reference to the task. 70 | */ 71 | public async createGeneralAnnotation( 72 | request: Scale.VideoPlaybackAnnotationRequest 73 | ): Promise { 74 | const _response = await core.fetcher({ 75 | url: urlJoin(this.options.environment ?? environments.ScaleEnvironment.Production, "task/videoannotation"), 76 | method: "POST", 77 | headers: { 78 | Authorization: core.BearerToken.toAuthorizationHeader(await core.Supplier.get(this.options.token)), 79 | }, 80 | body: await serializers.VideoPlaybackAnnotationRequest.jsonOrThrow(request), 81 | }); 82 | if (_response.ok) { 83 | return await serializers.VideoPlaybackAnnotationResponse.parseOrThrow( 84 | _response.body as serializers.VideoPlaybackAnnotationResponse.Raw, 85 | { allowUnknownKeys: true } 86 | ); 87 | } 88 | 89 | if (_response.error.reason === "status-code") { 90 | throw new errors.ScaleError({ 91 | statusCode: _response.error.statusCode, 92 | body: _response.error.body, 93 | }); 94 | } 95 | 96 | switch (_response.error.reason) { 97 | case "non-json": 98 | throw new errors.ScaleError({ 99 | statusCode: _response.error.statusCode, 100 | body: _response.error.rawBody, 101 | }); 102 | case "timeout": 103 | throw new errors.ScaleTimeoutError(); 104 | case "unknown": 105 | throw new errors.ScaleError({ 106 | message: _response.error.errorMessage, 107 | }); 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/api/resources/video/client/index.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /src/api/resources/video/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./client"; 3 | -------------------------------------------------------------------------------- /src/api/resources/video/types/AnnotationAttribute.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface AnnotationAttribute { 6 | /** attribute types: category, number, angle, text, x_line, y_line, linked */ 7 | type?: string; 8 | /** a human-readable string describing the attribute to a labeler. */ 9 | description?: string; 10 | /** a list of strings corresponding to the categorical choices. */ 11 | choices?: string; 12 | } 13 | -------------------------------------------------------------------------------- /src/api/resources/video/types/Box.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface Box { 6 | objectsToAnnotate?: unknown[]; 7 | minHeight?: number; 8 | minWidth?: number; 9 | } 10 | -------------------------------------------------------------------------------- /src/api/resources/video/types/CameraIntrinsics.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface CameraIntrinsics { 6 | fx?: number; 7 | fy?: number; 8 | cx?: number; 9 | cy?: number; 10 | skew?: number; 11 | scalefactor?: number; 12 | } 13 | -------------------------------------------------------------------------------- /src/api/resources/video/types/CameraRotationQuaternion.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface CameraRotationQuaternion { 6 | w?: number; 7 | x?: number; 8 | y?: number; 9 | z?: number; 10 | } 11 | -------------------------------------------------------------------------------- /src/api/resources/video/types/Cuboid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import { Scale } from "@fern-api/scale"; 6 | 7 | export interface Cuboid { 8 | objectsToAnnotate?: unknown[]; 9 | minHeight?: number; 10 | minWidth?: number; 11 | cameraIntrinsics?: Scale.CameraIntrinsics; 12 | cameraRotationQuaternion?: Scale.CameraRotationQuaternion; 13 | cameraHeight?: number; 14 | } 15 | -------------------------------------------------------------------------------- /src/api/resources/video/types/Ellipse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface Ellipse { 6 | objectsToAnnotate?: unknown[]; 7 | vertices?: unknown[]; 8 | } 9 | -------------------------------------------------------------------------------- /src/api/resources/video/types/Geometries.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import { Scale } from "@fern-api/scale"; 6 | 7 | /** 8 | * An object mapping `box`, `polygon`, `line`, `point`, `cuboid`, or `ellipse` to Geometry objects 9 | */ 10 | export interface Geometries { 11 | box?: Scale.Box; 12 | polygon?: Scale.Polygon; 13 | line?: Scale.Line; 14 | point?: Scale.Point; 15 | cuboid?: Scale.Cuboid; 16 | ellipse?: Scale.Ellipse; 17 | } 18 | -------------------------------------------------------------------------------- /src/api/resources/video/types/Line.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface Line { 6 | objectsToAnnotate?: unknown[]; 7 | minVertices?: number; 8 | maxVertices?: number; 9 | } 10 | -------------------------------------------------------------------------------- /src/api/resources/video/types/Links.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface Links { 6 | /** Whether or not the link is directional */ 7 | isBidirectional?: boolean; 8 | /** a list of labels of the geometries that the link can be linked from */ 9 | fromAllowedLabels?: unknown[]; 10 | /** a list of labels of the geometries that the link can be linked to */ 11 | toAllowedLabels?: unknown[]; 12 | } 13 | -------------------------------------------------------------------------------- /src/api/resources/video/types/ObjectsToAnnotate.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface ObjectsToAnnotate { 6 | objectsToAnnotate?: unknown[]; 7 | } 8 | -------------------------------------------------------------------------------- /src/api/resources/video/types/Point.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface Point { 6 | objectsToAnnotate?: unknown[]; 7 | x?: number; 8 | y?: number; 9 | } 10 | -------------------------------------------------------------------------------- /src/api/resources/video/types/Polygon.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export interface Polygon { 6 | objectsToAnnotate?: unknown[]; 7 | minVertices?: number; 8 | maxVertices?: number; 9 | } 10 | -------------------------------------------------------------------------------- /src/api/resources/video/types/VideoPlaybackAnnotationRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import { Scale } from "@fern-api/scale"; 6 | 7 | export interface VideoPlaybackAnnotationRequest { 8 | /** The name of the [project](/reference/project-overview) to associate this task with. */ 9 | project?: string; 10 | /** The name of the [batch](/reference/batch-overview) to associate this task with. Note that if a batch is specified, you need not specify the project, as the task will automatically be associated with the batch's project. For Scale Rapid projects specifying a batch is required. See [Batches section](/reference/batch-overview) for more details. */ 11 | batch?: string; 12 | /** A markdown-enabled string or iframe embed google doc explaining how to do the task. You can use [markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) to show example images, give structure to your instructions, and more. See our [instruction best practices](https://scale.com/docs/instructions) for more details. For Scale Rapid projects, DO NOT set this field unless you specifically want to override the project level instructions. */ 13 | instruction?: string; 14 | /** The full url (including the scheme `http://` or `https://`) or email address of the [callback](/reference/callbacks) that will be used when the task is completed. */ 15 | callbackUrl?: string; 16 | /** An array of URLs for the frames you'd like to be annotated. These image frames are stitched together to create a video. This is required if `attachment_type` is `image` and must be omitted if `attachment_type` is `video`. */ 17 | attachments?: string[]; 18 | /** A URL pointing to the video file attachment. Only the `mp4`, `webm`, and `ogg` formats are supported. */ 19 | attachment?: string; 20 | /** Describes what type of file the attachment(s) are. The only options are `image` and `video`. */ 21 | attachmentType?: string; 22 | /** An object mapping `box`, `polygon`, `line`, `point`, `cuboid`, or `ellipse` to Geometry objects */ 23 | geometries: Scale.Geometries; 24 | /** See the [Annotation Attributes](/reference/attributes-overview) section for more details about annotation attributes. */ 25 | annotationAttributes?: Record; 26 | /** The list of events to annotate */ 27 | eventsToAnnotate?: string[]; 28 | /** Use this field to define links between annotations. See [Links](/reference/links) for more details about links. */ 29 | links?: Record; 30 | /** The number of frames per second to annotate. */ 31 | frameRate?: number; 32 | /** The amount of padding in pixels added to the top, bottom, left, and right of each video frame. This allows labelers to extend annotations outside of the frames. */ 33 | padding?: number; 34 | /** The amount of padding in pixels added to the left and right of each video frame. Overrides `padding` if set. */ 35 | paddingX?: number; 36 | /** The amount of padding in pixels added to the top and bottom of each video frame. Overrides `padding` if set. */ 37 | paddingY?: number; 38 | /** Editable annotations that a task should be initialized with. This is useful when you've run a model to prelabel the task and want annotators to refine those prelabels. Review the [Segmentation Hypothesis Format](/reference/image-segmentation-hypothesis) for more details. */ 39 | hypothesis?: Record; 40 | /** Editable annotations, with the option to be "locked", that a task should be initialized with. This is useful when you've run a model to prelabel the task and want annotators to refine those prelabels. Must contain the `annotations` field, which has the same format as the `annotations` field in the response. */ 41 | baseAnnotations?: Record; 42 | /** Whether or not new annotations can be added to the task if base_annotations are used. If set to true, new annotations can be added to the task in addition to base_annotations. If set to false, new annotations will not be able to be added to the task. */ 43 | canAddBaseAnnotations?: boolean; 44 | /** Whether or not base_annotations can be edited in the task. If set to true, base_annotations can be edited by the tasker (position of annotation, attributes, etc). If set to false, all aspects of base_annotations will be locked. */ 45 | canEditBaseAnnotations?: boolean; 46 | /** Whether or not base_annotations labels can be edited in the task. If set to true, the label of base_annotations can be edited by the tasker. If set to false, the label will be locked. */ 47 | canEditBaseAnnotationLabels?: boolean; 48 | /** Whether or not base_annotations can be removed from the task. If set to true, base_annotations can be deleted from the task. If set to false, base_annotations cannot be deleted from the task. */ 49 | canDeleteBaseAnnotations?: boolean; 50 | /** A set of key/value pairs that you can attach to a task object. It can be useful for storing additional information about the task in a structured format. Max 10KB. */ 51 | metadata?: Record; 52 | /** A value of 10, 20, or 30 that defines the priority of a task within a project. The higher the number, the higher the priority. */ 53 | priority?: number; 54 | /** A arbitrary ID that you can assign to a task and then query for later. This ID must be unique across all projects under your account, otherwise the task submission will be rejected. See [Avoiding Duplicate Tasks](/reference/idempotent-requests) for more details. */ 55 | uniqueId?: string; 56 | /** If set to be true, if a task errors out after being submitted, the unique id on the task will be unset. This param allows workflows where you can re-submit the same unique id to recover from errors automatically */ 57 | clearUniqueIdOnError?: boolean; 58 | /** Arbitrary labels that you can assign to a task. At most 5 tags are allowed per task. You can query tasks with specific tags through the task retrieval API. */ 59 | tags?: string[]; 60 | } 61 | -------------------------------------------------------------------------------- /src/api/resources/video/types/VideoPlaybackAnnotationResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import { Scale } from "@fern-api/scale"; 6 | 7 | export interface VideoPlaybackAnnotationResponse { 8 | /** The ID of the created task. */ 9 | taskId?: string; 10 | /** The time the task was created at (in YYYY-MM-DDThh:mm:ss.sTZD format). */ 11 | createdAt?: string; 12 | /** The task type of the created task. */ 13 | type?: string; 14 | /** The status of the task, either `pending`, `completed`, `canceled` or `error`. */ 15 | status?: string; 16 | /** The instruction specified in the request. */ 17 | instruction?: string; 18 | /** Whether the task is a test task. */ 19 | isTest?: boolean; 20 | urgency?: string; 21 | /** The metadata specified in the request. */ 22 | metadata?: Record; 23 | /** The [project](/reference/project-overview) that this task is created in. */ 24 | project?: string; 25 | /** The full url (including the scheme `http://` or `https://`) or email address of the [callback](/reference/callbacks) that will be used when the task is completed. */ 26 | callbackUrl?: string; 27 | updatedAt?: string; 28 | workStarted?: boolean; 29 | params?: Scale.VideoPlaybackParams; 30 | } 31 | -------------------------------------------------------------------------------- /src/api/resources/video/types/VideoPlaybackGeometries.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import { Scale } from "@fern-api/scale"; 6 | 7 | export interface VideoPlaybackGeometries { 8 | box?: Scale.ObjectsToAnnotate; 9 | } 10 | -------------------------------------------------------------------------------- /src/api/resources/video/types/VideoPlaybackParams.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import { Scale } from "@fern-api/scale"; 6 | 7 | export interface VideoPlaybackParams { 8 | attachment?: string; 9 | frameRate?: number; 10 | withLabels?: boolean; 11 | eventsToAnnotate?: unknown[]; 12 | geometries?: Scale.VideoPlaybackGeometries; 13 | isTest?: boolean; 14 | /** A set of key/value pairs that you can attach to a task object. It can be useful for storing additional information about the task in a structured format. Max 10KB. */ 15 | metadata?: string; 16 | } 17 | -------------------------------------------------------------------------------- /src/api/resources/video/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./VideoPlaybackAnnotationRequest"; 2 | export * from "./Box"; 3 | export * from "./Polygon"; 4 | export * from "./Line"; 5 | export * from "./Point"; 6 | export * from "./CameraIntrinsics"; 7 | export * from "./CameraRotationQuaternion"; 8 | export * from "./Cuboid"; 9 | export * from "./Ellipse"; 10 | export * from "./Geometries"; 11 | export * from "./AnnotationAttribute"; 12 | export * from "./Links"; 13 | export * from "./VideoPlaybackAnnotationResponse"; 14 | export * from "./ObjectsToAnnotate"; 15 | export * from "./VideoPlaybackGeometries"; 16 | export * from "./VideoPlaybackParams"; 17 | -------------------------------------------------------------------------------- /src/core/auth/BasicAuth.ts: -------------------------------------------------------------------------------- 1 | import { parse } from "basic-auth"; 2 | import { Base64 } from "js-base64"; 3 | 4 | export interface BasicAuth { 5 | username: string; 6 | password: string; 7 | } 8 | 9 | export const BasicAuth = { 10 | toAuthorizationHeader: (basicAuth: BasicAuth | undefined): string | undefined => { 11 | if (basicAuth == null) { 12 | return undefined; 13 | } 14 | const token = Base64.encode(`${basicAuth.username}:${basicAuth.password}`); 15 | return `Basic ${token}`; 16 | }, 17 | fromAuthorizationHeader: (header: string): BasicAuth => { 18 | const parsed = parse(header); 19 | if (parsed == null) { 20 | throw new Error("Invalid basic auth"); 21 | } 22 | return { 23 | username: parsed.name, 24 | password: parsed.pass, 25 | }; 26 | }, 27 | }; 28 | -------------------------------------------------------------------------------- /src/core/auth/BearerToken.ts: -------------------------------------------------------------------------------- 1 | import { parse } from "basic-auth"; 2 | import { Base64 } from "js-base64"; 3 | 4 | /** 5 | * this file is modified from the default to work with Scale's authentication 6 | * scheme: basic auth, where the username is the API key and the password is "". 7 | */ 8 | 9 | export type BearerToken = string; 10 | 11 | export const BearerToken = { 12 | toAuthorizationHeader: (apiKey: BearerToken | undefined): string | undefined => { 13 | if (apiKey == null) { 14 | return undefined; 15 | } 16 | const token = Base64.encode(`${apiKey}:`); 17 | return `Basic ${token}`; 18 | }, 19 | fromAuthorizationHeader: (header: string): BearerToken => { 20 | const parsed = parse(header); 21 | if (parsed == null) { 22 | throw new Error("Invalid basic auth"); 23 | } 24 | return parsed.name; 25 | }, 26 | }; 27 | -------------------------------------------------------------------------------- /src/core/auth/index.ts: -------------------------------------------------------------------------------- 1 | export { BasicAuth } from "./BasicAuth"; 2 | export { BearerToken } from "./BearerToken"; 3 | -------------------------------------------------------------------------------- /src/core/fetcher/APIResponse.ts: -------------------------------------------------------------------------------- 1 | export type APIResponse = SuccessfulResponse | FailedResponse; 2 | 3 | export interface SuccessfulResponse { 4 | ok: true; 5 | body: T; 6 | } 7 | 8 | export interface FailedResponse { 9 | ok: false; 10 | error: T; 11 | } 12 | -------------------------------------------------------------------------------- /src/core/fetcher/Fetcher.ts: -------------------------------------------------------------------------------- 1 | import axios, { AxiosError } from "axios"; 2 | import { APIResponse } from "./APIResponse"; 3 | 4 | export type FetchFunction = (args: Fetcher.Args) => Promise>; 5 | 6 | export declare namespace Fetcher { 7 | export interface Args { 8 | url: string; 9 | method: string; 10 | headers?: Record; 11 | queryParameters?: URLSearchParams; 12 | body?: unknown; 13 | timeoutMs?: number; 14 | withCredentials?: boolean; 15 | } 16 | 17 | export type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError; 18 | 19 | export interface FailedStatusCodeError { 20 | reason: "status-code"; 21 | statusCode: number; 22 | body: unknown; 23 | } 24 | 25 | export interface NonJsonError { 26 | reason: "non-json"; 27 | statusCode: number; 28 | rawBody: string; 29 | } 30 | 31 | export interface TimeoutError { 32 | reason: "timeout"; 33 | } 34 | 35 | export interface UnknownError { 36 | reason: "unknown"; 37 | errorMessage: string; 38 | } 39 | } 40 | 41 | export const fetcher: FetchFunction = async (args) => { 42 | const headers: Record = { 43 | "Content-Type": "application/json", 44 | }; 45 | 46 | if (args.headers != null) { 47 | for (const [key, value] of Object.entries(args.headers)) { 48 | if (value != null) { 49 | headers[key] = value; 50 | } 51 | } 52 | } 53 | 54 | try { 55 | const response = await axios({ 56 | url: args.url, 57 | params: args.queryParameters, 58 | method: args.method, 59 | headers, 60 | data: args.body, 61 | validateStatus: () => true, 62 | transformResponse: (response) => response, 63 | timeout: args.timeoutMs ?? 60_000, 64 | transitional: { 65 | clarifyTimeoutError: true, 66 | }, 67 | withCredentials: args.withCredentials, 68 | }); 69 | 70 | let body: unknown; 71 | if (response.data != null && response.data.length > 0) { 72 | try { 73 | body = JSON.parse(response.data) ?? undefined; 74 | } catch { 75 | return { 76 | ok: false, 77 | error: { 78 | reason: "non-json", 79 | statusCode: response.status, 80 | rawBody: response.data, 81 | }, 82 | }; 83 | } 84 | } 85 | 86 | if (response.status >= 200 && response.status < 300) { 87 | return { 88 | ok: true, 89 | body, 90 | }; 91 | } else { 92 | return { 93 | ok: false, 94 | error: { 95 | reason: "status-code", 96 | statusCode: response.status, 97 | body, 98 | }, 99 | }; 100 | } 101 | } catch (error) { 102 | if ((error as AxiosError).code === "ETIMEDOUT") { 103 | return { 104 | ok: false, 105 | error: { 106 | reason: "timeout", 107 | }, 108 | }; 109 | } 110 | 111 | return { 112 | ok: false, 113 | error: { 114 | reason: "unknown", 115 | errorMessage: (error as AxiosError).message, 116 | }, 117 | }; 118 | } 119 | }; 120 | -------------------------------------------------------------------------------- /src/core/fetcher/Supplier.ts: -------------------------------------------------------------------------------- 1 | export type Supplier = T | Promise | (() => T | Promise); 2 | 3 | export const Supplier = { 4 | get: async (supplier: Supplier): Promise => { 5 | if (typeof supplier === "function") { 6 | return (supplier as () => T)(); 7 | } else { 8 | return supplier; 9 | } 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /src/core/fetcher/index.ts: -------------------------------------------------------------------------------- 1 | export { type APIResponse } from "./APIResponse"; 2 | export { fetcher, type Fetcher, type FetchFunction } from "./Fetcher"; 3 | export { Supplier } from "./Supplier"; 4 | -------------------------------------------------------------------------------- /src/core/index.ts: -------------------------------------------------------------------------------- 1 | export * as serialization from "./schemas"; 2 | export * from "./auth"; 3 | export * from "./fetcher"; 4 | -------------------------------------------------------------------------------- /src/core/schemas/Schema.ts: -------------------------------------------------------------------------------- 1 | import { SchemaUtils } from "./builders"; 2 | import { MaybePromise } from "./utils/MaybePromise"; 3 | 4 | export type Schema = BaseSchema & SchemaUtils; 5 | 6 | export type inferRaw = S extends Schema ? Raw : never; 7 | export type inferParsed = S extends Schema ? Parsed : never; 8 | 9 | export interface BaseSchema { 10 | parse: (raw: unknown, opts?: SchemaOptions) => MaybePromise>; 11 | json: (parsed: unknown, opts?: SchemaOptions) => MaybePromise>; 12 | getType: () => SchemaType | Promise; 13 | } 14 | 15 | export const SchemaType = { 16 | DATE: "date", 17 | ENUM: "enum", 18 | LIST: "list", 19 | STRING_LITERAL: "stringLiteral", 20 | OBJECT: "object", 21 | ANY: "any", 22 | BOOLEAN: "boolean", 23 | NUMBER: "number", 24 | STRING: "string", 25 | UNKNOWN: "unknown", 26 | RECORD: "record", 27 | SET: "set", 28 | UNION: "union", 29 | OPTIONAL: "optional", 30 | } as const; 31 | export type SchemaType = typeof SchemaType[keyof typeof SchemaType]; 32 | 33 | export type MaybeValid = Valid | Invalid; 34 | 35 | export interface Valid { 36 | ok: true; 37 | value: T; 38 | } 39 | 40 | export interface Invalid { 41 | ok: false; 42 | errors: ValidationError[]; 43 | } 44 | 45 | export interface ValidationError { 46 | path: string[]; 47 | message: string; 48 | } 49 | 50 | export interface SchemaOptions { 51 | /** 52 | * @default false 53 | */ 54 | allowUnknownKeys?: boolean; 55 | } 56 | -------------------------------------------------------------------------------- /src/core/schemas/builders/date/date.ts: -------------------------------------------------------------------------------- 1 | import { BaseSchema, Schema, SchemaType } from "../../Schema"; 2 | import { getSchemaUtils } from "../schema-utils"; 3 | 4 | // https://stackoverflow.com/questions/12756159/regex-and-iso8601-formatted-datetime 5 | const ISO_8601_REGEX = 6 | /^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; 7 | 8 | export function date(): Schema { 9 | const baseSchema: BaseSchema = { 10 | parse: (raw) => { 11 | if (typeof raw === "string" && ISO_8601_REGEX.test(raw)) { 12 | return { 13 | ok: true, 14 | value: new Date(raw), 15 | }; 16 | } else { 17 | return { 18 | ok: false, 19 | errors: [ 20 | { 21 | path: [], 22 | message: "Not an ISO 8601 date string", 23 | }, 24 | ], 25 | }; 26 | } 27 | }, 28 | json: (date) => { 29 | if (date instanceof Date) { 30 | return { 31 | ok: true, 32 | value: date.toISOString(), 33 | }; 34 | } else { 35 | return { 36 | ok: false, 37 | errors: [ 38 | { 39 | path: [], 40 | message: "Not a Date object", 41 | }, 42 | ], 43 | }; 44 | } 45 | }, 46 | getType: () => SchemaType.DATE, 47 | }; 48 | 49 | return { 50 | ...baseSchema, 51 | ...getSchemaUtils(baseSchema), 52 | }; 53 | } 54 | -------------------------------------------------------------------------------- /src/core/schemas/builders/date/index.ts: -------------------------------------------------------------------------------- 1 | export { date } from "./date"; 2 | -------------------------------------------------------------------------------- /src/core/schemas/builders/enum/enum.ts: -------------------------------------------------------------------------------- 1 | import { Schema, SchemaType } from "../../Schema"; 2 | import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; 3 | 4 | export function enum_(values: E): Schema { 5 | const validValues = new Set(values); 6 | 7 | const schemaCreator = createIdentitySchemaCreator(SchemaType.ENUM, (value, { allowUnknownKeys = false } = {}) => { 8 | if (typeof value === "string" && (validValues.has(value) || allowUnknownKeys)) { 9 | return { 10 | ok: true, 11 | value: value as U, 12 | }; 13 | } else { 14 | return { 15 | ok: false, 16 | errors: [ 17 | { 18 | path: [], 19 | message: "Not one of the allowed values", 20 | }, 21 | ], 22 | }; 23 | } 24 | }); 25 | 26 | return schemaCreator(); 27 | } 28 | -------------------------------------------------------------------------------- /src/core/schemas/builders/enum/index.ts: -------------------------------------------------------------------------------- 1 | export { enum_ } from "./enum"; 2 | -------------------------------------------------------------------------------- /src/core/schemas/builders/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./date"; 2 | export * from "./enum"; 3 | export * from "./lazy"; 4 | export * from "./list"; 5 | export * from "./literals"; 6 | export * from "./object"; 7 | export * from "./object-like"; 8 | export * from "./primitives"; 9 | export * from "./record"; 10 | export * from "./schema-utils"; 11 | export * from "./set"; 12 | export * from "./union"; 13 | -------------------------------------------------------------------------------- /src/core/schemas/builders/lazy/index.ts: -------------------------------------------------------------------------------- 1 | export { lazy, type SchemaGetter } from "./lazy"; 2 | export { lazyObject } from "./lazyObject"; 3 | -------------------------------------------------------------------------------- /src/core/schemas/builders/lazy/lazy.ts: -------------------------------------------------------------------------------- 1 | import { BaseSchema, Schema } from "../../Schema"; 2 | import { getSchemaUtils } from "../schema-utils"; 3 | 4 | export type SchemaGetter> = () => SchemaType | Promise; 5 | 6 | export function lazy(getter: SchemaGetter>): Schema { 7 | const baseSchema = constructLazyBaseSchema(getter); 8 | return { 9 | ...baseSchema, 10 | ...getSchemaUtils(baseSchema), 11 | }; 12 | } 13 | 14 | export function constructLazyBaseSchema( 15 | getter: SchemaGetter> 16 | ): BaseSchema { 17 | return { 18 | parse: async (raw, opts) => (await getMemoizedSchema(getter)).parse(raw, opts), 19 | json: async (parsed, opts) => (await getMemoizedSchema(getter)).json(parsed, opts), 20 | getType: async () => (await getMemoizedSchema(getter)).getType(), 21 | }; 22 | } 23 | 24 | type MemoizedGetter> = SchemaGetter & { __zurg_memoized?: SchemaType }; 25 | 26 | export async function getMemoizedSchema>( 27 | getter: SchemaGetter 28 | ): Promise { 29 | const castedGetter = getter as MemoizedGetter; 30 | if (castedGetter.__zurg_memoized == null) { 31 | castedGetter.__zurg_memoized = await getter(); 32 | } 33 | return castedGetter.__zurg_memoized; 34 | } 35 | -------------------------------------------------------------------------------- /src/core/schemas/builders/lazy/lazyObject.ts: -------------------------------------------------------------------------------- 1 | import { getObjectUtils } from "../object"; 2 | import { getObjectLikeUtils } from "../object-like"; 3 | import { BaseObjectSchema, ObjectSchema } from "../object/types"; 4 | import { getSchemaUtils } from "../schema-utils"; 5 | import { constructLazyBaseSchema, getMemoizedSchema, SchemaGetter } from "./lazy"; 6 | 7 | export function lazyObject(getter: SchemaGetter>): ObjectSchema { 8 | const baseSchema: BaseObjectSchema = { 9 | ...constructLazyBaseSchema(getter), 10 | _getRawProperties: async () => (await getMemoizedSchema(getter))._getRawProperties(), 11 | _getParsedProperties: async () => (await getMemoizedSchema(getter))._getParsedProperties(), 12 | }; 13 | 14 | return { 15 | ...baseSchema, 16 | ...getSchemaUtils(baseSchema), 17 | ...getObjectLikeUtils(baseSchema), 18 | ...getObjectUtils(baseSchema), 19 | }; 20 | } 21 | -------------------------------------------------------------------------------- /src/core/schemas/builders/list/index.ts: -------------------------------------------------------------------------------- 1 | export { list } from "./list"; 2 | -------------------------------------------------------------------------------- /src/core/schemas/builders/list/list.ts: -------------------------------------------------------------------------------- 1 | import { BaseSchema, MaybeValid, Schema, SchemaType, ValidationError } from "../../Schema"; 2 | import { MaybePromise } from "../../utils/MaybePromise"; 3 | import { getSchemaUtils } from "../schema-utils"; 4 | 5 | export function list(schema: Schema): Schema { 6 | const baseSchema: BaseSchema = { 7 | parse: async (raw, opts) => validateAndTransformArray(raw, (item) => schema.parse(item, opts)), 8 | json: (parsed, opts) => validateAndTransformArray(parsed, (item) => schema.json(item, opts)), 9 | getType: () => SchemaType.LIST, 10 | }; 11 | 12 | return { 13 | ...baseSchema, 14 | ...getSchemaUtils(baseSchema), 15 | }; 16 | } 17 | 18 | async function validateAndTransformArray( 19 | value: unknown, 20 | transformItem: (item: Raw) => MaybePromise> 21 | ): Promise> { 22 | if (!Array.isArray(value)) { 23 | return { 24 | ok: false, 25 | errors: [ 26 | { 27 | message: "Not a list", 28 | path: [], 29 | }, 30 | ], 31 | }; 32 | } 33 | 34 | const maybeValidItems = await Promise.all(value.map((item) => transformItem(item))); 35 | 36 | return maybeValidItems.reduce>( 37 | (acc, item, index) => { 38 | if (acc.ok && item.ok) { 39 | return { 40 | ok: true, 41 | value: [...acc.value, item.value], 42 | }; 43 | } 44 | 45 | const errors: ValidationError[] = []; 46 | if (!acc.ok) { 47 | errors.push(...acc.errors); 48 | } 49 | if (!item.ok) { 50 | errors.push( 51 | ...item.errors.map((error) => ({ 52 | path: [`[${index}]`, ...error.path], 53 | message: error.message, 54 | })) 55 | ); 56 | } 57 | 58 | return { 59 | ok: false, 60 | errors, 61 | }; 62 | }, 63 | { ok: true, value: [] } 64 | ); 65 | } 66 | -------------------------------------------------------------------------------- /src/core/schemas/builders/literals/index.ts: -------------------------------------------------------------------------------- 1 | export { stringLiteral } from "./stringLiteral"; 2 | -------------------------------------------------------------------------------- /src/core/schemas/builders/literals/stringLiteral.ts: -------------------------------------------------------------------------------- 1 | import { Schema, SchemaType } from "../../Schema"; 2 | import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; 3 | 4 | export function stringLiteral(literal: V): Schema { 5 | const schemaCreator = createIdentitySchemaCreator(SchemaType.STRING_LITERAL, (value) => { 6 | if (value === literal) { 7 | return { 8 | ok: true, 9 | value: literal, 10 | }; 11 | } else { 12 | return { 13 | ok: false, 14 | errors: [ 15 | { 16 | path: [], 17 | message: `Not equal to "${literal}"`, 18 | }, 19 | ], 20 | }; 21 | } 22 | }); 23 | 24 | return schemaCreator(); 25 | } 26 | -------------------------------------------------------------------------------- /src/core/schemas/builders/object-like/getObjectLikeUtils.ts: -------------------------------------------------------------------------------- 1 | import { BaseSchema } from "../../Schema"; 2 | import { filterObject } from "../../utils/filterObject"; 3 | import { isPlainObject, NOT_AN_OBJECT_ERROR_MESSAGE } from "../../utils/isPlainObject"; 4 | import { getSchemaUtils } from "../schema-utils"; 5 | import { ObjectLikeSchema, ObjectLikeUtils } from "./types"; 6 | 7 | export function getObjectLikeUtils(schema: BaseSchema): ObjectLikeUtils { 8 | return { 9 | withParsedProperties: (properties) => withParsedProperties(schema, properties), 10 | }; 11 | } 12 | 13 | /** 14 | * object-like utils are defined in one file to resolve issues with circular imports 15 | */ 16 | 17 | export function withParsedProperties( 18 | objectLike: BaseSchema, 19 | properties: { [K in keyof Properties]: Properties[K] | ((parsed: ParsedObjectShape) => Properties[K]) } 20 | ): ObjectLikeSchema { 21 | const objectSchema: BaseSchema = { 22 | parse: async (raw, opts) => { 23 | const parsedObject = await objectLike.parse(raw, opts); 24 | if (!parsedObject.ok) { 25 | return parsedObject; 26 | } 27 | 28 | const additionalProperties = Object.entries(properties).reduce>( 29 | (processed, [key, value]) => { 30 | return { 31 | ...processed, 32 | [key]: typeof value === "function" ? value(parsedObject.value) : value, 33 | }; 34 | }, 35 | {} 36 | ); 37 | 38 | return { 39 | ok: true, 40 | value: { 41 | ...parsedObject.value, 42 | ...(additionalProperties as Properties), 43 | }, 44 | }; 45 | }, 46 | 47 | json: (parsed, opts) => { 48 | if (!isPlainObject(parsed)) { 49 | return { 50 | ok: false, 51 | errors: [ 52 | { 53 | path: [], 54 | message: NOT_AN_OBJECT_ERROR_MESSAGE, 55 | }, 56 | ], 57 | }; 58 | } 59 | 60 | // strip out added properties 61 | const addedPropertyKeys = new Set(Object.keys(properties)); 62 | const parsedWithoutAddedProperties = filterObject( 63 | parsed, 64 | Object.keys(parsed).filter((key) => !addedPropertyKeys.has(key)) 65 | ); 66 | 67 | return objectLike.json(parsedWithoutAddedProperties as ParsedObjectShape, opts); 68 | }, 69 | 70 | getType: () => objectLike.getType(), 71 | }; 72 | 73 | return { 74 | ...objectSchema, 75 | ...getSchemaUtils(objectSchema), 76 | ...getObjectLikeUtils(objectSchema), 77 | }; 78 | } 79 | -------------------------------------------------------------------------------- /src/core/schemas/builders/object-like/index.ts: -------------------------------------------------------------------------------- 1 | export { getObjectLikeUtils, withParsedProperties } from "./getObjectLikeUtils"; 2 | export { type ObjectLikeSchema, type ObjectLikeUtils } from "./types"; 3 | -------------------------------------------------------------------------------- /src/core/schemas/builders/object-like/types.ts: -------------------------------------------------------------------------------- 1 | import { BaseSchema, Schema } from "../../Schema"; 2 | 3 | export type ObjectLikeSchema = Schema & 4 | BaseSchema & 5 | ObjectLikeUtils; 6 | 7 | export interface ObjectLikeUtils { 8 | withParsedProperties: >(properties: { 9 | [K in keyof T]: T[K] | ((parsed: Parsed) => T[K]); 10 | }) => ObjectLikeSchema; 11 | } 12 | -------------------------------------------------------------------------------- /src/core/schemas/builders/object/index.ts: -------------------------------------------------------------------------------- 1 | export { getObjectUtils, object } from "./object"; 2 | export { isProperty, property, type Property } from "./property"; 3 | export { 4 | type BaseObjectSchema, 5 | type inferObjectSchemaFromPropertySchemas, 6 | type inferParsedObject, 7 | type inferParsedObjectFromPropertySchemas, 8 | type inferParsedPropertySchema, 9 | type inferRawKey, 10 | type inferRawObject, 11 | type inferRawObjectFromPropertySchemas, 12 | type inferRawPropertySchema, 13 | type ObjectSchema, 14 | type ObjectUtils, 15 | type PropertySchemas, 16 | } from "./types"; 17 | -------------------------------------------------------------------------------- /src/core/schemas/builders/object/property.ts: -------------------------------------------------------------------------------- 1 | import { Schema } from "../../Schema"; 2 | 3 | export function property( 4 | rawKey: RawKey, 5 | valueSchema: Schema 6 | ): Property { 7 | return { 8 | rawKey, 9 | valueSchema, 10 | isProperty: true, 11 | }; 12 | } 13 | 14 | export interface Property { 15 | rawKey: RawKey; 16 | valueSchema: Schema; 17 | isProperty: true; 18 | } 19 | 20 | export function isProperty>(maybeProperty: unknown): maybeProperty is O { 21 | // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition 22 | return (maybeProperty as O).isProperty; 23 | } 24 | -------------------------------------------------------------------------------- /src/core/schemas/builders/object/types.ts: -------------------------------------------------------------------------------- 1 | import { BaseSchema, inferParsed, inferRaw, Schema } from "../../Schema"; 2 | import { addQuestionMarksToNullableProperties } from "../../utils/addQuestionMarksToNullableProperties"; 3 | import { ObjectLikeUtils } from "../object-like"; 4 | import { SchemaUtils } from "../schema-utils"; 5 | import { Property } from "./property"; 6 | 7 | export type ObjectSchema = BaseObjectSchema & 8 | ObjectLikeUtils & 9 | ObjectUtils & 10 | SchemaUtils; 11 | 12 | export interface BaseObjectSchema extends BaseSchema { 13 | _getRawProperties: () => Promise<(keyof Raw)[]>; 14 | _getParsedProperties: () => Promise<(keyof Parsed)[]>; 15 | } 16 | 17 | export interface ObjectUtils { 18 | extend: ( 19 | schemas: ObjectSchema 20 | ) => ObjectSchema; 21 | } 22 | 23 | export type inferRawObject> = O extends ObjectSchema ? Raw : never; 24 | 25 | export type inferParsedObject> = O extends ObjectSchema 26 | ? Parsed 27 | : never; 28 | 29 | export type inferObjectSchemaFromPropertySchemas> = ObjectSchema< 30 | inferRawObjectFromPropertySchemas, 31 | inferParsedObjectFromPropertySchemas 32 | >; 33 | 34 | export type inferRawObjectFromPropertySchemas> = 35 | addQuestionMarksToNullableProperties<{ 36 | [ParsedKey in keyof T as inferRawKey]: inferRawPropertySchema; 37 | }>; 38 | 39 | export type inferParsedObjectFromPropertySchemas> = 40 | addQuestionMarksToNullableProperties<{ 41 | [K in keyof T]: inferParsedPropertySchema; 42 | }>; 43 | 44 | export type PropertySchemas = Record< 45 | ParsedKeys, 46 | Property | Schema 47 | >; 48 | 49 | export type inferRawPropertySchema

| Schema> = P extends Property< 50 | any, 51 | infer Raw, 52 | any 53 | > 54 | ? Raw 55 | : P extends Schema 56 | ? inferRaw

57 | : never; 58 | 59 | export type inferParsedPropertySchema

| Schema> = P extends Property< 60 | any, 61 | any, 62 | infer Parsed 63 | > 64 | ? Parsed 65 | : P extends Schema 66 | ? inferParsed

67 | : never; 68 | 69 | export type inferRawKey< 70 | ParsedKey extends string | number | symbol, 71 | P extends Property | Schema 72 | > = P extends Property ? Raw : ParsedKey; 73 | -------------------------------------------------------------------------------- /src/core/schemas/builders/primitives/any.ts: -------------------------------------------------------------------------------- 1 | import { SchemaType } from "../../Schema"; 2 | import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; 3 | 4 | export const any = createIdentitySchemaCreator(SchemaType.ANY, (value) => ({ ok: true, value })); 5 | -------------------------------------------------------------------------------- /src/core/schemas/builders/primitives/boolean.ts: -------------------------------------------------------------------------------- 1 | import { SchemaType } from "../../Schema"; 2 | import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; 3 | 4 | export const boolean = createIdentitySchemaCreator(SchemaType.BOOLEAN, (value) => { 5 | if (typeof value === "boolean") { 6 | return { 7 | ok: true, 8 | value, 9 | }; 10 | } else { 11 | return { 12 | ok: false, 13 | errors: [ 14 | { 15 | path: [], 16 | message: "Not a boolean", 17 | }, 18 | ], 19 | }; 20 | } 21 | }); 22 | -------------------------------------------------------------------------------- /src/core/schemas/builders/primitives/index.ts: -------------------------------------------------------------------------------- 1 | export { any } from "./any"; 2 | export { boolean } from "./boolean"; 3 | export { number } from "./number"; 4 | export { string } from "./string"; 5 | export { unknown } from "./unknown"; 6 | -------------------------------------------------------------------------------- /src/core/schemas/builders/primitives/number.ts: -------------------------------------------------------------------------------- 1 | import { SchemaType } from "../../Schema"; 2 | import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; 3 | 4 | export const number = createIdentitySchemaCreator(SchemaType.NUMBER, (value) => { 5 | if (typeof value === "number") { 6 | return { 7 | ok: true, 8 | value, 9 | }; 10 | } else { 11 | return { 12 | ok: false, 13 | errors: [ 14 | { 15 | path: [], 16 | message: "Not a number", 17 | }, 18 | ], 19 | }; 20 | } 21 | }); 22 | -------------------------------------------------------------------------------- /src/core/schemas/builders/primitives/string.ts: -------------------------------------------------------------------------------- 1 | import { SchemaType } from "../../Schema"; 2 | import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; 3 | 4 | export const string = createIdentitySchemaCreator(SchemaType.STRING, (value) => { 5 | if (typeof value === "string") { 6 | return { 7 | ok: true, 8 | value, 9 | }; 10 | } else { 11 | return { 12 | ok: false, 13 | errors: [ 14 | { 15 | path: [], 16 | message: "Not a string", 17 | }, 18 | ], 19 | }; 20 | } 21 | }); 22 | -------------------------------------------------------------------------------- /src/core/schemas/builders/primitives/unknown.ts: -------------------------------------------------------------------------------- 1 | import { SchemaType } from "../../Schema"; 2 | import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; 3 | 4 | export const unknown = createIdentitySchemaCreator(SchemaType.UNKNOWN, (value) => ({ ok: true, value })); 5 | -------------------------------------------------------------------------------- /src/core/schemas/builders/record/index.ts: -------------------------------------------------------------------------------- 1 | export { record } from "./record"; 2 | export { type BaseRecordSchema, type RecordSchema } from "./types"; 3 | -------------------------------------------------------------------------------- /src/core/schemas/builders/record/record.ts: -------------------------------------------------------------------------------- 1 | import { MaybeValid, Schema, SchemaType, ValidationError } from "../../Schema"; 2 | import { entries } from "../../utils/entries"; 3 | import { isPlainObject, NOT_AN_OBJECT_ERROR_MESSAGE } from "../../utils/isPlainObject"; 4 | import { MaybePromise } from "../../utils/MaybePromise"; 5 | import { OptionalRecord } from "../../utils/OptionalRecord"; 6 | import { getSchemaUtils } from "../schema-utils"; 7 | import { BaseRecordSchema, RecordSchema } from "./types"; 8 | 9 | export function record( 10 | keySchema: Schema, 11 | valueSchema: Schema 12 | ): RecordSchema { 13 | const baseSchema: BaseRecordSchema = { 14 | parse: async (raw, opts) => { 15 | return validateAndTransformRecord({ 16 | value: raw, 17 | isKeyNumeric: (await keySchema.getType()) === SchemaType.NUMBER, 18 | transformKey: (key) => keySchema.parse(key, opts), 19 | transformValue: (value) => valueSchema.parse(value, opts), 20 | }); 21 | }, 22 | json: async (parsed, opts) => { 23 | return validateAndTransformRecord({ 24 | value: parsed, 25 | isKeyNumeric: (await keySchema.getType()) === SchemaType.NUMBER, 26 | transformKey: (key) => keySchema.json(key, opts), 27 | transformValue: (value) => valueSchema.json(value, opts), 28 | }); 29 | }, 30 | getType: () => SchemaType.RECORD, 31 | }; 32 | 33 | return { 34 | ...baseSchema, 35 | ...getSchemaUtils(baseSchema), 36 | }; 37 | } 38 | 39 | async function validateAndTransformRecord({ 40 | value, 41 | isKeyNumeric, 42 | transformKey, 43 | transformValue, 44 | }: { 45 | value: unknown; 46 | isKeyNumeric: boolean; 47 | transformKey: (key: string | number) => MaybePromise>; 48 | transformValue: (value: unknown) => MaybePromise>; 49 | }): Promise>> { 50 | if (!isPlainObject(value)) { 51 | return { 52 | ok: false, 53 | errors: [ 54 | { 55 | path: [], 56 | message: NOT_AN_OBJECT_ERROR_MESSAGE, 57 | }, 58 | ], 59 | }; 60 | } 61 | 62 | return entries(value).reduce>>>( 63 | async (accPromise, [stringKey, value]) => { 64 | // skip nullish keys 65 | if (value == null) { 66 | return accPromise; 67 | } 68 | 69 | const acc = await accPromise; 70 | 71 | let key: string | number = stringKey; 72 | if (isKeyNumeric) { 73 | const numberKey = stringKey.length > 0 ? Number(stringKey) : NaN; 74 | if (!isNaN(numberKey)) { 75 | key = numberKey; 76 | } 77 | } 78 | const transformedKey = await transformKey(key); 79 | 80 | const transformedValue = await transformValue(value); 81 | 82 | if (acc.ok && transformedKey.ok && transformedValue.ok) { 83 | return { 84 | ok: true, 85 | value: { 86 | ...acc.value, 87 | [transformedKey.value]: transformedValue.value, 88 | }, 89 | }; 90 | } 91 | 92 | const errors: ValidationError[] = []; 93 | if (!acc.ok) { 94 | errors.push(...acc.errors); 95 | } 96 | if (!transformedKey.ok) { 97 | errors.push( 98 | ...transformedKey.errors.map((error) => ({ 99 | path: [`${key} (key)`, ...error.path], 100 | message: error.message, 101 | })) 102 | ); 103 | } 104 | if (!transformedValue.ok) { 105 | errors.push( 106 | ...transformedValue.errors.map((error) => ({ 107 | path: [stringKey, ...error.path], 108 | message: error.message, 109 | })) 110 | ); 111 | } 112 | 113 | return { 114 | ok: false, 115 | errors, 116 | }; 117 | }, 118 | Promise.resolve({ ok: true, value: {} as OptionalRecord }) 119 | ); 120 | } 121 | -------------------------------------------------------------------------------- /src/core/schemas/builders/record/types.ts: -------------------------------------------------------------------------------- 1 | import { BaseSchema } from "../../Schema"; 2 | import { OptionalRecord } from "../../utils/OptionalRecord"; 3 | import { SchemaUtils } from "../schema-utils"; 4 | 5 | export type RecordSchema< 6 | RawKey extends string | number, 7 | RawValue, 8 | ParsedKey extends string | number, 9 | ParsedValue 10 | > = BaseRecordSchema & 11 | SchemaUtils, OptionalRecord>; 12 | 13 | export type BaseRecordSchema< 14 | RawKey extends string | number, 15 | RawValue, 16 | ParsedKey extends string | number, 17 | ParsedValue 18 | > = BaseSchema, OptionalRecord>; 19 | -------------------------------------------------------------------------------- /src/core/schemas/builders/schema-utils/JsonError.ts: -------------------------------------------------------------------------------- 1 | import { ValidationError } from "../../Schema"; 2 | import { stringifyValidationError } from "./stringifyValidationErrors"; 3 | 4 | export class JsonError extends Error { 5 | constructor(public readonly errors: ValidationError[]) { 6 | super(errors.map(stringifyValidationError).join("; ")); 7 | Object.setPrototypeOf(this, JsonError.prototype); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/core/schemas/builders/schema-utils/ParseError.ts: -------------------------------------------------------------------------------- 1 | import { ValidationError } from "../../Schema"; 2 | import { stringifyValidationError } from "./stringifyValidationErrors"; 3 | 4 | export class ParseError extends Error { 5 | constructor(public readonly errors: ValidationError[]) { 6 | super(errors.map(stringifyValidationError).join("; ")); 7 | Object.setPrototypeOf(this, ParseError.prototype); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/core/schemas/builders/schema-utils/getSchemaUtils.ts: -------------------------------------------------------------------------------- 1 | import { BaseSchema, Schema, SchemaOptions, SchemaType } from "../../Schema"; 2 | import { JsonError } from "./JsonError"; 3 | import { ParseError } from "./ParseError"; 4 | 5 | export interface SchemaUtils { 6 | optional: () => Schema; 7 | transform: (transformer: SchemaTransformer) => Schema; 8 | parseOrThrow: (raw: unknown, opts?: SchemaOptions) => Promise; 9 | jsonOrThrow: (raw: unknown, opts?: SchemaOptions) => Promise; 10 | } 11 | 12 | export interface SchemaTransformer { 13 | transform: (parsed: Parsed) => Transformed; 14 | untransform: (transformed: any) => Parsed; 15 | } 16 | 17 | export function getSchemaUtils(schema: BaseSchema): SchemaUtils { 18 | return { 19 | optional: () => optional(schema), 20 | transform: (transformer) => transform(schema, transformer), 21 | parseOrThrow: async (raw, opts) => { 22 | const parsed = await schema.parse(raw, opts); 23 | if (parsed.ok) { 24 | return parsed.value; 25 | } 26 | throw new ParseError(parsed.errors); 27 | }, 28 | jsonOrThrow: async (parsed, opts) => { 29 | const raw = await schema.json(parsed, opts); 30 | if (raw.ok) { 31 | return raw.value; 32 | } 33 | throw new JsonError(raw.errors); 34 | }, 35 | }; 36 | } 37 | 38 | /** 39 | * schema utils are defined in one file to resolve issues with circular imports 40 | */ 41 | 42 | export function optional( 43 | schema: BaseSchema 44 | ): Schema { 45 | const baseSchema: BaseSchema = { 46 | parse: (raw, opts) => { 47 | if (raw == null) { 48 | return { 49 | ok: true, 50 | value: undefined, 51 | }; 52 | } 53 | return schema.parse(raw, opts); 54 | }, 55 | json: (parsed, opts) => { 56 | if (parsed == null) { 57 | return { 58 | ok: true, 59 | value: null, 60 | }; 61 | } 62 | return schema.json(parsed, opts); 63 | }, 64 | getType: () => SchemaType.OPTIONAL, 65 | }; 66 | 67 | return { 68 | ...baseSchema, 69 | ...getSchemaUtils(baseSchema), 70 | }; 71 | } 72 | 73 | export function transform( 74 | schema: BaseSchema, 75 | transformer: SchemaTransformer 76 | ): Schema { 77 | const baseSchema: BaseSchema = { 78 | parse: async (raw, opts) => { 79 | const parsed = await schema.parse(raw, opts); 80 | if (!parsed.ok) { 81 | return parsed; 82 | } 83 | return { 84 | ok: true, 85 | value: transformer.transform(parsed.value), 86 | }; 87 | }, 88 | json: async (transformed, opts) => { 89 | const parsed = await transformer.untransform(transformed); 90 | return schema.json(parsed, opts); 91 | }, 92 | getType: () => schema.getType(), 93 | }; 94 | 95 | return { 96 | ...baseSchema, 97 | ...getSchemaUtils(baseSchema), 98 | }; 99 | } 100 | -------------------------------------------------------------------------------- /src/core/schemas/builders/schema-utils/index.ts: -------------------------------------------------------------------------------- 1 | export { getSchemaUtils, optional, transform, type SchemaUtils } from "./getSchemaUtils"; 2 | export { JsonError } from "./JsonError"; 3 | export { ParseError } from "./ParseError"; 4 | -------------------------------------------------------------------------------- /src/core/schemas/builders/schema-utils/stringifyValidationErrors.ts: -------------------------------------------------------------------------------- 1 | import { ValidationError } from "../../Schema"; 2 | 3 | export function stringifyValidationError(error: ValidationError): string { 4 | if (error.path.length === 0) { 5 | return error.message; 6 | } 7 | return `${error.path.join(" -> ")}: ${error.message}`; 8 | } 9 | -------------------------------------------------------------------------------- /src/core/schemas/builders/set/index.ts: -------------------------------------------------------------------------------- 1 | export { set } from "./set"; 2 | -------------------------------------------------------------------------------- /src/core/schemas/builders/set/set.ts: -------------------------------------------------------------------------------- 1 | import { BaseSchema, Schema, SchemaType } from "../../Schema"; 2 | import { list } from "../list"; 3 | import { getSchemaUtils } from "../schema-utils"; 4 | 5 | export function set(schema: Schema): Schema> { 6 | const listSchema = list(schema); 7 | const baseSchema: BaseSchema> = { 8 | parse: async (raw, opts) => { 9 | const parsedList = await listSchema.parse(raw, opts); 10 | if (parsedList.ok) { 11 | return { 12 | ok: true, 13 | value: new Set(parsedList.value), 14 | }; 15 | } else { 16 | return parsedList; 17 | } 18 | }, 19 | json: async (parsed, opts) => { 20 | if (!(parsed instanceof Set)) { 21 | return { 22 | ok: false, 23 | errors: [ 24 | { 25 | path: [], 26 | message: "Not a Set", 27 | }, 28 | ], 29 | }; 30 | } 31 | const jsonList = await listSchema.json([...parsed], opts); 32 | return jsonList; 33 | }, 34 | getType: () => SchemaType.SET, 35 | }; 36 | 37 | return { 38 | ...baseSchema, 39 | ...getSchemaUtils(baseSchema), 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /src/core/schemas/builders/union/discriminant.ts: -------------------------------------------------------------------------------- 1 | export function discriminant( 2 | parsedDiscriminant: ParsedDiscriminant, 3 | rawDiscriminant: RawDiscriminant 4 | ): Discriminant { 5 | return { 6 | parsedDiscriminant, 7 | rawDiscriminant, 8 | }; 9 | } 10 | 11 | export interface Discriminant { 12 | parsedDiscriminant: ParsedDiscriminant; 13 | rawDiscriminant: RawDiscriminant; 14 | } 15 | -------------------------------------------------------------------------------- /src/core/schemas/builders/union/index.ts: -------------------------------------------------------------------------------- 1 | export { discriminant, type Discriminant } from "./discriminant"; 2 | export { 3 | type inferParsedDiscriminant, 4 | type inferParsedUnion, 5 | type inferRawDiscriminant, 6 | type inferRawUnion, 7 | type UnionSubtypes, 8 | } from "./types"; 9 | export { union } from "./union"; 10 | -------------------------------------------------------------------------------- /src/core/schemas/builders/union/types.ts: -------------------------------------------------------------------------------- 1 | import { inferParsedObject, inferRawObject, ObjectSchema } from "../object"; 2 | import { Discriminant } from "./discriminant"; 3 | 4 | export type UnionSubtypes = { 5 | [K in DiscriminantValues]: ObjectSchema; 6 | }; 7 | 8 | export type inferRawUnion, U extends UnionSubtypes> = { 9 | [K in keyof U]: Record, K> & inferRawObject; 10 | }[keyof U]; 11 | 12 | export type inferParsedUnion, U extends UnionSubtypes> = { 13 | [K in keyof U]: Record, K> & inferParsedObject; 14 | }[keyof U]; 15 | 16 | export type inferRawDiscriminant> = D extends string 17 | ? D 18 | : D extends Discriminant 19 | ? Raw 20 | : never; 21 | 22 | export type inferParsedDiscriminant> = D extends string 23 | ? D 24 | : D extends Discriminant 25 | ? Parsed 26 | : never; 27 | -------------------------------------------------------------------------------- /src/core/schemas/builders/union/union.ts: -------------------------------------------------------------------------------- 1 | import { BaseSchema, MaybeValid, SchemaType } from "../../Schema"; 2 | import { isPlainObject, NOT_AN_OBJECT_ERROR_MESSAGE } from "../../utils/isPlainObject"; 3 | import { keys } from "../../utils/keys"; 4 | import { MaybePromise } from "../../utils/MaybePromise"; 5 | import { enum_ } from "../enum"; 6 | import { ObjectSchema } from "../object"; 7 | import { getObjectLikeUtils, ObjectLikeSchema } from "../object-like"; 8 | import { getSchemaUtils } from "../schema-utils"; 9 | import { Discriminant } from "./discriminant"; 10 | import { inferParsedDiscriminant, inferParsedUnion, inferRawDiscriminant, inferRawUnion, UnionSubtypes } from "./types"; 11 | 12 | export function union, U extends UnionSubtypes>( 13 | discriminant: D, 14 | union: U 15 | ): ObjectLikeSchema, inferParsedUnion> { 16 | const rawDiscriminant = 17 | typeof discriminant === "string" ? discriminant : (discriminant.rawDiscriminant as inferRawDiscriminant); 18 | const parsedDiscriminant = 19 | typeof discriminant === "string" 20 | ? discriminant 21 | : (discriminant.parsedDiscriminant as inferParsedDiscriminant); 22 | 23 | const discriminantValueSchema = enum_(keys(union) as string[]); 24 | 25 | const baseSchema: BaseSchema, inferParsedUnion> = { 26 | parse: async (raw, opts) => { 27 | return transformAndValidateUnion( 28 | raw, 29 | rawDiscriminant, 30 | parsedDiscriminant, 31 | (discriminantValue) => discriminantValueSchema.parse(discriminantValue, opts), 32 | (discriminantValue) => union[discriminantValue], 33 | opts?.allowUnknownKeys ?? false, 34 | (additionalProperties, additionalPropertiesSchema) => 35 | additionalPropertiesSchema.parse(additionalProperties, opts) 36 | ); 37 | }, 38 | json: async (parsed, opts) => { 39 | return transformAndValidateUnion( 40 | parsed, 41 | parsedDiscriminant, 42 | rawDiscriminant, 43 | (discriminantValue) => discriminantValueSchema.json(discriminantValue, opts), 44 | (discriminantValue) => union[discriminantValue], 45 | opts?.allowUnknownKeys ?? false, 46 | (additionalProperties, additionalPropertiesSchema) => 47 | additionalPropertiesSchema.json(additionalProperties, opts) 48 | ); 49 | }, 50 | getType: () => SchemaType.UNION, 51 | }; 52 | 53 | return { 54 | ...baseSchema, 55 | ...getSchemaUtils(baseSchema), 56 | ...getObjectLikeUtils(baseSchema), 57 | }; 58 | } 59 | 60 | async function transformAndValidateUnion< 61 | TransformedDiscriminant extends string, 62 | TransformedDiscriminantValue extends string, 63 | TransformedAdditionalProperties 64 | >( 65 | value: unknown, 66 | discriminant: string, 67 | transformedDiscriminant: TransformedDiscriminant, 68 | transformDiscriminantValue: (discriminantValue: unknown) => MaybePromise>, 69 | getAdditionalPropertiesSchema: (discriminantValue: string) => ObjectSchema | undefined, 70 | allowUnknownKeys: boolean, 71 | transformAdditionalProperties: ( 72 | additionalProperties: unknown, 73 | additionalPropertiesSchema: ObjectSchema 74 | ) => MaybePromise> 75 | ): Promise< 76 | MaybeValid & TransformedAdditionalProperties> 77 | > { 78 | if (!isPlainObject(value)) { 79 | return { 80 | ok: false, 81 | errors: [ 82 | { 83 | path: [], 84 | message: NOT_AN_OBJECT_ERROR_MESSAGE, 85 | }, 86 | ], 87 | }; 88 | } 89 | 90 | const { [discriminant]: discriminantValue, ...additionalProperties } = value; 91 | 92 | if (discriminantValue == null) { 93 | return { 94 | ok: false, 95 | errors: [ 96 | { 97 | path: [], 98 | message: `Missing discriminant ("${discriminant}")`, 99 | }, 100 | ], 101 | }; 102 | } 103 | 104 | const transformedDiscriminantValue = await transformDiscriminantValue(discriminantValue); 105 | if (!transformedDiscriminantValue.ok) { 106 | return { 107 | ok: false, 108 | errors: transformedDiscriminantValue.errors.map((error) => ({ 109 | path: [discriminant, ...error.path], 110 | message: error.message, 111 | })), 112 | }; 113 | } 114 | 115 | const additionalPropertiesSchema = getAdditionalPropertiesSchema(transformedDiscriminantValue.value); 116 | 117 | if (additionalPropertiesSchema == null) { 118 | if (allowUnknownKeys) { 119 | return { 120 | ok: true, 121 | value: { 122 | [transformedDiscriminant]: transformedDiscriminantValue.value, 123 | ...additionalProperties, 124 | } as Record & TransformedAdditionalProperties, 125 | }; 126 | } else { 127 | return { 128 | ok: false, 129 | errors: [ 130 | { 131 | path: [discriminant], 132 | message: "Unrecognized discriminant value", 133 | }, 134 | ], 135 | }; 136 | } 137 | } 138 | 139 | const transformedAdditionalProperties = await transformAdditionalProperties( 140 | additionalProperties, 141 | additionalPropertiesSchema 142 | ); 143 | if (!transformedAdditionalProperties.ok) { 144 | return transformedAdditionalProperties; 145 | } 146 | 147 | return { 148 | ok: true, 149 | value: { 150 | [transformedDiscriminant]: discriminantValue, 151 | ...transformedAdditionalProperties.value, 152 | } as Record & TransformedAdditionalProperties, 153 | }; 154 | } 155 | -------------------------------------------------------------------------------- /src/core/schemas/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./builders"; 2 | export { type inferParsed, type inferRaw, type Schema, type SchemaOptions } from "./Schema"; 3 | -------------------------------------------------------------------------------- /src/core/schemas/utils/MaybePromise.ts: -------------------------------------------------------------------------------- 1 | export type MaybePromise = T | Promise; 2 | -------------------------------------------------------------------------------- /src/core/schemas/utils/OptionalRecord.ts: -------------------------------------------------------------------------------- 1 | export type OptionalRecord = Record; 2 | -------------------------------------------------------------------------------- /src/core/schemas/utils/addQuestionMarksToNullableProperties.ts: -------------------------------------------------------------------------------- 1 | export type addQuestionMarksToNullableProperties = { 2 | [K in OptionalKeys]?: T[K]; 3 | } & Pick>; 4 | 5 | export type OptionalKeys = { 6 | [K in keyof T]-?: undefined extends T[K] 7 | ? K 8 | : null extends T[K] 9 | ? K 10 | : 1 extends (any extends T[K] ? 0 : 1) 11 | ? never 12 | : K; 13 | }[keyof T]; 14 | 15 | export type RequiredKeys = Exclude>; 16 | -------------------------------------------------------------------------------- /src/core/schemas/utils/createIdentitySchemaCreator.ts: -------------------------------------------------------------------------------- 1 | import { getSchemaUtils } from "../builders/schema-utils"; 2 | import { BaseSchema, MaybeValid, Schema, SchemaOptions, SchemaType } from "../Schema"; 3 | 4 | export function createIdentitySchemaCreator( 5 | schemaType: SchemaType, 6 | validate: (value: unknown, opts?: SchemaOptions) => MaybeValid 7 | ): () => Schema { 8 | return () => { 9 | const baseSchema: BaseSchema = { 10 | parse: validate, 11 | json: validate, 12 | getType: () => schemaType, 13 | }; 14 | 15 | return { 16 | ...baseSchema, 17 | ...getSchemaUtils(baseSchema), 18 | }; 19 | }; 20 | } 21 | -------------------------------------------------------------------------------- /src/core/schemas/utils/entries.ts: -------------------------------------------------------------------------------- 1 | export function entries(object: T): [keyof T, T[keyof T]][] { 2 | return Object.entries(object) as [keyof T, T[keyof T]][]; 3 | } 4 | -------------------------------------------------------------------------------- /src/core/schemas/utils/filterObject.ts: -------------------------------------------------------------------------------- 1 | export function filterObject(obj: T, keysToInclude: K[]): Pick { 2 | const keysToIncludeSet = new Set(keysToInclude); 3 | return Object.entries(obj).reduce((acc, [key, value]) => { 4 | if (keysToIncludeSet.has(key as K)) { 5 | acc[key as K] = value; 6 | } 7 | return acc; 8 | // eslint-disable-next-line @typescript-eslint/prefer-reduce-type-parameter 9 | }, {} as Pick); 10 | } 11 | -------------------------------------------------------------------------------- /src/core/schemas/utils/isPlainObject.ts: -------------------------------------------------------------------------------- 1 | export const NOT_AN_OBJECT_ERROR_MESSAGE = "Not an object"; 2 | 3 | // borrowed from https://github.com/lodash/lodash/blob/master/isPlainObject.js 4 | export function isPlainObject(value: unknown): value is Record { 5 | if (typeof value !== "object" || value === null) { 6 | return false; 7 | } 8 | 9 | if (Object.getPrototypeOf(value) === null) { 10 | return true; 11 | } 12 | 13 | let proto = value; 14 | while (Object.getPrototypeOf(proto) !== null) { 15 | proto = Object.getPrototypeOf(proto); 16 | } 17 | 18 | return Object.getPrototypeOf(value) === proto; 19 | } 20 | -------------------------------------------------------------------------------- /src/core/schemas/utils/keys.ts: -------------------------------------------------------------------------------- 1 | export function keys(object: T): (keyof T)[] { 2 | return Object.keys(object) as (keyof T)[]; 3 | } 4 | -------------------------------------------------------------------------------- /src/core/schemas/utils/partition.ts: -------------------------------------------------------------------------------- 1 | export function partition(items: readonly T[], predicate: (item: T) => boolean): [T[], T[]] { 2 | const trueItems: T[] = [], 3 | falseItems: T[] = []; 4 | for (const item of items) { 5 | if (predicate(item)) { 6 | trueItems.push(item); 7 | } else { 8 | falseItems.push(item); 9 | } 10 | } 11 | return [trueItems, falseItems]; 12 | } 13 | -------------------------------------------------------------------------------- /src/environments.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export const ScaleEnvironment = { 6 | Production: "https://api.scale.com/v1/", 7 | } as const; 8 | 9 | export type ScaleEnvironment = typeof ScaleEnvironment.Production; 10 | -------------------------------------------------------------------------------- /src/errors/ScaleError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export class ScaleError extends Error { 6 | readonly statusCode?: number; 7 | readonly body?: unknown; 8 | 9 | constructor({ message, statusCode, body }: { message?: string; statusCode?: number; body?: unknown }) { 10 | super(message); 11 | Object.setPrototypeOf(this, ScaleError.prototype); 12 | if (statusCode != null) { 13 | this.statusCode = statusCode; 14 | } 15 | 16 | if (body !== undefined) { 17 | this.body = body; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/errors/ScaleTimeoutError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | export class ScaleTimeoutError extends Error { 6 | constructor() { 7 | super("Timeout"); 8 | Object.setPrototypeOf(this, ScaleTimeoutError.prototype); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/errors/index.ts: -------------------------------------------------------------------------------- 1 | export { ScaleError } from "./ScaleError"; 2 | export { ScaleTimeoutError } from "./ScaleTimeoutError"; 3 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * as Scale from "./api"; 2 | export { ScaleClient } from "./Client"; 3 | export { ScaleEnvironment } from "./environments"; 4 | export { ScaleError, ScaleTimeoutError } from "./errors"; 5 | -------------------------------------------------------------------------------- /src/serialization/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./resources"; 2 | -------------------------------------------------------------------------------- /src/serialization/resources/batches/client/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./requests"; 2 | -------------------------------------------------------------------------------- /src/serialization/resources/batches/client/requests/CreateBatchRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../core"; 8 | 9 | export const CreateBatchRequest: core.serialization.Schema< 10 | serializers.CreateBatchRequest.Raw, 11 | Scale.CreateBatchRequest 12 | > = core.serialization.object({ 13 | project: core.serialization.string(), 14 | name: core.serialization.string(), 15 | callback: core.serialization.string().optional(), 16 | calibrationBatch: core.serialization.property("calibration_batch", core.serialization.boolean().optional()), 17 | selfLabelBatch: core.serialization.property("self_label_batch", core.serialization.boolean().optional()), 18 | }); 19 | 20 | export declare namespace CreateBatchRequest { 21 | interface Raw { 22 | project: string; 23 | name: string; 24 | callback?: string | null; 25 | calibration_batch?: boolean | null; 26 | self_label_batch?: boolean | null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/serialization/resources/batches/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { CreateBatchRequest } from "./CreateBatchRequest"; 2 | -------------------------------------------------------------------------------- /src/serialization/resources/batches/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./client"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/batches/types/Batch.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const Batch: core.serialization.ObjectSchema = core.serialization.object({ 10 | project: core.serialization.string().optional(), 11 | name: core.serialization.string().optional(), 12 | status: core.serialization.string().optional(), 13 | callback: core.serialization.string().optional(), 14 | createdAt: core.serialization.property("created_at", core.serialization.string().optional()), 15 | }); 16 | 17 | export declare namespace Batch { 18 | interface Raw { 19 | project?: string | null; 20 | name?: string | null; 21 | status?: string | null; 22 | callback?: string | null; 23 | created_at?: string | null; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/serialization/resources/batches/types/BatchList.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const BatchList: core.serialization.ObjectSchema = 10 | core.serialization.object({ 11 | docs: core.serialization 12 | .list(core.serialization.lazyObject(async () => (await import("../../..")).Batch)) 13 | .optional(), 14 | total: core.serialization.number().optional(), 15 | limit: core.serialization.number().optional(), 16 | offset: core.serialization.number().optional(), 17 | hasMore: core.serialization.property("has_more", core.serialization.boolean().optional()), 18 | }); 19 | 20 | export declare namespace BatchList { 21 | interface Raw { 22 | docs?: serializers.Batch.Raw[] | null; 23 | total?: number | null; 24 | limit?: number | null; 25 | offset?: number | null; 26 | has_more?: boolean | null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/serialization/resources/batches/types/BatchStatus.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const BatchStatus: core.serialization.Schema = 10 | core.serialization.enum_(["staging", "in_progress", "completed"]); 11 | 12 | export declare namespace BatchStatus { 13 | type Raw = "staging" | "in_progress" | "completed"; 14 | } 15 | -------------------------------------------------------------------------------- /src/serialization/resources/batches/types/BatchStatusResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const BatchStatusResponse: core.serialization.ObjectSchema< 10 | serializers.BatchStatusResponse.Raw, 11 | Scale.BatchStatusResponse 12 | > = core.serialization.object({ 13 | status: core.serialization.lazy(async () => (await import("../../..")).BatchStatus).optional(), 14 | pending: core.serialization.number().optional(), 15 | error: core.serialization.number().optional(), 16 | completed: core.serialization.number().optional(), 17 | canceled: core.serialization.number().optional(), 18 | }); 19 | 20 | export declare namespace BatchStatusResponse { 21 | interface Raw { 22 | status?: serializers.BatchStatus.Raw | null; 23 | pending?: number | null; 24 | error?: number | null; 25 | completed?: number | null; 26 | canceled?: number | null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/serialization/resources/batches/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./BatchList"; 2 | export * from "./Batch"; 3 | export * from "./BatchStatusResponse"; 4 | export * from "./BatchStatus"; 5 | -------------------------------------------------------------------------------- /src/serialization/resources/index.ts: -------------------------------------------------------------------------------- 1 | export * as batches from "./batches"; 2 | export * from "./batches/types"; 3 | export * as projects from "./projects"; 4 | export * from "./projects/types"; 5 | export * as studio from "./studio"; 6 | export * as tasks from "./tasks"; 7 | export * from "./tasks/types"; 8 | export * as teammates from "./teammates"; 9 | export * from "./teammates/types"; 10 | export * as video from "./video"; 11 | export * from "./video/types"; 12 | export * from "./batches/client/requests"; 13 | export * from "./projects/client/requests"; 14 | export * from "./tasks/client/requests"; 15 | -------------------------------------------------------------------------------- /src/serialization/resources/projects/client/index.ts: -------------------------------------------------------------------------------- 1 | export * as list from "./list"; 2 | export * from "./requests"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/projects/client/list.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const Response: core.serialization.Schema = 10 | core.serialization.list(core.serialization.lazyObject(async () => (await import("../../..")).Project)); 11 | 12 | export declare namespace Response { 13 | type Raw = serializers.Project.Raw[]; 14 | } 15 | -------------------------------------------------------------------------------- /src/serialization/resources/projects/client/requests/CreateProjectRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../core"; 8 | 9 | export const CreateProjectRequest: core.serialization.Schema< 10 | serializers.CreateProjectRequest.Raw, 11 | Scale.CreateProjectRequest 12 | > = core.serialization.object({ 13 | type: core.serialization.lazy(async () => (await import("../../../..")).TaskType), 14 | name: core.serialization.string(), 15 | rapid: core.serialization.boolean().optional(), 16 | params: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), 17 | }); 18 | 19 | export declare namespace CreateProjectRequest { 20 | interface Raw { 21 | type: serializers.TaskType.Raw; 22 | name: string; 23 | rapid?: boolean | null; 24 | params?: Record | null; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/serialization/resources/projects/client/requests/SetOntologyRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../core"; 8 | 9 | export const SetOntologyRequest: core.serialization.Schema< 10 | serializers.SetOntologyRequest.Raw, 11 | Scale.SetOntologyRequest 12 | > = core.serialization.object({ 13 | ontology: core.serialization.list(core.serialization.unknown()), 14 | name: core.serialization.string().optional(), 15 | }); 16 | 17 | export declare namespace SetOntologyRequest { 18 | interface Raw { 19 | ontology: unknown[]; 20 | name?: string | null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/serialization/resources/projects/client/requests/UpdateProjectParametersRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../core"; 8 | 9 | export const UpdateProjectParametersRequest: core.serialization.Schema< 10 | serializers.UpdateProjectParametersRequest.Raw, 11 | Scale.UpdateProjectParametersRequest 12 | > = core.serialization.object({ 13 | patch: core.serialization.boolean().optional(), 14 | instruction: core.serialization.string().optional(), 15 | }); 16 | 17 | export declare namespace UpdateProjectParametersRequest { 18 | interface Raw { 19 | patch?: boolean | null; 20 | instruction?: string | null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/serialization/resources/projects/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { CreateProjectRequest } from "./CreateProjectRequest"; 2 | export { UpdateProjectParametersRequest } from "./UpdateProjectParametersRequest"; 3 | export { SetOntologyRequest } from "./SetOntologyRequest"; 4 | -------------------------------------------------------------------------------- /src/serialization/resources/projects/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./client"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/projects/types/Project.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const Project: core.serialization.ObjectSchema = 10 | core.serialization.object({ 11 | type: core.serialization.string().optional(), 12 | name: core.serialization.string().optional(), 13 | paramHistory: core.serialization.property( 14 | "param_history", 15 | core.serialization 16 | .list(core.serialization.lazyObject(async () => (await import("../../..")).ProjectPramHistory)) 17 | .optional() 18 | ), 19 | createdAt: core.serialization.property("created_at", core.serialization.string().optional()), 20 | }); 21 | 22 | export declare namespace Project { 23 | interface Raw { 24 | type?: string | null; 25 | name?: string | null; 26 | param_history?: serializers.ProjectPramHistory.Raw[] | null; 27 | created_at?: string | null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/serialization/resources/projects/types/ProjectPramHistory.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const ProjectPramHistory: core.serialization.ObjectSchema< 10 | serializers.ProjectPramHistory.Raw, 11 | Scale.ProjectPramHistory 12 | > = core.serialization.object({ 13 | instruction: core.serialization.string().optional(), 14 | version: core.serialization.number().optional(), 15 | createdAt: core.serialization.property("created_at", core.serialization.string().optional()), 16 | }); 17 | 18 | export declare namespace ProjectPramHistory { 19 | interface Raw { 20 | instruction?: string | null; 21 | version?: number | null; 22 | created_at?: string | null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/serialization/resources/projects/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./Project"; 2 | export * from "./ProjectPramHistory"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./resources"; 2 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/assignments/client/index.ts: -------------------------------------------------------------------------------- 1 | export * as list from "./list"; 2 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/assignments/client/list.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../../core"; 8 | 9 | export const Response: core.serialization.Schema< 10 | serializers.studio.assignments.list.Response.Raw, 11 | Record 12 | > = core.serialization.record( 13 | core.serialization.string(), 14 | core.serialization.lazy(async () => (await import("../../../../..")).studio.Assignment).optional() 15 | ); 16 | 17 | export declare namespace Response { 18 | type Raw = Record; 19 | } 20 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/assignments/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./client"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/assignments/types/AssignTeammate.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../../core"; 8 | 9 | export const AssignTeammate: core.serialization.ObjectSchema< 10 | serializers.studio.AssignTeammate.Raw, 11 | Scale.studio.AssignTeammate 12 | > = core.serialization.object({ 13 | emails: core.serialization.list(core.serialization.string()), 14 | projects: core.serialization.list(core.serialization.string()), 15 | }); 16 | 17 | export declare namespace AssignTeammate { 18 | interface Raw { 19 | emails: string[]; 20 | projects: string[]; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/assignments/types/Assignment.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../../core"; 8 | 9 | export const Assignment: core.serialization.Schema = 10 | core.serialization.list(core.serialization.string()); 11 | 12 | export declare namespace Assignment { 13 | type Raw = string[]; 14 | } 15 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/assignments/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./Assignment"; 2 | export * from "./AssignTeammate"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/batches/client/index.ts: -------------------------------------------------------------------------------- 1 | export * as list from "./list"; 2 | export * as setPriorities from "./setPriorities"; 3 | export * as resetPriorities from "./resetPriorities"; 4 | export * from "./requests"; 5 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/batches/client/list.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../../core"; 8 | 9 | export const Response: core.serialization.Schema = 10 | core.serialization.list(core.serialization.lazyObject(async () => (await import("../../../../..")).studio.Batch)); 11 | 12 | export declare namespace Response { 13 | type Raw = serializers.studio.Batch.Raw[]; 14 | } 15 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/batches/client/requests/SetBatchGroupRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../../../core"; 8 | 9 | export const SetBatchGroupRequest: core.serialization.Schema< 10 | serializers.studio.SetBatchGroupRequest.Raw, 11 | Scale.studio.SetBatchGroupRequest 12 | > = core.serialization.object({ 13 | groups: core.serialization.list(core.serialization.string()).optional(), 14 | }); 15 | 16 | export declare namespace SetBatchGroupRequest { 17 | interface Raw { 18 | groups?: string[] | null; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/batches/client/requests/SetBatchPrioritiesRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../../../core"; 8 | 9 | export const SetBatchPrioritiesRequest: core.serialization.Schema< 10 | serializers.studio.SetBatchPrioritiesRequest.Raw, 11 | Scale.studio.SetBatchPrioritiesRequest 12 | > = core.serialization.object({ 13 | groups: core.serialization 14 | .list(core.serialization.lazyObject(async () => (await import("../../../../../..")).studio.BatchName)) 15 | .optional(), 16 | }); 17 | 18 | export declare namespace SetBatchPrioritiesRequest { 19 | interface Raw { 20 | groups?: serializers.studio.BatchName.Raw[] | null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/batches/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { SetBatchGroupRequest } from "./SetBatchGroupRequest"; 2 | export { SetBatchPrioritiesRequest } from "./SetBatchPrioritiesRequest"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/batches/client/resetPriorities.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../../core"; 8 | 9 | export const Response: core.serialization.Schema< 10 | serializers.studio.batches.resetPriorities.Response.Raw, 11 | Scale.studio.Batch[] 12 | > = core.serialization.list(core.serialization.lazyObject(async () => (await import("../../../../..")).studio.Batch)); 13 | 14 | export declare namespace Response { 15 | type Raw = serializers.studio.Batch.Raw[]; 16 | } 17 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/batches/client/setPriorities.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../../core"; 8 | 9 | export const Response: core.serialization.Schema< 10 | serializers.studio.batches.setPriorities.Response.Raw, 11 | Scale.studio.Batch[] 12 | > = core.serialization.list(core.serialization.lazyObject(async () => (await import("../../../../..")).studio.Batch)); 13 | 14 | export declare namespace Response { 15 | type Raw = serializers.studio.Batch.Raw[]; 16 | } 17 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/batches/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./client"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/batches/types/Batch.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../../core"; 8 | 9 | export const Batch: core.serialization.ObjectSchema = 10 | core.serialization.object({ 11 | id: core.serialization.string().optional(), 12 | name: core.serialization.string().optional(), 13 | projectId: core.serialization.string().optional(), 14 | projectName: core.serialization.string().optional(), 15 | batchType: core.serialization.string().optional(), 16 | studioPriority: core.serialization.number().optional(), 17 | total: core.serialization.number().optional(), 18 | completed: core.serialization.number().optional(), 19 | groups: core.serialization.list(core.serialization.string()).optional(), 20 | }); 21 | 22 | export declare namespace Batch { 23 | interface Raw { 24 | id?: string | null; 25 | name?: string | null; 26 | projectId?: string | null; 27 | projectName?: string | null; 28 | batchType?: string | null; 29 | studioPriority?: number | null; 30 | total?: number | null; 31 | completed?: number | null; 32 | groups?: string[] | null; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/batches/types/BatchName.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../../core"; 8 | 9 | export const BatchName: core.serialization.ObjectSchema = 10 | core.serialization.object({ 11 | name: core.serialization.string(), 12 | }); 13 | 14 | export declare namespace BatchName { 15 | interface Raw { 16 | name: string; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/batches/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./BatchName"; 2 | export * from "./Batch"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/index.ts: -------------------------------------------------------------------------------- 1 | export * as assignments from "./assignments"; 2 | export * from "./assignments/types"; 3 | export * as batches from "./batches"; 4 | export * from "./batches/types"; 5 | export * as projectGroups from "./projectGroups"; 6 | export * from "./projectGroups/types"; 7 | export * from "./batches/client/requests"; 8 | export * from "./projectGroups/client/requests"; 9 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/projectGroups/client/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./requests"; 2 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/projectGroups/client/requests/CreateProjectGroupRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../../../core"; 8 | 9 | export const CreateProjectGroupRequest: core.serialization.Schema< 10 | serializers.studio.CreateProjectGroupRequest.Raw, 11 | Scale.studio.CreateProjectGroupRequest 12 | > = core.serialization.object({ 13 | emails: core.serialization.list(core.serialization.string()), 14 | name: core.serialization.string(), 15 | }); 16 | 17 | export declare namespace CreateProjectGroupRequest { 18 | interface Raw { 19 | emails: string[]; 20 | name: string; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/projectGroups/client/requests/UpdateProjectGroupRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../../../core"; 8 | 9 | export const UpdateProjectGroupRequest: core.serialization.Schema< 10 | serializers.studio.UpdateProjectGroupRequest.Raw, 11 | Scale.studio.UpdateProjectGroupRequest 12 | > = core.serialization.object({ 13 | addEmails: core.serialization.property( 14 | "add_emails", 15 | core.serialization.list(core.serialization.string()).optional() 16 | ), 17 | removeEmails: core.serialization.property( 18 | "remove_emails", 19 | core.serialization.list(core.serialization.string()).optional() 20 | ), 21 | }); 22 | 23 | export declare namespace UpdateProjectGroupRequest { 24 | interface Raw { 25 | add_emails?: string[] | null; 26 | remove_emails?: string[] | null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/projectGroups/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { CreateProjectGroupRequest } from "./CreateProjectGroupRequest"; 2 | export { UpdateProjectGroupRequest } from "./UpdateProjectGroupRequest"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/projectGroups/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./client"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/projectGroups/types/ProjectGroup.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../../core"; 8 | 9 | export const ProjectGroup: core.serialization.ObjectSchema< 10 | serializers.studio.ProjectGroup.Raw, 11 | Scale.studio.ProjectGroup 12 | > = core.serialization.object({ 13 | id: core.serialization.string().optional(), 14 | name: core.serialization.string().optional(), 15 | numWorkers: core.serialization.number().optional(), 16 | isSingleton: core.serialization.boolean().optional(), 17 | workers: core.serialization 18 | .list(core.serialization.lazyObject(async () => (await import("../../../../..")).studio.Workers)) 19 | .optional(), 20 | }); 21 | 22 | export declare namespace ProjectGroup { 23 | interface Raw { 24 | id?: string | null; 25 | name?: string | null; 26 | numWorkers?: number | null; 27 | isSingleton?: boolean | null; 28 | workers?: serializers.studio.Workers.Raw[] | null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/projectGroups/types/Workers.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../../core"; 8 | 9 | export const Workers: core.serialization.ObjectSchema = 10 | core.serialization.object({ 11 | id: core.serialization.string(), 12 | email: core.serialization.string(), 13 | }); 14 | 15 | export declare namespace Workers { 16 | interface Raw { 17 | id: string; 18 | email: string; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/serialization/resources/studio/resources/projectGroups/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./ProjectGroup"; 2 | export * from "./Workers"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/tasks/client/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./requests"; 2 | -------------------------------------------------------------------------------- /src/serialization/resources/tasks/client/requests/SetTaskMetadataRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../../core"; 8 | 9 | export const SetTaskMetadataRequest: core.serialization.Schema< 10 | serializers.SetTaskMetadataRequest.Raw, 11 | Scale.SetTaskMetadataRequest 12 | > = core.serialization.object({ 13 | docs: core.serialization.record(core.serialization.string(), core.serialization.unknown()), 14 | }); 15 | 16 | export declare namespace SetTaskMetadataRequest { 17 | interface Raw { 18 | docs: Record; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/serialization/resources/tasks/client/requests/index.ts: -------------------------------------------------------------------------------- 1 | export { SetTaskMetadataRequest } from "./SetTaskMetadataRequest"; 2 | -------------------------------------------------------------------------------- /src/serialization/resources/tasks/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./client"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/tasks/types/Annotations.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const Annotations: core.serialization.ObjectSchema = 10 | core.serialization.object({ 11 | objectsToAnnotate: core.serialization.property( 12 | "objects_to_annotate", 13 | core.serialization.list(core.serialization.string()).optional() 14 | ), 15 | }); 16 | 17 | export declare namespace Annotations { 18 | interface Raw { 19 | objects_to_annotate?: string[] | null; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/serialization/resources/tasks/types/ListTasksResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const ListTasksResponse: core.serialization.ObjectSchema< 10 | serializers.ListTasksResponse.Raw, 11 | Scale.ListTasksResponse 12 | > = core.serialization.object({ 13 | docs: core.serialization 14 | .list(core.serialization.lazyObject(async () => (await import("../../..")).Task)) 15 | .optional(), 16 | total: core.serialization.number().optional(), 17 | limit: core.serialization.number().optional(), 18 | hasMore: core.serialization.property("has_more", core.serialization.boolean().optional()), 19 | nextToken: core.serialization.property("next_token", core.serialization.string().optional()), 20 | }); 21 | 22 | export declare namespace ListTasksResponse { 23 | interface Raw { 24 | docs?: serializers.Task.Raw[] | null; 25 | total?: number | null; 26 | limit?: number | null; 27 | has_more?: boolean | null; 28 | next_token?: string | null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/serialization/resources/tasks/types/Task.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const Task: core.serialization.ObjectSchema = core.serialization.object({ 10 | taskId: core.serialization.property("task_id", core.serialization.string().optional()), 11 | createdAt: core.serialization.property("created_at", core.serialization.string().optional()), 12 | callbackUrl: core.serialization.property("callback_url", core.serialization.string().optional()), 13 | type: core.serialization.string().optional(), 14 | status: core.serialization.string().optional(), 15 | instruction: core.serialization.string().optional(), 16 | params: core.serialization.lazyObject(async () => (await import("../../..")).TaskParams).optional(), 17 | metadata: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), 18 | }); 19 | 20 | export declare namespace Task { 21 | interface Raw { 22 | task_id?: string | null; 23 | created_at?: string | null; 24 | callback_url?: string | null; 25 | type?: string | null; 26 | status?: string | null; 27 | instruction?: string | null; 28 | params?: serializers.TaskParams.Raw | null; 29 | metadata?: Record | null; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/serialization/resources/tasks/types/TaskGeometries.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const TaskGeometries: core.serialization.ObjectSchema = 10 | core.serialization.object({ 11 | box: core.serialization.lazyObject(async () => (await import("../../..")).Annotations).optional(), 12 | }); 13 | 14 | export declare namespace TaskGeometries { 15 | interface Raw { 16 | box?: serializers.Annotations.Raw | null; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/serialization/resources/tasks/types/TaskParams.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const TaskParams: core.serialization.ObjectSchema = 10 | core.serialization.object({ 11 | attachment: core.serialization.string().optional(), 12 | geometries: core.serialization.lazyObject(async () => (await import("../../..")).TaskGeometries).optional(), 13 | }); 14 | 15 | export declare namespace TaskParams { 16 | interface Raw { 17 | attachment?: string | null; 18 | geometries?: serializers.TaskGeometries.Raw | null; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/serialization/resources/tasks/types/TaskType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const TaskType: core.serialization.Schema = core.serialization.enum_([ 10 | "annotation", 11 | "categorization", 12 | "comparison", 13 | "cuboidannotation", 14 | "datacollection", 15 | "documentmodel", 16 | "documenttranscription", 17 | "imageannotation", 18 | "laneannotation", 19 | "lidarannotation", 20 | "lidarlinking", 21 | "lidarsegmentation", 22 | "lidartopdown", 23 | "lineannotation", 24 | "namedentityrecognition", 25 | "pointannotation", 26 | "polygonannotation", 27 | "segmentannotation", 28 | "transcription", 29 | "textcollection", 30 | "videoannotation", 31 | "videoboxannotation", 32 | "videoplaybackannotation", 33 | "videocuboidannotation", 34 | ]); 35 | 36 | export declare namespace TaskType { 37 | type Raw = 38 | | "annotation" 39 | | "categorization" 40 | | "comparison" 41 | | "cuboidannotation" 42 | | "datacollection" 43 | | "documentmodel" 44 | | "documenttranscription" 45 | | "imageannotation" 46 | | "laneannotation" 47 | | "lidarannotation" 48 | | "lidarlinking" 49 | | "lidarsegmentation" 50 | | "lidartopdown" 51 | | "lineannotation" 52 | | "namedentityrecognition" 53 | | "pointannotation" 54 | | "polygonannotation" 55 | | "segmentannotation" 56 | | "transcription" 57 | | "textcollection" 58 | | "videoannotation" 59 | | "videoboxannotation" 60 | | "videoplaybackannotation" 61 | | "videocuboidannotation"; 62 | } 63 | -------------------------------------------------------------------------------- /src/serialization/resources/tasks/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./ListTasksResponse"; 2 | export * from "./TaskType"; 3 | export * from "./Task"; 4 | export * from "./Annotations"; 5 | export * from "./TaskGeometries"; 6 | export * from "./TaskParams"; 7 | -------------------------------------------------------------------------------- /src/serialization/resources/teammates/client/index.ts: -------------------------------------------------------------------------------- 1 | export * as list from "./list"; 2 | -------------------------------------------------------------------------------- /src/serialization/resources/teammates/client/list.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const Response: core.serialization.Schema = 10 | core.serialization.list(core.serialization.lazyObject(async () => (await import("../../..")).Teammate)); 11 | 12 | export declare namespace Response { 13 | type Raw = serializers.Teammate.Raw[]; 14 | } 15 | -------------------------------------------------------------------------------- /src/serialization/resources/teammates/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./client"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/teammates/types/Teammate.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const Teammate: core.serialization.ObjectSchema = 10 | core.serialization.object({ 11 | email: core.serialization.string(), 12 | role: core.serialization.string(), 13 | company: core.serialization.string().optional(), 14 | firstName: core.serialization.string().optional(), 15 | lastName: core.serialization.string().optional(), 16 | isStudioLabeler: core.serialization.boolean().optional(), 17 | expiry: core.serialization.string().optional(), 18 | }); 19 | 20 | export declare namespace Teammate { 21 | interface Raw { 22 | email: string; 23 | role: string; 24 | company?: string | null; 25 | firstName?: string | null; 26 | lastName?: string | null; 27 | isStudioLabeler?: boolean | null; 28 | expiry?: string | null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/serialization/resources/teammates/types/TeamsInvite.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const TeamsInvite: core.serialization.ObjectSchema = 10 | core.serialization.object({ 11 | emails: core.serialization.list(core.serialization.string()), 12 | teamRole: core.serialization.property("team_role", core.serialization.string()), 13 | }); 14 | 15 | export declare namespace TeamsInvite { 16 | interface Raw { 17 | emails: string[]; 18 | team_role: string; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/serialization/resources/teammates/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./Teammate"; 2 | export * from "./TeamsInvite"; 3 | -------------------------------------------------------------------------------- /src/serialization/resources/video/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | -------------------------------------------------------------------------------- /src/serialization/resources/video/types/AnnotationAttribute.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const AnnotationAttribute: core.serialization.ObjectSchema< 10 | serializers.AnnotationAttribute.Raw, 11 | Scale.AnnotationAttribute 12 | > = core.serialization.object({ 13 | type: core.serialization.string().optional(), 14 | description: core.serialization.string().optional(), 15 | choices: core.serialization.string().optional(), 16 | }); 17 | 18 | export declare namespace AnnotationAttribute { 19 | interface Raw { 20 | type?: string | null; 21 | description?: string | null; 22 | choices?: string | null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/serialization/resources/video/types/Box.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const Box: core.serialization.ObjectSchema = core.serialization.object({ 10 | objectsToAnnotate: core.serialization.property( 11 | "objects_to_annotate", 12 | core.serialization.list(core.serialization.unknown()).optional() 13 | ), 14 | minHeight: core.serialization.property("min_height", core.serialization.number().optional()), 15 | minWidth: core.serialization.property("min_width", core.serialization.number().optional()), 16 | }); 17 | 18 | export declare namespace Box { 19 | interface Raw { 20 | objects_to_annotate?: unknown[] | null; 21 | min_height?: number | null; 22 | min_width?: number | null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/serialization/resources/video/types/CameraIntrinsics.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const CameraIntrinsics: core.serialization.ObjectSchema< 10 | serializers.CameraIntrinsics.Raw, 11 | Scale.CameraIntrinsics 12 | > = core.serialization.object({ 13 | fx: core.serialization.number().optional(), 14 | fy: core.serialization.number().optional(), 15 | cx: core.serialization.number().optional(), 16 | cy: core.serialization.number().optional(), 17 | skew: core.serialization.number().optional(), 18 | scalefactor: core.serialization.number().optional(), 19 | }); 20 | 21 | export declare namespace CameraIntrinsics { 22 | interface Raw { 23 | fx?: number | null; 24 | fy?: number | null; 25 | cx?: number | null; 26 | cy?: number | null; 27 | skew?: number | null; 28 | scalefactor?: number | null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/serialization/resources/video/types/CameraRotationQuaternion.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const CameraRotationQuaternion: core.serialization.ObjectSchema< 10 | serializers.CameraRotationQuaternion.Raw, 11 | Scale.CameraRotationQuaternion 12 | > = core.serialization.object({ 13 | w: core.serialization.number().optional(), 14 | x: core.serialization.number().optional(), 15 | y: core.serialization.number().optional(), 16 | z: core.serialization.number().optional(), 17 | }); 18 | 19 | export declare namespace CameraRotationQuaternion { 20 | interface Raw { 21 | w?: number | null; 22 | x?: number | null; 23 | y?: number | null; 24 | z?: number | null; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/serialization/resources/video/types/Cuboid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const Cuboid: core.serialization.ObjectSchema = core.serialization.object({ 10 | objectsToAnnotate: core.serialization.property( 11 | "objects_to_annotate", 12 | core.serialization.list(core.serialization.unknown()).optional() 13 | ), 14 | minHeight: core.serialization.property("min_height", core.serialization.number().optional()), 15 | minWidth: core.serialization.property("min_width", core.serialization.number().optional()), 16 | cameraIntrinsics: core.serialization.property( 17 | "camera_intrinsics", 18 | core.serialization.lazyObject(async () => (await import("../../..")).CameraIntrinsics).optional() 19 | ), 20 | cameraRotationQuaternion: core.serialization.property( 21 | "camera_rotation_quaternion", 22 | core.serialization.lazyObject(async () => (await import("../../..")).CameraRotationQuaternion).optional() 23 | ), 24 | cameraHeight: core.serialization.property("camera_height", core.serialization.number().optional()), 25 | }); 26 | 27 | export declare namespace Cuboid { 28 | interface Raw { 29 | objects_to_annotate?: unknown[] | null; 30 | min_height?: number | null; 31 | min_width?: number | null; 32 | camera_intrinsics?: serializers.CameraIntrinsics.Raw | null; 33 | camera_rotation_quaternion?: serializers.CameraRotationQuaternion.Raw | null; 34 | camera_height?: number | null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/serialization/resources/video/types/Ellipse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const Ellipse: core.serialization.ObjectSchema = 10 | core.serialization.object({ 11 | objectsToAnnotate: core.serialization.property( 12 | "objects_to_annotate", 13 | core.serialization.list(core.serialization.unknown()).optional() 14 | ), 15 | vertices: core.serialization.list(core.serialization.unknown()).optional(), 16 | }); 17 | 18 | export declare namespace Ellipse { 19 | interface Raw { 20 | objects_to_annotate?: unknown[] | null; 21 | vertices?: unknown[] | null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/serialization/resources/video/types/Geometries.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const Geometries: core.serialization.ObjectSchema = 10 | core.serialization.object({ 11 | box: core.serialization.lazyObject(async () => (await import("../../..")).Box).optional(), 12 | polygon: core.serialization.lazyObject(async () => (await import("../../..")).Polygon).optional(), 13 | line: core.serialization.lazyObject(async () => (await import("../../..")).Line).optional(), 14 | point: core.serialization.lazyObject(async () => (await import("../../..")).Point).optional(), 15 | cuboid: core.serialization.lazyObject(async () => (await import("../../..")).Cuboid).optional(), 16 | ellipse: core.serialization.lazyObject(async () => (await import("../../..")).Ellipse).optional(), 17 | }); 18 | 19 | export declare namespace Geometries { 20 | interface Raw { 21 | box?: serializers.Box.Raw | null; 22 | polygon?: serializers.Polygon.Raw | null; 23 | line?: serializers.Line.Raw | null; 24 | point?: serializers.Point.Raw | null; 25 | cuboid?: serializers.Cuboid.Raw | null; 26 | ellipse?: serializers.Ellipse.Raw | null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/serialization/resources/video/types/Line.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const Line: core.serialization.ObjectSchema = core.serialization.object({ 10 | objectsToAnnotate: core.serialization.property( 11 | "objects_to_annotate", 12 | core.serialization.list(core.serialization.unknown()).optional() 13 | ), 14 | minVertices: core.serialization.property("min_vertices", core.serialization.number().optional()), 15 | maxVertices: core.serialization.property("max_vertices", core.serialization.number().optional()), 16 | }); 17 | 18 | export declare namespace Line { 19 | interface Raw { 20 | objects_to_annotate?: unknown[] | null; 21 | min_vertices?: number | null; 22 | max_vertices?: number | null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/serialization/resources/video/types/Links.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const Links: core.serialization.ObjectSchema = core.serialization.object({ 10 | isBidirectional: core.serialization.property("is_bidirectional", core.serialization.boolean().optional()), 11 | fromAllowedLabels: core.serialization.property( 12 | "from_allowed_labels", 13 | core.serialization.list(core.serialization.unknown()).optional() 14 | ), 15 | toAllowedLabels: core.serialization.property( 16 | "to_allowed_labels", 17 | core.serialization.list(core.serialization.unknown()).optional() 18 | ), 19 | }); 20 | 21 | export declare namespace Links { 22 | interface Raw { 23 | is_bidirectional?: boolean | null; 24 | from_allowed_labels?: unknown[] | null; 25 | to_allowed_labels?: unknown[] | null; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/serialization/resources/video/types/ObjectsToAnnotate.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const ObjectsToAnnotate: core.serialization.ObjectSchema< 10 | serializers.ObjectsToAnnotate.Raw, 11 | Scale.ObjectsToAnnotate 12 | > = core.serialization.object({ 13 | objectsToAnnotate: core.serialization.property( 14 | "objects_to_annotate", 15 | core.serialization.list(core.serialization.unknown()).optional() 16 | ), 17 | }); 18 | 19 | export declare namespace ObjectsToAnnotate { 20 | interface Raw { 21 | objects_to_annotate?: unknown[] | null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/serialization/resources/video/types/Point.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const Point: core.serialization.ObjectSchema = core.serialization.object({ 10 | objectsToAnnotate: core.serialization.property( 11 | "objects_to_annotate", 12 | core.serialization.list(core.serialization.unknown()).optional() 13 | ), 14 | x: core.serialization.number().optional(), 15 | y: core.serialization.number().optional(), 16 | }); 17 | 18 | export declare namespace Point { 19 | interface Raw { 20 | objects_to_annotate?: unknown[] | null; 21 | x?: number | null; 22 | y?: number | null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/serialization/resources/video/types/Polygon.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const Polygon: core.serialization.ObjectSchema = 10 | core.serialization.object({ 11 | objectsToAnnotate: core.serialization.property( 12 | "objects_to_annotate", 13 | core.serialization.list(core.serialization.unknown()).optional() 14 | ), 15 | minVertices: core.serialization.property("min_vertices", core.serialization.number().optional()), 16 | maxVertices: core.serialization.property("max_vertices", core.serialization.number().optional()), 17 | }); 18 | 19 | export declare namespace Polygon { 20 | interface Raw { 21 | objects_to_annotate?: unknown[] | null; 22 | min_vertices?: number | null; 23 | max_vertices?: number | null; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/serialization/resources/video/types/VideoPlaybackAnnotationRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const VideoPlaybackAnnotationRequest: core.serialization.ObjectSchema< 10 | serializers.VideoPlaybackAnnotationRequest.Raw, 11 | Scale.VideoPlaybackAnnotationRequest 12 | > = core.serialization.object({ 13 | project: core.serialization.string().optional(), 14 | batch: core.serialization.string().optional(), 15 | instruction: core.serialization.string().optional(), 16 | callbackUrl: core.serialization.property("callback_url", core.serialization.string().optional()), 17 | attachments: core.serialization.list(core.serialization.string()).optional(), 18 | attachment: core.serialization.string().optional(), 19 | attachmentType: core.serialization.property("attachment_type", core.serialization.string().optional()), 20 | geometries: core.serialization.lazyObject(async () => (await import("../../..")).Geometries), 21 | annotationAttributes: core.serialization.property( 22 | "annotation_attributes", 23 | core.serialization 24 | .record( 25 | core.serialization.string(), 26 | core.serialization.lazyObject(async () => (await import("../../..")).AnnotationAttribute).optional() 27 | ) 28 | .optional() 29 | ), 30 | eventsToAnnotate: core.serialization.property( 31 | "events_to_annotate", 32 | core.serialization.list(core.serialization.string()).optional() 33 | ), 34 | links: core.serialization 35 | .record( 36 | core.serialization.string(), 37 | core.serialization.lazyObject(async () => (await import("../../..")).Links).optional() 38 | ) 39 | .optional(), 40 | frameRate: core.serialization.property("frame_rate", core.serialization.number().optional()), 41 | padding: core.serialization.number().optional(), 42 | paddingX: core.serialization.number().optional(), 43 | paddingY: core.serialization.number().optional(), 44 | hypothesis: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), 45 | baseAnnotations: core.serialization.property( 46 | "base_annotations", 47 | core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional() 48 | ), 49 | canAddBaseAnnotations: core.serialization.property( 50 | "can_add_base_annotations", 51 | core.serialization.boolean().optional() 52 | ), 53 | canEditBaseAnnotations: core.serialization.property( 54 | "can_edit_base_annotations", 55 | core.serialization.boolean().optional() 56 | ), 57 | canEditBaseAnnotationLabels: core.serialization.property( 58 | "can_edit_base_annotation_labels", 59 | core.serialization.boolean().optional() 60 | ), 61 | canDeleteBaseAnnotations: core.serialization.property( 62 | "can_delete_base_annotations", 63 | core.serialization.boolean().optional() 64 | ), 65 | metadata: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), 66 | priority: core.serialization.number().optional(), 67 | uniqueId: core.serialization.property("unique_id", core.serialization.string().optional()), 68 | clearUniqueIdOnError: core.serialization.property( 69 | "clear_unique_id_on_error", 70 | core.serialization.boolean().optional() 71 | ), 72 | tags: core.serialization.list(core.serialization.string()).optional(), 73 | }); 74 | 75 | export declare namespace VideoPlaybackAnnotationRequest { 76 | interface Raw { 77 | project?: string | null; 78 | batch?: string | null; 79 | instruction?: string | null; 80 | callback_url?: string | null; 81 | attachments?: string[] | null; 82 | attachment?: string | null; 83 | attachment_type?: string | null; 84 | geometries: serializers.Geometries.Raw; 85 | annotation_attributes?: Record | null; 86 | events_to_annotate?: string[] | null; 87 | links?: Record | null; 88 | frame_rate?: number | null; 89 | padding?: number | null; 90 | paddingX?: number | null; 91 | paddingY?: number | null; 92 | hypothesis?: Record | null; 93 | base_annotations?: Record | null; 94 | can_add_base_annotations?: boolean | null; 95 | can_edit_base_annotations?: boolean | null; 96 | can_edit_base_annotation_labels?: boolean | null; 97 | can_delete_base_annotations?: boolean | null; 98 | metadata?: Record | null; 99 | priority?: number | null; 100 | unique_id?: string | null; 101 | clear_unique_id_on_error?: boolean | null; 102 | tags?: string[] | null; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/serialization/resources/video/types/VideoPlaybackAnnotationResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const VideoPlaybackAnnotationResponse: core.serialization.ObjectSchema< 10 | serializers.VideoPlaybackAnnotationResponse.Raw, 11 | Scale.VideoPlaybackAnnotationResponse 12 | > = core.serialization.object({ 13 | taskId: core.serialization.property("task_id", core.serialization.string().optional()), 14 | createdAt: core.serialization.property("created_at", core.serialization.string().optional()), 15 | type: core.serialization.string().optional(), 16 | status: core.serialization.string().optional(), 17 | instruction: core.serialization.string().optional(), 18 | isTest: core.serialization.property("is_test", core.serialization.boolean().optional()), 19 | urgency: core.serialization.string().optional(), 20 | metadata: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), 21 | project: core.serialization.string().optional(), 22 | callbackUrl: core.serialization.property("callback_url", core.serialization.string().optional()), 23 | updatedAt: core.serialization.property("updated_at", core.serialization.string().optional()), 24 | workStarted: core.serialization.property("work_started", core.serialization.boolean().optional()), 25 | params: core.serialization.lazyObject(async () => (await import("../../..")).VideoPlaybackParams).optional(), 26 | }); 27 | 28 | export declare namespace VideoPlaybackAnnotationResponse { 29 | interface Raw { 30 | task_id?: string | null; 31 | created_at?: string | null; 32 | type?: string | null; 33 | status?: string | null; 34 | instruction?: string | null; 35 | is_test?: boolean | null; 36 | urgency?: string | null; 37 | metadata?: Record | null; 38 | project?: string | null; 39 | callback_url?: string | null; 40 | updated_at?: string | null; 41 | work_started?: boolean | null; 42 | params?: serializers.VideoPlaybackParams.Raw | null; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/serialization/resources/video/types/VideoPlaybackGeometries.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const VideoPlaybackGeometries: core.serialization.ObjectSchema< 10 | serializers.VideoPlaybackGeometries.Raw, 11 | Scale.VideoPlaybackGeometries 12 | > = core.serialization.object({ 13 | box: core.serialization.lazyObject(async () => (await import("../../..")).ObjectsToAnnotate).optional(), 14 | }); 15 | 16 | export declare namespace VideoPlaybackGeometries { 17 | interface Raw { 18 | box?: serializers.ObjectsToAnnotate.Raw | null; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/serialization/resources/video/types/VideoPlaybackParams.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by Fern from our API Definition. 3 | */ 4 | 5 | import * as serializers from "../../.."; 6 | import { Scale } from "@fern-api/scale"; 7 | import * as core from "../../../../core"; 8 | 9 | export const VideoPlaybackParams: core.serialization.ObjectSchema< 10 | serializers.VideoPlaybackParams.Raw, 11 | Scale.VideoPlaybackParams 12 | > = core.serialization.object({ 13 | attachment: core.serialization.string().optional(), 14 | frameRate: core.serialization.property("frame_rate", core.serialization.number().optional()), 15 | withLabels: core.serialization.property("with_labels", core.serialization.boolean().optional()), 16 | eventsToAnnotate: core.serialization.property( 17 | "events_to_annotate", 18 | core.serialization.list(core.serialization.unknown()).optional() 19 | ), 20 | geometries: core.serialization 21 | .lazyObject(async () => (await import("../../..")).VideoPlaybackGeometries) 22 | .optional(), 23 | isTest: core.serialization.property("is_test", core.serialization.boolean().optional()), 24 | metadata: core.serialization.string().optional(), 25 | }); 26 | 27 | export declare namespace VideoPlaybackParams { 28 | interface Raw { 29 | attachment?: string | null; 30 | frame_rate?: number | null; 31 | with_labels?: boolean | null; 32 | events_to_annotate?: unknown[] | null; 33 | geometries?: serializers.VideoPlaybackGeometries.Raw | null; 34 | is_test?: boolean | null; 35 | metadata?: string | null; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/serialization/resources/video/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./VideoPlaybackAnnotationRequest"; 2 | export * from "./Box"; 3 | export * from "./Polygon"; 4 | export * from "./Line"; 5 | export * from "./Point"; 6 | export * from "./CameraIntrinsics"; 7 | export * from "./CameraRotationQuaternion"; 8 | export * from "./Cuboid"; 9 | export * from "./Ellipse"; 10 | export * from "./Geometries"; 11 | export * from "./AnnotationAttribute"; 12 | export * from "./Links"; 13 | export * from "./VideoPlaybackAnnotationResponse"; 14 | export * from "./ObjectsToAnnotate"; 15 | export * from "./VideoPlaybackGeometries"; 16 | export * from "./VideoPlaybackParams"; 17 | -------------------------------------------------------------------------------- /static/compile-error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scaleapi/scaleapi-node/542f7a72f2c3dfafaa81ae4273f2594565de2e4d/static/compile-error.png -------------------------------------------------------------------------------- /static/hero.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scaleapi/scaleapi-node/542f7a72f2c3dfafaa81ae4273f2594565de2e4d/static/hero.png -------------------------------------------------------------------------------- /static/method-autocomplete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scaleapi/scaleapi-node/542f7a72f2c3dfafaa81ae4273f2594565de2e4d/static/method-autocomplete.png -------------------------------------------------------------------------------- /static/property-autocomplete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scaleapi/scaleapi-node/542f7a72f2c3dfafaa81ae4273f2594565de2e4d/static/property-autocomplete.png -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "extendedDiagnostics": true, 4 | "strict": true, 5 | "target": "esnext", 6 | "module": "CommonJS", 7 | "moduleResolution": "node", 8 | "esModuleInterop": true, 9 | "skipLibCheck": true, 10 | "declaration": true, 11 | "noUnusedLocals": true, 12 | "noUnusedParameters": true, 13 | "outDir": "dist", 14 | "rootDir": "src", 15 | "baseUrl": "src", 16 | "paths": { 17 | "@fern-api/scale": [ 18 | "." 19 | ] 20 | } 21 | }, 22 | "include": [ 23 | "src" 24 | ], 25 | "exclude": [] 26 | } --------------------------------------------------------------------------------