@read-frog/api-contract 0.2.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/schemas/column.ts","../src/contracts/column.ts","../src/schemas/custom-table.ts","../src/contracts/custom-table.ts","../src/schemas/notebase-beta.ts","../src/contracts/notebase-beta.ts","../src/schemas/row.ts","../src/contracts/row.ts","../src/index.ts"],"sourcesContent":["import { COLUMN_MAX_WIDTH, COLUMN_MIN_WIDTH, columnConfigSchema } from '@read-frog/definitions'\nimport { z } from 'zod'\n\nexport const ColumnAddInputSchema = z.object({\n tableId: z.uuid(),\n data: z.object({\n id: z.uuid().optional(),\n name: z.string().min(1),\n config: columnConfigSchema,\n position: z.number().int().optional(),\n }).strict(),\n})\n\nexport const ColumnAddOutputSchema = z.object({\n txid: z.number(),\n})\n\nexport const ColumnUpdateInputSchema = z.object({\n columnId: z.uuid(),\n data: z.object({\n name: z.string().min(1).optional(),\n config: columnConfigSchema.optional(),\n width: z.number().int().min(COLUMN_MIN_WIDTH).max(COLUMN_MAX_WIDTH).nullable().optional(),\n }).strict(),\n})\n\nexport const ColumnUpdateOutputSchema = z.object({\n txid: z.number(),\n})\n\nexport const ColumnDeleteInputSchema = z.object({\n columnId: z.uuid(),\n})\n\nexport const ColumnDeleteOutputSchema = z.object({\n txid: z.number(),\n})\n","import { oc } from '@orpc/contract'\nimport {\n ColumnAddInputSchema,\n ColumnAddOutputSchema,\n ColumnDeleteInputSchema,\n ColumnDeleteOutputSchema,\n ColumnUpdateInputSchema,\n ColumnUpdateOutputSchema,\n} from '@/schemas/column'\n\nexport const columnContract = {\n add: oc\n .route({\n method: 'POST',\n path: '/columns',\n summary: 'Add column to table',\n tags: ['Columns'],\n })\n .input(ColumnAddInputSchema)\n .output(ColumnAddOutputSchema),\n\n update: oc\n .route({\n method: 'PATCH',\n path: '/columns/{columnId}',\n summary: 'Update column name',\n tags: ['Columns'],\n })\n .input(ColumnUpdateInputSchema)\n .output(ColumnUpdateOutputSchema),\n\n delete: oc\n .route({\n method: 'DELETE',\n path: '/columns/{columnId}',\n summary: 'Delete column',\n tags: ['Columns'],\n })\n .input(ColumnDeleteInputSchema)\n .output(ColumnDeleteOutputSchema),\n}\n","import { columnConfigSchema } from '@read-frog/definitions'\nimport { z } from 'zod'\n\nexport const CustomTableListInputSchema = z.object({})\nexport type CustomTableListInput = z.infer<typeof CustomTableListInputSchema>\n\nexport const CustomTableListItemSchema = z.object({\n id: z.string(),\n name: z.string(),\n})\nexport type CustomTableListItem = z.infer<typeof CustomTableListItemSchema>\n\nexport const CustomTableListOutputSchema = z.array(CustomTableListItemSchema)\nexport type CustomTableListOutput = z.infer<typeof CustomTableListOutputSchema>\n\nexport const CustomTableCreateInputSchema = z.object({\n id: z.uuid().optional(),\n name: z.string().min(1),\n})\nexport type CustomTableCreateInput = z.infer<typeof CustomTableCreateInputSchema>\n\nexport const CustomTableCreateOutputSchema = z.object({\n txid: z.number(),\n})\nexport type CustomTableCreateOutput = z.infer<typeof CustomTableCreateOutputSchema>\n\nexport const CustomTableUpdateInputSchema = z.object({\n id: z.uuid(),\n name: z.string().min(1).optional(),\n})\nexport type CustomTableUpdateInput = z.infer<typeof CustomTableUpdateInputSchema>\n\nexport const CustomTableUpdateOutputSchema = z.object({\n txid: z.number(),\n})\nexport type CustomTableUpdateOutput = z.infer<typeof CustomTableUpdateOutputSchema>\n\nexport const CustomTableDeleteInputSchema = z.object({\n id: z.uuid(),\n})\nexport type CustomTableDeleteInput = z.infer<typeof CustomTableDeleteInputSchema>\n\nexport const CustomTableDeleteOutputSchema = z.object({\n txid: z.number(),\n})\nexport type CustomTableDeleteOutput = z.infer<typeof CustomTableDeleteOutputSchema>\n\n// Get endpoint schemas\nexport const CustomTableGetInputSchema = z.object({\n id: z.uuid(),\n})\nexport type CustomTableGetInput = z.infer<typeof CustomTableGetInputSchema>\n\nexport const CustomTableGetSchemaInputSchema = z.object({\n id: z.uuid(),\n})\nexport type CustomTableGetSchemaInput = z.infer<typeof CustomTableGetSchemaInputSchema>\n\nexport const TableColumnSchema = z.object({\n id: z.string(),\n tableId: z.string(),\n name: z.string(),\n config: columnConfigSchema,\n position: z.number(),\n isPrimary: z.boolean(),\n width: z.number().nullable(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n})\nexport type TableColumn = z.infer<typeof TableColumnSchema>\n\nexport const TableRowSchema = z.object({\n id: z.string(),\n tableId: z.string(),\n cells: z.record(z.string(), z.unknown()),\n position: z.number().nullable(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n})\nexport type TableRow = z.infer<typeof TableRowSchema>\n\nexport const TableViewSchema = z.object({\n id: z.string(),\n tableId: z.string(),\n name: z.string(),\n type: z.enum(['table', 'kanban', 'gallery']),\n config: z.record(z.string(), z.unknown()).nullable(),\n filters: z.array(z.unknown()).nullable(),\n sorts: z.array(z.unknown()).nullable(),\n position: z.number(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n})\nexport type TableView = z.infer<typeof TableViewSchema>\n\nexport const CustomTableGetOutputSchema = z.object({\n id: z.string(),\n userId: z.string(),\n name: z.string(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n columns: z.array(TableColumnSchema),\n rows: z.array(TableRowSchema),\n views: z.array(TableViewSchema),\n})\nexport type CustomTableGetOutput = z.infer<typeof CustomTableGetOutputSchema>\n\nexport const CustomTableGetSchemaOutputSchema = z.object({\n id: z.string(),\n name: z.string(),\n updatedAt: z.coerce.date(),\n columns: z.array(TableColumnSchema),\n})\nexport type CustomTableGetSchemaOutput = z.infer<typeof CustomTableGetSchemaOutputSchema>\n","import { oc } from '@orpc/contract'\nimport {\n CustomTableCreateInputSchema,\n CustomTableCreateOutputSchema,\n CustomTableDeleteInputSchema,\n CustomTableDeleteOutputSchema,\n CustomTableGetInputSchema,\n CustomTableGetOutputSchema,\n CustomTableGetSchemaInputSchema,\n CustomTableGetSchemaOutputSchema,\n CustomTableListInputSchema,\n CustomTableListOutputSchema,\n CustomTableUpdateInputSchema,\n CustomTableUpdateOutputSchema,\n} from '@/schemas/custom-table'\n\nexport const customTableContract = {\n list: oc\n .route({\n method: 'GET',\n path: '/custom-tables',\n summary: 'List custom tables',\n tags: ['Custom Tables'],\n })\n .input(CustomTableListInputSchema)\n .output(CustomTableListOutputSchema),\n\n get: oc\n .route({\n method: 'GET',\n path: '/custom-tables/{id}',\n summary: 'Get custom table with columns, rows, and views',\n tags: ['Custom Tables'],\n })\n .input(CustomTableGetInputSchema)\n .output(CustomTableGetOutputSchema),\n\n getSchema: oc\n .route({\n method: 'GET',\n path: '/custom-tables/{id}/schema',\n summary: 'Get custom table schema',\n tags: ['Custom Tables'],\n })\n .input(CustomTableGetSchemaInputSchema)\n .output(CustomTableGetSchemaOutputSchema),\n\n create: oc\n .route({\n method: 'POST',\n path: '/custom-tables',\n summary: 'Create custom table',\n tags: ['Custom Tables'],\n })\n .input(CustomTableCreateInputSchema)\n .output(CustomTableCreateOutputSchema),\n\n update: oc\n .route({\n method: 'PUT',\n path: '/custom-tables/{id}',\n summary: 'Update custom table',\n tags: ['Custom Tables'],\n })\n .input(CustomTableUpdateInputSchema)\n .output(CustomTableUpdateOutputSchema),\n\n delete: oc\n .route({\n method: 'DELETE',\n path: '/custom-tables/{id}',\n summary: 'Delete custom table',\n tags: ['Custom Tables'],\n })\n .input(CustomTableDeleteInputSchema)\n .output(CustomTableDeleteOutputSchema),\n}\n","import { z } from 'zod'\n\nexport const NotebaseBetaStatusInputSchema = z.object({}).strict()\nexport type NotebaseBetaStatusInput = z.infer<typeof NotebaseBetaStatusInputSchema>\n\nexport const NotebaseBetaStatusOutputSchema = z.object({\n allowed: z.boolean(),\n})\nexport type NotebaseBetaStatusOutput = z.infer<typeof NotebaseBetaStatusOutputSchema>\n","import { oc } from '@orpc/contract'\nimport {\n NotebaseBetaStatusInputSchema,\n NotebaseBetaStatusOutputSchema,\n} from '@/schemas/notebase-beta'\n\nexport const notebaseBetaContract = {\n status: oc\n .route({\n method: 'GET',\n path: '/notebase-beta/status',\n summary: 'Get Notebase beta access status',\n tags: ['Notebase Beta'],\n })\n .input(NotebaseBetaStatusInputSchema)\n .output(NotebaseBetaStatusOutputSchema),\n}\n","import { z } from 'zod'\n\nexport const RowAddInputSchema = z.object({\n tableId: z.uuid(),\n data: z.object({\n id: z.uuid().optional(),\n cells: z.record(z.string(), z.unknown()),\n position: z.number().int().optional(),\n }).strict(),\n})\nexport type RowAddInput = z.infer<typeof RowAddInputSchema>\n\nexport const RowAddOutputSchema = z.object({\n txid: z.number(),\n})\nexport type RowAddOutput = z.infer<typeof RowAddOutputSchema>\n\nexport const RowUpdateInputSchema = z.object({\n rowId: z.uuid(),\n data: z.object({\n cells: z.record(z.string(), z.unknown()).optional(),\n position: z.number().int().optional(),\n }).strict(),\n})\nexport type RowUpdateInput = z.infer<typeof RowUpdateInputSchema>\n\nexport const RowUpdateOutputSchema = z.object({\n id: z.uuid(),\n tableId: z.uuid(),\n cells: z.record(z.string(), z.unknown()),\n position: z.number().int().nullable(),\n createdAt: z.date(),\n updatedAt: z.date(),\n txid: z.number(),\n})\nexport type RowUpdateOutput = z.infer<typeof RowUpdateOutputSchema>\n\nexport const RowDeleteInputSchema = z.object({\n rowId: z.uuid(),\n})\nexport type RowDeleteInput = z.infer<typeof RowDeleteInputSchema>\n\nexport const RowDeleteOutputSchema = z.object({\n txid: z.number(),\n})\nexport type RowDeleteOutput = z.infer<typeof RowDeleteOutputSchema>\n","import { oc } from '@orpc/contract'\nimport {\n RowAddInputSchema,\n RowAddOutputSchema,\n RowDeleteInputSchema,\n RowDeleteOutputSchema,\n RowUpdateInputSchema,\n RowUpdateOutputSchema,\n} from '@/schemas/row'\n\nexport const rowContract = {\n add: oc\n .route({\n method: 'POST',\n path: '/rows',\n summary: 'Add row to table',\n tags: ['Rows'],\n })\n .input(RowAddInputSchema)\n .output(RowAddOutputSchema),\n\n update: oc\n .route({\n method: 'PATCH',\n path: '/rows/{rowId}',\n summary: 'Update row cells',\n tags: ['Rows'],\n })\n .input(RowUpdateInputSchema)\n .output(RowUpdateOutputSchema),\n\n delete: oc\n .route({\n method: 'DELETE',\n path: '/rows/{rowId}',\n summary: 'Delete row',\n tags: ['Rows'],\n })\n .input(RowDeleteInputSchema)\n .output(RowDeleteOutputSchema),\n}\n","import type { ContractRouterClient } from '@orpc/contract'\nimport { columnContract } from './contracts/column'\nimport { customTableContract } from './contracts/custom-table'\nimport { notebaseBetaContract } from './contracts/notebase-beta'\nimport { rowContract } from './contracts/row'\n\nexport const contract = {\n customTable: customTableContract,\n column: columnContract,\n row: rowContract,\n notebaseBeta: notebaseBetaContract,\n}\n\nexport type ORPCRouterClient = ContractRouterClient<typeof contract>\n\n// Re-export schemas for convenience\nexport * from './schemas/column'\nexport * from './schemas/custom-table'\nexport * from './schemas/notebase-beta'\nexport * from './schemas/row'\n"],"mappings":";;;;;AAGA,MAAa,uBAAuB,EAAE,OAAO;CAC3C,SAAS,EAAE,MAAM;CACjB,MAAM,EAAE,OAAO;EACb,IAAI,EAAE,MAAM,CAAC,UAAU;EACvB,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE;EACvB,QAAQ;EACR,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;EACtC,CAAC,CAAC,QAAQ;CACZ,CAAC;AAEF,MAAa,wBAAwB,EAAE,OAAO,EAC5C,MAAM,EAAE,QAAQ,EACjB,CAAC;AAEF,MAAa,0BAA0B,EAAE,OAAO;CAC9C,UAAU,EAAE,MAAM;CAClB,MAAM,EAAE,OAAO;EACb,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,UAAU;EAClC,QAAQ,mBAAmB,UAAU;EACrC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,iBAAiB,CAAC,IAAI,iBAAiB,CAAC,UAAU,CAAC,UAAU;EAC1F,CA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C;AAGF,MAAa,uBAAuB,EAAE,OAAO,EAC3C,OAAO,EAAE,MAAM,EAChB,CAAC;AAGF,MAAa,wBAAwB,EAAE,OAAO,EAC5C,MAAM,EAAE,QAAQ,EACjB,CAAC;;;;AClCF,MAAa,cAAc;CACzB,KAAK,GACF,MAAM;EACL,QAAQ;EACR,MAAM;EACN,SAAS;EACT,MAAM,CAAC,OAAO;EACf,CAAC,CACD,MAAM,kBAAkB,CACxB,OAAO,mBAAmB;CAE7B,QAAQ,GACL,MAAM;EACL,QAAQ;EACR,MAAM;EACN,SAAS;EACT,MAAM,CAAC,OAAO;EACf,CAAC,CACD,MAAM,qBAAqB,CAC3B,OAAO,sBAAsB;CAEhC,QAAQ,GACL,MAAM;EACL,QAAQ;EACR,MAAM;EACN,SAAS;EACT,MAAM,CAAC,OAAO;EACf,CAAC,CACD,MAAM,qBAAqB,CAC3B,OAAO,sBAAsB;CACjC;;;;AClCD,MAAa,WAAW;CACtB,aAAa;CACb,QAAQ;CACR,KAAK;CACL,cAAc;CACf"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/schemas/beta-access.ts","../src/contracts/beta-access.ts","../src/public-errors.ts","../src/schemas/column.ts","../src/contracts/shared.ts","../src/contracts/column.ts","../src/schemas/row.ts","../src/schemas/view.ts","../src/schemas/custom-table.ts","../src/contracts/custom-table.ts","../src/contracts/row.ts","../src/index.ts"],"sourcesContent":["import { BETA_FEATURE_KEYS } from \"@read-frog/definitions\"\nimport { z } from \"zod\"\n\nexport const BetaFeatureKeySchema = z.enum(BETA_FEATURE_KEYS)\nexport type BetaFeatureKey = z.infer<typeof BetaFeatureKeySchema>\n\nexport const BetaAccessStatusInputSchema = z.object({\n featureKey: BetaFeatureKeySchema,\n}).strict()\nexport type BetaAccessStatusInput = z.infer<typeof BetaAccessStatusInputSchema>\n\nexport const BetaAccessStatusOutputSchema = z.object({\n featureKey: BetaFeatureKeySchema,\n allowed: z.boolean(),\n})\nexport type BetaAccessStatusOutput = z.infer<typeof BetaAccessStatusOutputSchema>\n","import { oc } from \"@orpc/contract\"\nimport {\n BetaAccessStatusInputSchema,\n BetaAccessStatusOutputSchema,\n} from \"@/schemas/beta-access\"\n\nexport const betaAccessContract = {\n status: oc\n .route({\n method: \"GET\",\n path: \"/beta-access/status\",\n summary: \"Get beta access status for a feature\",\n tags: [\"Beta Access\"],\n })\n .input(BetaAccessStatusInputSchema)\n .output(BetaAccessStatusOutputSchema),\n}\n","import type { ErrorMap } from \"@orpc/contract\"\nimport { z } from \"zod\"\n\ninterface PublicAppErrorDefinition {\n data?: z.ZodTypeAny\n message: string\n status: number\n}\n\nexport const CellValidationFailureReasonSchema = z.enum([\n \"unknown_column\",\n \"type_mismatch\",\n \"invalid_select_option\",\n \"invalid_date_format\",\n])\nexport type CellValidationFailureReason = z.infer<typeof CellValidationFailureReasonSchema>\n\nexport const CellValidationFailureDetailsSchema = z.object({\n expectedFormat: z.string().optional(),\n expectedType: z.string().optional(),\n receivedType: z.string().optional(),\n receivedValue: z.unknown().optional(),\n validOptions: z.array(z.string()).optional(),\n}).strict()\nexport type CellValidationFailureDetails = z.infer<typeof CellValidationFailureDetailsSchema>\n\nexport const CellValidationFailedDataSchema = z.object({\n columnId: z.string(),\n details: CellValidationFailureDetailsSchema,\n reason: CellValidationFailureReasonSchema,\n}).strict()\nexport type CellValidationFailedData = z.infer<typeof CellValidationFailedDataSchema>\n\nexport const PUBLIC_APP_ERROR_DEFS = {\n NOTEBASE_BETA_RESTRICTED: {\n message: \"Notebase is currently in beta for selected accounts\",\n status: 403,\n },\n TABLE_NOT_FOUND: {\n message: \"Table not found\",\n status: 404,\n },\n COLUMN_NOT_FOUND: {\n message: \"Column not found\",\n status: 404,\n },\n ROW_NOT_FOUND: {\n message: \"Row not found\",\n status: 404,\n },\n VIEW_NOT_FOUND: {\n message: \"View not found\",\n status: 404,\n },\n CELL_VALIDATION_FAILED: {\n data: CellValidationFailedDataSchema,\n message: \"Cell validation failed\",\n status: 422,\n },\n PRIMARY_COLUMN_DELETE_NOT_ALLOWED: {\n message: \"Cannot delete primary column\",\n status: 400,\n },\n CONCURRENT_POSITION_CONFLICT: {\n message: \"Concurrent position conflict, please retry\",\n status: 409,\n },\n} as const satisfies Record<string, PublicAppErrorDefinition>\n\nexport type PublicAppErrorCode = keyof typeof PUBLIC_APP_ERROR_DEFS\n\nexport type PublicAppErrorData<TCode extends PublicAppErrorCode>\n = (typeof PUBLIC_APP_ERROR_DEFS)[TCode] extends { data: infer TSchema extends z.ZodTypeAny }\n ? z.output<TSchema>\n : undefined\n\nexport function isPublicAppErrorCode(code: string | undefined): code is PublicAppErrorCode {\n return code !== undefined && code in PUBLIC_APP_ERROR_DEFS\n}\n\nexport function getPublicErrorDefinition<TCode extends PublicAppErrorCode>(code: TCode) {\n return PUBLIC_APP_ERROR_DEFS[code]\n}\n\nexport function pickPublicErrorMap<const TCodes extends readonly PublicAppErrorCode[]>(\n ...codes: TCodes\n) {\n return Object.fromEntries(codes.map((code) => {\n const definition = PUBLIC_APP_ERROR_DEFS[code]\n\n if (\"data\" in definition) {\n return [code, {\n data: definition.data,\n message: definition.message,\n status: definition.status,\n }]\n }\n\n return [code, {\n message: definition.message,\n status: definition.status,\n }]\n })) as Pick<ErrorMap, TCodes[number]>\n}\n","import { COLUMN_MAX_WIDTH, COLUMN_MIN_WIDTH, columnConfigSchema } from \"@read-frog/definitions\"\nimport { z } from \"zod\"\n\nexport const columnWidthSchema = z.number().int().min(COLUMN_MIN_WIDTH).max(COLUMN_MAX_WIDTH)\n\nexport const tableColumnSchema = z.object({\n id: z.string(),\n tableId: z.string(),\n name: z.string(),\n config: columnConfigSchema,\n position: z.number(),\n isPrimary: z.boolean(),\n width: z.number().nullable(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n})\nexport type TableColumn = z.infer<typeof tableColumnSchema>\n\nexport const columnCreateDataSchema = z.object({\n id: z.uuid().optional(),\n name: z.string().min(1),\n config: columnConfigSchema,\n}).strict()\nexport type ColumnCreateData = z.infer<typeof columnCreateDataSchema>\n\nexport const columnUpdateDataSchema = z.object({\n name: z.string().min(1).optional(),\n config: columnConfigSchema.optional(),\n width: columnWidthSchema.nullable().optional(),\n}).strict()\nexport type ColumnUpdateData = z.infer<typeof columnUpdateDataSchema>\n\nexport const ColumnCreateInputSchema = z.object({\n tableId: z.uuid(),\n data: columnCreateDataSchema,\n})\nexport type ColumnCreateInput = z.infer<typeof ColumnCreateInputSchema>\n\nexport const ColumnCreateOutputSchema = z.object({\n txid: z.number(),\n})\nexport type ColumnCreateOutput = z.infer<typeof ColumnCreateOutputSchema>\n\nexport const ColumnUpdateInputSchema = z.object({\n columnId: z.uuid(),\n data: columnUpdateDataSchema,\n})\nexport type ColumnUpdateInput = z.infer<typeof ColumnUpdateInputSchema>\n\nexport const ColumnUpdateOutputSchema = z.object({\n txid: z.number(),\n})\nexport type ColumnUpdateOutput = z.infer<typeof ColumnUpdateOutputSchema>\n\nexport const ColumnDeleteInputSchema = z.object({\n columnId: z.uuid(),\n})\nexport type ColumnDeleteInput = z.infer<typeof ColumnDeleteInputSchema>\n\nexport const ColumnDeleteOutputSchema = z.object({\n txid: z.number(),\n})\nexport type ColumnDeleteOutput = z.infer<typeof ColumnDeleteOutputSchema>\n\nexport const ColumnReorderInputSchema = z.object({\n tableId: z.uuid(),\n ids: z.array(z.uuid()),\n})\nexport type ColumnReorderInput = z.infer<typeof ColumnReorderInputSchema>\n\nexport const ColumnReorderOutputSchema = z.object({\n txid: z.number(),\n})\nexport type ColumnReorderOutput = z.infer<typeof ColumnReorderOutputSchema>\n","import { oc } from \"@orpc/contract\"\nimport { pickPublicErrorMap } from \"@/public-errors\"\n\nexport const notebaseProcedure = oc.errors(\n pickPublicErrorMap(\"NOTEBASE_BETA_RESTRICTED\"),\n)\n","import { pickPublicErrorMap } from \"@/public-errors\"\nimport {\n ColumnCreateInputSchema,\n ColumnCreateOutputSchema,\n ColumnDeleteInputSchema,\n ColumnDeleteOutputSchema,\n ColumnReorderInputSchema,\n ColumnReorderOutputSchema,\n ColumnUpdateInputSchema,\n ColumnUpdateOutputSchema,\n} from \"@/schemas/column\"\nimport { notebaseProcedure } from \"./shared\"\n\nexport const columnContract = {\n create: notebaseProcedure\n .errors(pickPublicErrorMap(\"TABLE_NOT_FOUND\", \"CONCURRENT_POSITION_CONFLICT\"))\n .route({\n method: \"POST\",\n path: \"/columns\",\n summary: \"Create column\",\n tags: [\"Columns\"],\n })\n .input(ColumnCreateInputSchema)\n .output(ColumnCreateOutputSchema),\n\n update: notebaseProcedure\n .errors(pickPublicErrorMap(\"COLUMN_NOT_FOUND\"))\n .route({\n method: \"PATCH\",\n path: \"/columns/{columnId}\",\n summary: \"Update column\",\n tags: [\"Columns\"],\n })\n .input(ColumnUpdateInputSchema)\n .output(ColumnUpdateOutputSchema),\n\n delete: notebaseProcedure\n .errors(pickPublicErrorMap(\n \"COLUMN_NOT_FOUND\",\n \"PRIMARY_COLUMN_DELETE_NOT_ALLOWED\",\n \"CONCURRENT_POSITION_CONFLICT\",\n ))\n .route({\n method: \"DELETE\",\n path: \"/columns/{columnId}\",\n summary: \"Delete column\",\n tags: [\"Columns\"],\n })\n .input(ColumnDeleteInputSchema)\n .output(ColumnDeleteOutputSchema),\n\n reorder: notebaseProcedure\n .errors(pickPublicErrorMap(\"TABLE_NOT_FOUND\", \"CONCURRENT_POSITION_CONFLICT\"))\n .route({\n method: \"POST\",\n path: \"/columns/reorder\",\n summary: \"Reorder columns in a table\",\n tags: [\"Columns\"],\n })\n .input(ColumnReorderInputSchema)\n .output(ColumnReorderOutputSchema),\n}\n","import { z } from \"zod\"\n\nexport const rowCellsSchema = z.record(z.string(), z.unknown())\n\nexport const tableRowSchema = z.object({\n id: z.string(),\n tableId: z.string(),\n cells: rowCellsSchema,\n position: z.number(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n})\nexport type TableRow = z.infer<typeof tableRowSchema>\n\nexport const rowCreateDataSchema = z.object({\n id: z.uuid().optional(),\n cells: rowCellsSchema.optional(),\n}).strict()\nexport type RowCreateData = z.infer<typeof rowCreateDataSchema>\n\nexport const rowUpdateDataSchema = z.object({\n cells: rowCellsSchema.optional(),\n}).strict()\nexport type RowUpdateData = z.infer<typeof rowUpdateDataSchema>\n\nexport const RowCreateInputSchema = z.object({\n tableId: z.uuid(),\n data: rowCreateDataSchema,\n})\nexport type RowCreateInput = z.infer<typeof RowCreateInputSchema>\n\nexport const RowCreateOutputSchema = z.object({\n txid: z.number(),\n})\nexport type RowCreateOutput = z.infer<typeof RowCreateOutputSchema>\n\nexport const RowUpdateInputSchema = z.object({\n rowId: z.uuid(),\n data: rowUpdateDataSchema,\n})\nexport type RowUpdateInput = z.infer<typeof RowUpdateInputSchema>\n\nexport const RowUpdateOutputSchema = z.object({\n id: z.uuid(),\n tableId: z.uuid(),\n cells: rowCellsSchema,\n position: z.number().int(),\n createdAt: z.date(),\n updatedAt: z.date(),\n txid: z.number(),\n})\nexport type RowUpdateOutput = z.infer<typeof RowUpdateOutputSchema>\n\nexport const RowDeleteInputSchema = z.object({\n rowId: z.uuid(),\n})\nexport type RowDeleteInput = z.infer<typeof RowDeleteInputSchema>\n\nexport const RowDeleteOutputSchema = z.object({\n txid: z.number(),\n})\nexport type RowDeleteOutput = z.infer<typeof RowDeleteOutputSchema>\n\nexport const RowReorderInputSchema = z.object({\n tableId: z.uuid(),\n ids: z.array(z.uuid()),\n})\nexport type RowReorderInput = z.infer<typeof RowReorderInputSchema>\n\nexport const RowReorderOutputSchema = z.object({\n txid: z.number(),\n})\nexport type RowReorderOutput = z.infer<typeof RowReorderOutputSchema>\n","import { z } from \"zod\"\n\nexport const tableViewTypeSchema = z.enum([\"table\", \"kanban\", \"gallery\"])\nexport type TableViewType = z.infer<typeof tableViewTypeSchema>\n\nexport const viewConfigSchema = z.object({\n columnWidths: z.record(z.string(), z.number()).optional(),\n hiddenColumns: z.array(z.string()).optional(),\n groupByColumnId: z.string().optional(),\n}).catchall(z.unknown())\nexport type ViewConfig = z.infer<typeof viewConfigSchema>\n\nexport const viewFilterSchema = z.object({\n columnId: z.string(),\n operator: z.string(),\n value: z.unknown(),\n}).strict()\nexport type ViewFilter = z.infer<typeof viewFilterSchema>\n\nexport const viewFiltersSchema = z.array(viewFilterSchema)\n\nexport const viewSortSchema = z.object({\n columnId: z.string(),\n direction: z.enum([\"asc\", \"desc\"]),\n}).strict()\nexport type ViewSort = z.infer<typeof viewSortSchema>\n\nexport const viewSortsSchema = z.array(viewSortSchema)\n\nexport const viewCreateDataSchema = z.object({\n id: z.uuid().optional(),\n name: z.string().min(1),\n type: tableViewTypeSchema,\n config: viewConfigSchema.optional(),\n filters: viewFiltersSchema.optional(),\n sorts: viewSortsSchema.optional(),\n}).strict()\nexport type ViewCreateData = z.infer<typeof viewCreateDataSchema>\n\nexport const viewUpdateDataSchema = z.object({\n name: z.string().min(1).optional(),\n type: tableViewTypeSchema.optional(),\n config: viewConfigSchema.optional(),\n filters: viewFiltersSchema.optional(),\n sorts: viewSortsSchema.optional(),\n}).strict()\nexport type ViewUpdateData = z.infer<typeof viewUpdateDataSchema>\n\nexport const tableViewSchema = z.object({\n id: z.string(),\n tableId: z.string(),\n name: z.string(),\n type: tableViewTypeSchema,\n config: viewConfigSchema.nullable(),\n filters: z.array(z.unknown()).nullable(),\n sorts: z.array(z.unknown()).nullable(),\n position: z.number(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n})\nexport type TableView = z.infer<typeof tableViewSchema>\n","import { z } from \"zod\"\nimport { tableColumnSchema } from \"./column\"\nimport { tableRowSchema } from \"./row\"\nimport { tableViewSchema } from \"./view\"\n\nexport const CustomTableListInputSchema = z.object({})\nexport type CustomTableListInput = z.infer<typeof CustomTableListInputSchema>\n\nexport const CustomTableListItemSchema = z.object({\n id: z.string(),\n name: z.string(),\n})\nexport type CustomTableListItem = z.infer<typeof CustomTableListItemSchema>\n\nexport const CustomTableListOutputSchema = z.array(CustomTableListItemSchema)\nexport type CustomTableListOutput = z.infer<typeof CustomTableListOutputSchema>\n\nexport const customTableCreateDataSchema = z.object({\n id: z.uuid().optional(),\n name: z.string().min(1),\n}).strict()\nexport type CustomTableCreateData = z.infer<typeof customTableCreateDataSchema>\n\nexport const CustomTableCreateInputSchema = customTableCreateDataSchema\nexport type CustomTableCreateInput = z.infer<typeof CustomTableCreateInputSchema>\n\nexport const CustomTableCreateOutputSchema = z.object({\n txid: z.number(),\n})\nexport type CustomTableCreateOutput = z.infer<typeof CustomTableCreateOutputSchema>\n\nexport const customTableUpdateDataSchema = z.object({\n name: z.string().min(1).optional(),\n}).strict()\nexport type CustomTableUpdateData = z.infer<typeof customTableUpdateDataSchema>\n\nexport const CustomTableUpdateInputSchema = customTableUpdateDataSchema.extend({\n id: z.uuid(),\n})\nexport type CustomTableUpdateInput = z.infer<typeof CustomTableUpdateInputSchema>\n\nexport const CustomTableUpdateOutputSchema = z.object({\n txid: z.number(),\n})\nexport type CustomTableUpdateOutput = z.infer<typeof CustomTableUpdateOutputSchema>\n\nexport const CustomTableDeleteInputSchema = z.object({\n id: z.uuid(),\n})\nexport type CustomTableDeleteInput = z.infer<typeof CustomTableDeleteInputSchema>\n\nexport const CustomTableDeleteOutputSchema = z.object({\n txid: z.number(),\n})\nexport type CustomTableDeleteOutput = z.infer<typeof CustomTableDeleteOutputSchema>\n\n// Get endpoint schemas\nexport const CustomTableGetInputSchema = z.object({\n id: z.uuid(),\n})\nexport type CustomTableGetInput = z.infer<typeof CustomTableGetInputSchema>\n\nexport const CustomTableGetSchemaInputSchema = z.object({\n id: z.uuid(),\n})\nexport type CustomTableGetSchemaInput = z.infer<typeof CustomTableGetSchemaInputSchema>\n\nexport const CustomTableGetOutputSchema = z.object({\n id: z.string(),\n userId: z.string(),\n name: z.string(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n columns: z.array(tableColumnSchema),\n rows: z.array(tableRowSchema),\n views: z.array(tableViewSchema),\n})\nexport type CustomTableGetOutput = z.infer<typeof CustomTableGetOutputSchema>\n\nexport const CustomTableGetSchemaOutputSchema = z.object({\n id: z.string(),\n name: z.string(),\n updatedAt: z.coerce.date(),\n columns: z.array(tableColumnSchema),\n})\nexport type CustomTableGetSchemaOutput = z.infer<typeof CustomTableGetSchemaOutputSchema>\n","import { pickPublicErrorMap } from \"@/public-errors\"\nimport {\n CustomTableCreateInputSchema,\n CustomTableCreateOutputSchema,\n CustomTableDeleteInputSchema,\n CustomTableDeleteOutputSchema,\n CustomTableGetInputSchema,\n CustomTableGetOutputSchema,\n CustomTableGetSchemaInputSchema,\n CustomTableGetSchemaOutputSchema,\n CustomTableListInputSchema,\n CustomTableListOutputSchema,\n CustomTableUpdateInputSchema,\n CustomTableUpdateOutputSchema,\n} from \"@/schemas/custom-table\"\nimport { notebaseProcedure } from \"./shared\"\n\nexport const customTableContract = {\n list: notebaseProcedure\n .route({\n method: \"GET\",\n path: \"/custom-tables\",\n summary: \"List custom tables\",\n tags: [\"Custom Tables\"],\n })\n .input(CustomTableListInputSchema)\n .output(CustomTableListOutputSchema),\n\n get: notebaseProcedure\n .errors(pickPublicErrorMap(\"TABLE_NOT_FOUND\"))\n .route({\n method: \"GET\",\n path: \"/custom-tables/{id}\",\n summary: \"Get custom table with columns, rows, and views\",\n tags: [\"Custom Tables\"],\n })\n .input(CustomTableGetInputSchema)\n .output(CustomTableGetOutputSchema),\n\n getSchema: notebaseProcedure\n .errors(pickPublicErrorMap(\"TABLE_NOT_FOUND\"))\n .route({\n method: \"GET\",\n path: \"/custom-tables/{id}/schema\",\n summary: \"Get custom table schema\",\n tags: [\"Custom Tables\"],\n })\n .input(CustomTableGetSchemaInputSchema)\n .output(CustomTableGetSchemaOutputSchema),\n\n create: notebaseProcedure\n .route({\n method: \"POST\",\n path: \"/custom-tables\",\n summary: \"Create custom table\",\n tags: [\"Custom Tables\"],\n })\n .input(CustomTableCreateInputSchema)\n .output(CustomTableCreateOutputSchema),\n\n update: notebaseProcedure\n .errors(pickPublicErrorMap(\"TABLE_NOT_FOUND\"))\n .route({\n method: \"PUT\",\n path: \"/custom-tables/{id}\",\n summary: \"Update custom table\",\n tags: [\"Custom Tables\"],\n })\n .input(CustomTableUpdateInputSchema)\n .output(CustomTableUpdateOutputSchema),\n\n delete: notebaseProcedure\n .errors(pickPublicErrorMap(\"TABLE_NOT_FOUND\"))\n .route({\n method: \"DELETE\",\n path: \"/custom-tables/{id}\",\n summary: \"Delete custom table\",\n tags: [\"Custom Tables\"],\n })\n .input(CustomTableDeleteInputSchema)\n .output(CustomTableDeleteOutputSchema),\n}\n","import { pickPublicErrorMap } from \"@/public-errors\"\nimport {\n RowCreateInputSchema,\n RowCreateOutputSchema,\n RowDeleteInputSchema,\n RowDeleteOutputSchema,\n RowReorderInputSchema,\n RowReorderOutputSchema,\n RowUpdateInputSchema,\n RowUpdateOutputSchema,\n} from \"@/schemas/row\"\nimport { notebaseProcedure } from \"./shared\"\n\nexport const rowContract = {\n create: notebaseProcedure\n .errors(pickPublicErrorMap(\n \"TABLE_NOT_FOUND\",\n \"CELL_VALIDATION_FAILED\",\n \"CONCURRENT_POSITION_CONFLICT\",\n ))\n .route({\n method: \"POST\",\n path: \"/rows\",\n summary: \"Create row\",\n tags: [\"Rows\"],\n })\n .input(RowCreateInputSchema)\n .output(RowCreateOutputSchema),\n\n update: notebaseProcedure\n .errors(pickPublicErrorMap(\"ROW_NOT_FOUND\", \"CELL_VALIDATION_FAILED\"))\n .route({\n method: \"PATCH\",\n path: \"/rows/{rowId}\",\n summary: \"Update row cells\",\n tags: [\"Rows\"],\n })\n .input(RowUpdateInputSchema)\n .output(RowUpdateOutputSchema),\n\n delete: notebaseProcedure\n .errors(pickPublicErrorMap(\"ROW_NOT_FOUND\", \"CONCURRENT_POSITION_CONFLICT\"))\n .route({\n method: \"DELETE\",\n path: \"/rows/{rowId}\",\n summary: \"Delete row\",\n tags: [\"Rows\"],\n })\n .input(RowDeleteInputSchema)\n .output(RowDeleteOutputSchema),\n\n reorder: notebaseProcedure\n .errors(pickPublicErrorMap(\"TABLE_NOT_FOUND\", \"CONCURRENT_POSITION_CONFLICT\"))\n .route({\n method: \"POST\",\n path: \"/rows/reorder\",\n summary: \"Reorder rows in a table\",\n tags: [\"Rows\"],\n })\n .input(RowReorderInputSchema)\n .output(RowReorderOutputSchema),\n}\n","import type { ContractRouterClient } from \"@orpc/contract\"\nimport { betaAccessContract } from \"./contracts/beta-access\"\nimport { columnContract } from \"./contracts/column\"\nimport { customTableContract } from \"./contracts/custom-table\"\nimport { rowContract } from \"./contracts/row\"\n\nexport const contract = {\n betaAccess: betaAccessContract,\n customTable: customTableContract,\n column: columnContract,\n row: rowContract,\n}\n\nexport type ORPCRouterClient = ContractRouterClient<typeof contract>\n\nexport * from \"./public-errors\"\nexport * from \"./schemas/beta-access\"\nexport * from \"./schemas/column\"\nexport * from \"./schemas/custom-table\"\nexport * from \"./schemas/row\"\nexport * from \"./schemas/view\"\n"],"mappings":";;;;AAGA,MAAa,uBAAuB,EAAE,KAAK,kBAAkB;AAG7D,MAAa,8BAA8B,EAAE,OAAO,EAClD,YAAY,sBACb,CAAC,CAAC,QAAQ;AAGX,MAAa,+BAA+B,EAAE,OAAO;CACnD,YAAY;CACZ,SAAS,EAAE,SAAS;CACrB,CAAC;;;ACRF,MAAa,qBAAqB,EAChC,QAAQ,GACL,MAAM;CACL,QAAQ;CACR,MAAM;CACN,SAAS;CACT,MAAM,CAAC,cAAc;CACtB,CAAC,CACD,MAAM,4BAA4B,CAClC,OAAO,6BAA6B,EACxC;;;ACPD,MAAa,oCAAoC,EAAE,KAAK;CACtD;CACA;CACA;CACA;CACD,CAAC;AAGF,MAAa,qCAAqC,EAAE,OAAO;CACzD,gBAAgB,EAAE,QAAQ,CAAC,UAAU;CACrC,cAAc,EAAE,QAAQ,CAAC,UAAU;CACnC,cAAc,EAAE,QAAQ,CAAC,UAAU;CACnC,eAAe,EAAE,SAAS,CAAC,UAAU;CACrC,cAAc,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;CAC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M,CAAC,OAAO;GACf,CAAC,CACD,MAAM,qBAAqB,CAC3B,OAAO,sBAAsB;EAEhC,SAAS,kBACN,OAAO,mBAAmB,mBAAmB,+BAA+B,CAAC,CAC7E,MAAM;GACL,QAAQ;GACR,MAAM;GACN,SAAS;GACT,MAAM,CAAC,OAAO;GACf,CAAC,CACD,MAAM,sBAAsB,CAC5B,OAAO,uBAAuB;EAClC;CClDA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@read-frog/api-contract",
3
3
  "type": "module",
4
- "version": "0.2.2",
4
+ "version": "0.4.0",
5
5
  "private": false,
6
6
  "exports": {
7
7
  ".": {
@@ -12,17 +12,18 @@
12
12
  "main": "./dist/index.js",
13
13
  "types": "./dist/index.d.ts",
14
14
  "files": [
15
- "dist"
15
+ "dist",
16
+ "src"
16
17
  ],
17
18
  "dependencies": {
18
- "@orpc/contract": "^1.13.5",
19
+ "@orpc/contract": "^1.13.14",
19
20
  "zod": "^4.3.6",
20
- "@read-frog/definitions": "0.1.2"
21
+ "@read-frog/definitions": "0.1.3"
21
22
  },
22
23
  "devDependencies": {
23
- "@types/node": "^25.5.0",
24
- "tsdown": "^0.20.3",
25
- "@repo/eslint-config": "0.0.0",
24
+ "@types/node": "^25.6.0",
25
+ "tsdown": "^0.21.8",
26
+ "@repo/eslint-config": "0.0.1",
26
27
  "@repo/tsdown-config": "0.0.0",
27
28
  "@repo/typescript-config": "0.0.0"
28
29
  },
@@ -30,6 +31,7 @@
30
31
  "build": "tsdown",
31
32
  "dev": "tsdown --watch",
32
33
  "build:publish": "tsdown",
34
+ "type-check": "tsc --noEmit",
33
35
  "lint": "eslint .",
34
36
  "lint:fix": "eslint --fix"
35
37
  }
@@ -0,0 +1,17 @@
1
+ import { oc } from "@orpc/contract"
2
+ import {
3
+ BetaAccessStatusInputSchema,
4
+ BetaAccessStatusOutputSchema,
5
+ } from "@/schemas/beta-access"
6
+
7
+ export const betaAccessContract = {
8
+ status: oc
9
+ .route({
10
+ method: "GET",
11
+ path: "/beta-access/status",
12
+ summary: "Get beta access status for a feature",
13
+ tags: ["Beta Access"],
14
+ })
15
+ .input(BetaAccessStatusInputSchema)
16
+ .output(BetaAccessStatusOutputSchema),
17
+ }
@@ -0,0 +1,62 @@
1
+ import { pickPublicErrorMap } from "@/public-errors"
2
+ import {
3
+ ColumnCreateInputSchema,
4
+ ColumnCreateOutputSchema,
5
+ ColumnDeleteInputSchema,
6
+ ColumnDeleteOutputSchema,
7
+ ColumnReorderInputSchema,
8
+ ColumnReorderOutputSchema,
9
+ ColumnUpdateInputSchema,
10
+ ColumnUpdateOutputSchema,
11
+ } from "@/schemas/column"
12
+ import { notebaseProcedure } from "./shared"
13
+
14
+ export const columnContract = {
15
+ create: notebaseProcedure
16
+ .errors(pickPublicErrorMap("TABLE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT"))
17
+ .route({
18
+ method: "POST",
19
+ path: "/columns",
20
+ summary: "Create column",
21
+ tags: ["Columns"],
22
+ })
23
+ .input(ColumnCreateInputSchema)
24
+ .output(ColumnCreateOutputSchema),
25
+
26
+ update: notebaseProcedure
27
+ .errors(pickPublicErrorMap("COLUMN_NOT_FOUND"))
28
+ .route({
29
+ method: "PATCH",
30
+ path: "/columns/{columnId}",
31
+ summary: "Update column",
32
+ tags: ["Columns"],
33
+ })
34
+ .input(ColumnUpdateInputSchema)
35
+ .output(ColumnUpdateOutputSchema),
36
+
37
+ delete: notebaseProcedure
38
+ .errors(pickPublicErrorMap(
39
+ "COLUMN_NOT_FOUND",
40
+ "PRIMARY_COLUMN_DELETE_NOT_ALLOWED",
41
+ "CONCURRENT_POSITION_CONFLICT",
42
+ ))
43
+ .route({
44
+ method: "DELETE",
45
+ path: "/columns/{columnId}",
46
+ summary: "Delete column",
47
+ tags: ["Columns"],
48
+ })
49
+ .input(ColumnDeleteInputSchema)
50
+ .output(ColumnDeleteOutputSchema),
51
+
52
+ reorder: notebaseProcedure
53
+ .errors(pickPublicErrorMap("TABLE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT"))
54
+ .route({
55
+ method: "POST",
56
+ path: "/columns/reorder",
57
+ summary: "Reorder columns in a table",
58
+ tags: ["Columns"],
59
+ })
60
+ .input(ColumnReorderInputSchema)
61
+ .output(ColumnReorderOutputSchema),
62
+ }
@@ -0,0 +1,82 @@
1
+ import { pickPublicErrorMap } from "@/public-errors"
2
+ import {
3
+ CustomTableCreateInputSchema,
4
+ CustomTableCreateOutputSchema,
5
+ CustomTableDeleteInputSchema,
6
+ CustomTableDeleteOutputSchema,
7
+ CustomTableGetInputSchema,
8
+ CustomTableGetOutputSchema,
9
+ CustomTableGetSchemaInputSchema,
10
+ CustomTableGetSchemaOutputSchema,
11
+ CustomTableListInputSchema,
12
+ CustomTableListOutputSchema,
13
+ CustomTableUpdateInputSchema,
14
+ CustomTableUpdateOutputSchema,
15
+ } from "@/schemas/custom-table"
16
+ import { notebaseProcedure } from "./shared"
17
+
18
+ export const customTableContract = {
19
+ list: notebaseProcedure
20
+ .route({
21
+ method: "GET",
22
+ path: "/custom-tables",
23
+ summary: "List custom tables",
24
+ tags: ["Custom Tables"],
25
+ })
26
+ .input(CustomTableListInputSchema)
27
+ .output(CustomTableListOutputSchema),
28
+
29
+ get: notebaseProcedure
30
+ .errors(pickPublicErrorMap("TABLE_NOT_FOUND"))
31
+ .route({
32
+ method: "GET",
33
+ path: "/custom-tables/{id}",
34
+ summary: "Get custom table with columns, rows, and views",
35
+ tags: ["Custom Tables"],
36
+ })
37
+ .input(CustomTableGetInputSchema)
38
+ .output(CustomTableGetOutputSchema),
39
+
40
+ getSchema: notebaseProcedure
41
+ .errors(pickPublicErrorMap("TABLE_NOT_FOUND"))
42
+ .route({
43
+ method: "GET",
44
+ path: "/custom-tables/{id}/schema",
45
+ summary: "Get custom table schema",
46
+ tags: ["Custom Tables"],
47
+ })
48
+ .input(CustomTableGetSchemaInputSchema)
49
+ .output(CustomTableGetSchemaOutputSchema),
50
+
51
+ create: notebaseProcedure
52
+ .route({
53
+ method: "POST",
54
+ path: "/custom-tables",
55
+ summary: "Create custom table",
56
+ tags: ["Custom Tables"],
57
+ })
58
+ .input(CustomTableCreateInputSchema)
59
+ .output(CustomTableCreateOutputSchema),
60
+
61
+ update: notebaseProcedure
62
+ .errors(pickPublicErrorMap("TABLE_NOT_FOUND"))
63
+ .route({
64
+ method: "PUT",
65
+ path: "/custom-tables/{id}",
66
+ summary: "Update custom table",
67
+ tags: ["Custom Tables"],
68
+ })
69
+ .input(CustomTableUpdateInputSchema)
70
+ .output(CustomTableUpdateOutputSchema),
71
+
72
+ delete: notebaseProcedure
73
+ .errors(pickPublicErrorMap("TABLE_NOT_FOUND"))
74
+ .route({
75
+ method: "DELETE",
76
+ path: "/custom-tables/{id}",
77
+ summary: "Delete custom table",
78
+ tags: ["Custom Tables"],
79
+ })
80
+ .input(CustomTableDeleteInputSchema)
81
+ .output(CustomTableDeleteOutputSchema),
82
+ }
@@ -0,0 +1,62 @@
1
+ import { pickPublicErrorMap } from "@/public-errors"
2
+ import {
3
+ RowCreateInputSchema,
4
+ RowCreateOutputSchema,
5
+ RowDeleteInputSchema,
6
+ RowDeleteOutputSchema,
7
+ RowReorderInputSchema,
8
+ RowReorderOutputSchema,
9
+ RowUpdateInputSchema,
10
+ RowUpdateOutputSchema,
11
+ } from "@/schemas/row"
12
+ import { notebaseProcedure } from "./shared"
13
+
14
+ export const rowContract = {
15
+ create: notebaseProcedure
16
+ .errors(pickPublicErrorMap(
17
+ "TABLE_NOT_FOUND",
18
+ "CELL_VALIDATION_FAILED",
19
+ "CONCURRENT_POSITION_CONFLICT",
20
+ ))
21
+ .route({
22
+ method: "POST",
23
+ path: "/rows",
24
+ summary: "Create row",
25
+ tags: ["Rows"],
26
+ })
27
+ .input(RowCreateInputSchema)
28
+ .output(RowCreateOutputSchema),
29
+
30
+ update: notebaseProcedure
31
+ .errors(pickPublicErrorMap("ROW_NOT_FOUND", "CELL_VALIDATION_FAILED"))
32
+ .route({
33
+ method: "PATCH",
34
+ path: "/rows/{rowId}",
35
+ summary: "Update row cells",
36
+ tags: ["Rows"],
37
+ })
38
+ .input(RowUpdateInputSchema)
39
+ .output(RowUpdateOutputSchema),
40
+
41
+ delete: notebaseProcedure
42
+ .errors(pickPublicErrorMap("ROW_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT"))
43
+ .route({
44
+ method: "DELETE",
45
+ path: "/rows/{rowId}",
46
+ summary: "Delete row",
47
+ tags: ["Rows"],
48
+ })
49
+ .input(RowDeleteInputSchema)
50
+ .output(RowDeleteOutputSchema),
51
+
52
+ reorder: notebaseProcedure
53
+ .errors(pickPublicErrorMap("TABLE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT"))
54
+ .route({
55
+ method: "POST",
56
+ path: "/rows/reorder",
57
+ summary: "Reorder rows in a table",
58
+ tags: ["Rows"],
59
+ })
60
+ .input(RowReorderInputSchema)
61
+ .output(RowReorderOutputSchema),
62
+ }
@@ -0,0 +1,6 @@
1
+ import { oc } from "@orpc/contract"
2
+ import { pickPublicErrorMap } from "@/public-errors"
3
+
4
+ export const notebaseProcedure = oc.errors(
5
+ pickPublicErrorMap("NOTEBASE_BETA_RESTRICTED"),
6
+ )
package/src/index.ts ADDED
@@ -0,0 +1,21 @@
1
+ import type { ContractRouterClient } from "@orpc/contract"
2
+ import { betaAccessContract } from "./contracts/beta-access"
3
+ import { columnContract } from "./contracts/column"
4
+ import { customTableContract } from "./contracts/custom-table"
5
+ import { rowContract } from "./contracts/row"
6
+
7
+ export const contract = {
8
+ betaAccess: betaAccessContract,
9
+ customTable: customTableContract,
10
+ column: columnContract,
11
+ row: rowContract,
12
+ }
13
+
14
+ export type ORPCRouterClient = ContractRouterClient<typeof contract>
15
+
16
+ export * from "./public-errors"
17
+ export * from "./schemas/beta-access"
18
+ export * from "./schemas/column"
19
+ export * from "./schemas/custom-table"
20
+ export * from "./schemas/row"
21
+ export * from "./schemas/view"
@@ -0,0 +1,104 @@
1
+ import type { ErrorMap } from "@orpc/contract"
2
+ import { z } from "zod"
3
+
4
+ interface PublicAppErrorDefinition {
5
+ data?: z.ZodTypeAny
6
+ message: string
7
+ status: number
8
+ }
9
+
10
+ export const CellValidationFailureReasonSchema = z.enum([
11
+ "unknown_column",
12
+ "type_mismatch",
13
+ "invalid_select_option",
14
+ "invalid_date_format",
15
+ ])
16
+ export type CellValidationFailureReason = z.infer<typeof CellValidationFailureReasonSchema>
17
+
18
+ export const CellValidationFailureDetailsSchema = z.object({
19
+ expectedFormat: z.string().optional(),
20
+ expectedType: z.string().optional(),
21
+ receivedType: z.string().optional(),
22
+ receivedValue: z.unknown().optional(),
23
+ validOptions: z.array(z.string()).optional(),
24
+ }).strict()
25
+ export type CellValidationFailureDetails = z.infer<typeof CellValidationFailureDetailsSchema>
26
+
27
+ export const CellValidationFailedDataSchema = z.object({
28
+ columnId: z.string(),
29
+ details: CellValidationFailureDetailsSchema,
30
+ reason: CellValidationFailureReasonSchema,
31
+ }).strict()
32
+ export type CellValidationFailedData = z.infer<typeof CellValidationFailedDataSchema>
33
+
34
+ export const PUBLIC_APP_ERROR_DEFS = {
35
+ NOTEBASE_BETA_RESTRICTED: {
36
+ message: "Notebase is currently in beta for selected accounts",
37
+ status: 403,
38
+ },
39
+ TABLE_NOT_FOUND: {
40
+ message: "Table not found",
41
+ status: 404,
42
+ },
43
+ COLUMN_NOT_FOUND: {
44
+ message: "Column not found",
45
+ status: 404,
46
+ },
47
+ ROW_NOT_FOUND: {
48
+ message: "Row not found",
49
+ status: 404,
50
+ },
51
+ VIEW_NOT_FOUND: {
52
+ message: "View not found",
53
+ status: 404,
54
+ },
55
+ CELL_VALIDATION_FAILED: {
56
+ data: CellValidationFailedDataSchema,
57
+ message: "Cell validation failed",
58
+ status: 422,
59
+ },
60
+ PRIMARY_COLUMN_DELETE_NOT_ALLOWED: {
61
+ message: "Cannot delete primary column",
62
+ status: 400,
63
+ },
64
+ CONCURRENT_POSITION_CONFLICT: {
65
+ message: "Concurrent position conflict, please retry",
66
+ status: 409,
67
+ },
68
+ } as const satisfies Record<string, PublicAppErrorDefinition>
69
+
70
+ export type PublicAppErrorCode = keyof typeof PUBLIC_APP_ERROR_DEFS
71
+
72
+ export type PublicAppErrorData<TCode extends PublicAppErrorCode>
73
+ = (typeof PUBLIC_APP_ERROR_DEFS)[TCode] extends { data: infer TSchema extends z.ZodTypeAny }
74
+ ? z.output<TSchema>
75
+ : undefined
76
+
77
+ export function isPublicAppErrorCode(code: string | undefined): code is PublicAppErrorCode {
78
+ return code !== undefined && code in PUBLIC_APP_ERROR_DEFS
79
+ }
80
+
81
+ export function getPublicErrorDefinition<TCode extends PublicAppErrorCode>(code: TCode) {
82
+ return PUBLIC_APP_ERROR_DEFS[code]
83
+ }
84
+
85
+ export function pickPublicErrorMap<const TCodes extends readonly PublicAppErrorCode[]>(
86
+ ...codes: TCodes
87
+ ) {
88
+ return Object.fromEntries(codes.map((code) => {
89
+ const definition = PUBLIC_APP_ERROR_DEFS[code]
90
+
91
+ if ("data" in definition) {
92
+ return [code, {
93
+ data: definition.data,
94
+ message: definition.message,
95
+ status: definition.status,
96
+ }]
97
+ }
98
+
99
+ return [code, {
100
+ message: definition.message,
101
+ status: definition.status,
102
+ }]
103
+ })) as Pick<ErrorMap, TCodes[number]>
104
+ }
@@ -0,0 +1,16 @@
1
+ import { BETA_FEATURE_KEYS } from "@read-frog/definitions"
2
+ import { z } from "zod"
3
+
4
+ export const BetaFeatureKeySchema = z.enum(BETA_FEATURE_KEYS)
5
+ export type BetaFeatureKey = z.infer<typeof BetaFeatureKeySchema>
6
+
7
+ export const BetaAccessStatusInputSchema = z.object({
8
+ featureKey: BetaFeatureKeySchema,
9
+ }).strict()
10
+ export type BetaAccessStatusInput = z.infer<typeof BetaAccessStatusInputSchema>
11
+
12
+ export const BetaAccessStatusOutputSchema = z.object({
13
+ featureKey: BetaFeatureKeySchema,
14
+ allowed: z.boolean(),
15
+ })
16
+ export type BetaAccessStatusOutput = z.infer<typeof BetaAccessStatusOutputSchema>
@@ -0,0 +1,74 @@
1
+ import { COLUMN_MAX_WIDTH, COLUMN_MIN_WIDTH, columnConfigSchema } from "@read-frog/definitions"
2
+ import { z } from "zod"
3
+
4
+ export const columnWidthSchema = z.number().int().min(COLUMN_MIN_WIDTH).max(COLUMN_MAX_WIDTH)
5
+
6
+ export const tableColumnSchema = z.object({
7
+ id: z.string(),
8
+ tableId: z.string(),
9
+ name: z.string(),
10
+ config: columnConfigSchema,
11
+ position: z.number(),
12
+ isPrimary: z.boolean(),
13
+ width: z.number().nullable(),
14
+ createdAt: z.coerce.date(),
15
+ updatedAt: z.coerce.date(),
16
+ })
17
+ export type TableColumn = z.infer<typeof tableColumnSchema>
18
+
19
+ export const columnCreateDataSchema = z.object({
20
+ id: z.uuid().optional(),
21
+ name: z.string().min(1),
22
+ config: columnConfigSchema,
23
+ }).strict()
24
+ export type ColumnCreateData = z.infer<typeof columnCreateDataSchema>
25
+
26
+ export const columnUpdateDataSchema = z.object({
27
+ name: z.string().min(1).optional(),
28
+ config: columnConfigSchema.optional(),
29
+ width: columnWidthSchema.nullable().optional(),
30
+ }).strict()
31
+ export type ColumnUpdateData = z.infer<typeof columnUpdateDataSchema>
32
+
33
+ export const ColumnCreateInputSchema = z.object({
34
+ tableId: z.uuid(),
35
+ data: columnCreateDataSchema,
36
+ })
37
+ export type ColumnCreateInput = z.infer<typeof ColumnCreateInputSchema>
38
+
39
+ export const ColumnCreateOutputSchema = z.object({
40
+ txid: z.number(),
41
+ })
42
+ export type ColumnCreateOutput = z.infer<typeof ColumnCreateOutputSchema>
43
+
44
+ export const ColumnUpdateInputSchema = z.object({
45
+ columnId: z.uuid(),
46
+ data: columnUpdateDataSchema,
47
+ })
48
+ export type ColumnUpdateInput = z.infer<typeof ColumnUpdateInputSchema>
49
+
50
+ export const ColumnUpdateOutputSchema = z.object({
51
+ txid: z.number(),
52
+ })
53
+ export type ColumnUpdateOutput = z.infer<typeof ColumnUpdateOutputSchema>
54
+
55
+ export const ColumnDeleteInputSchema = z.object({
56
+ columnId: z.uuid(),
57
+ })
58
+ export type ColumnDeleteInput = z.infer<typeof ColumnDeleteInputSchema>
59
+
60
+ export const ColumnDeleteOutputSchema = z.object({
61
+ txid: z.number(),
62
+ })
63
+ export type ColumnDeleteOutput = z.infer<typeof ColumnDeleteOutputSchema>
64
+
65
+ export const ColumnReorderInputSchema = z.object({
66
+ tableId: z.uuid(),
67
+ ids: z.array(z.uuid()),
68
+ })
69
+ export type ColumnReorderInput = z.infer<typeof ColumnReorderInputSchema>
70
+
71
+ export const ColumnReorderOutputSchema = z.object({
72
+ txid: z.number(),
73
+ })
74
+ export type ColumnReorderOutput = z.infer<typeof ColumnReorderOutputSchema>