Repository navigation
Add missing documentation files for mapping and block schemas #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| --- | ||
| title: Mapping | ||
| description: Mapping protocol schemas | ||
| --- | ||
|
|
||
| # Mapping | ||
|
|
||
| <Callout type="info"> | ||
| **Source:** `packages/spec/src/data/mapping.zod.ts` | ||
| </Callout> | ||
|
|
||
| ## TypeScript Usage | ||
|
|
||
| ```typescript | ||
| import { MappingSchema, FieldMappingSchema, TransformType } from '@objectstack/spec/data'; | ||
| import type { Mapping, FieldMapping } from '@objectstack/spec/data'; | ||
|
|
||
| // Validate data | ||
| const result = MappingSchema.parse(data); | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## FieldMapping | ||
|
|
||
| ### Properties | ||
|
|
||
| | Property | Type | Required | Description | | ||
| | :--- | :--- | :--- | :--- | | ||
| | **source** | `string \| string[]` | ✅ | Source column header(s) | | ||
| | **target** | `string \| string[]` | ✅ | Target object field(s) | | ||
| | **transform** | `Enum<'none' \| 'constant' \| 'lookup' \| 'split' \| 'join' \| 'javascript' \| 'map'>` | optional | Transformation type (default: 'none') | | ||
| | **params** | `object` | optional | Configuration for transform | | ||
|
Comment on lines
+28
to
+33
|
||
|
|
||
| ### Transform Params Properties | ||
|
|
||
| | Property | Type | Required | Description | | ||
| | :--- | :--- | :--- | :--- | | ||
| | **value** | `any` | optional | Value for constant transform | | ||
| | **object** | `string` | optional | Lookup Object for lookup transform | | ||
| | **fromField** | `string` | optional | Match on field (e.g. "name") for lookup | | ||
| | **toField** | `string` | optional | Value to take (e.g. "_id") for lookup | | ||
| | **autoCreate** | `boolean` | optional | Create if missing for lookup | | ||
| | **valueMap** | `Record<string, any>` | optional | Value mapping for map transform (e.g. { "Open": "draft" }) | | ||
| | **separator** | `string` | optional | Separator for split/join transforms | | ||
|
|
||
|
Comment on lines
+37
to
+46
|
||
| --- | ||
|
|
||
| ## Mapping | ||
|
|
||
| Defines a reusable data mapping configuration for ETL operations. | ||
|
|
||
| **NAMING CONVENTION:** | ||
| Mapping names are machine identifiers and must be lowercase snake_case. | ||
|
|
||
| **Examples of good mapping names:** | ||
| - `salesforce_to_crm` | ||
| - `csv_import_contacts` | ||
| - `api_sync_orders` | ||
|
|
||
| **Examples of bad mapping names (will be rejected):** | ||
| - `SalesforceToCRM` (PascalCase) | ||
| - `CSV Import` (spaces) | ||
|
|
||
| ### Properties | ||
|
|
||
| | Property | Type | Required | Description | | ||
| | :--- | :--- | :--- | :--- | | ||
| | **name** | `string` | ✅ | Mapping unique name (lowercase snake_case) | | ||
| | **label** | `string` | optional | Human readable label | | ||
| | **sourceFormat** | `Enum<'csv' \| 'json' \| 'xml' \| 'sql'>` | optional | Source data format (default: 'csv') | | ||
| | **targetObject** | `string` | ✅ | Target Object Name | | ||
| | **fieldMapping** | `object[]` | ✅ | Column Mappings | | ||
| | **mode** | `Enum<'insert' \| 'update' \| 'upsert'>` | optional | Data operation mode (default: 'insert') | | ||
| | **upsertKey** | `string[]` | optional | Fields to match for upsert (e.g. email) | | ||
| | **extractQuery** | `object` | optional | Query to run for export only | | ||
|
Comment on lines
+67
to
+76
|
||
| | **errorPolicy** | `Enum<'skip' \| 'abort' \| 'retry'>` | optional | Error handling strategy (default: 'skip') | | ||
| | **batchSize** | `number` | optional | Batch size for operations (default: 1000) | | ||
|
|
||
| --- | ||
|
|
||
| ## TransformType | ||
|
|
||
| Built-in helpers for converting data during import. | ||
|
|
||
| ### Allowed Values | ||
|
|
||
| * `none` - Direct copy | ||
| * `constant` - Use a hardcoded value | ||
| * `lookup` - Resolve FK (Name → ID) | ||
| * `split` - "John Doe" → ["John", "Doe"] | ||
| * `join` - ["John", "Doe"] → "John Doe" | ||
| * `javascript` - Custom script (Review security!) | ||
| * `map` - Value mapping (e.g. "Active" → "active") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| --- | ||
| title: Block | ||
| description: Block protocol schemas | ||
| --- | ||
|
|
||
| # Block | ||
|
|
||
| <Callout type="info"> | ||
| **Source:** `packages/spec/src/ui/block.zod.ts` | ||
| </Callout> | ||
|
|
||
| ## TypeScript Usage | ||
|
|
||
| ```typescript | ||
| import { | ||
| PageHeaderProps, | ||
| PageTabsProps, | ||
| PageCardProps, | ||
| RecordDetailsProps, | ||
| RecordRelatedListProps, | ||
| RecordHighlightsProps, | ||
| ComponentPropsMap | ||
| } from '@objectstack/spec/ui'; | ||
|
|
||
| // Validate data | ||
| const result = PageHeaderProps.parse(data); | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Component Props Map | ||
|
|
||
| Maps Component Type to its Property Schema. Available component types: | ||
|
|
||
| ### Structure Components | ||
|
|
||
| * `page:header` | ||
| * `page:tabs` | ||
| * `page:card` | ||
| * `page:footer` | ||
| * `page:sidebar` | ||
| * `page:accordion` | ||
| * `page:section` | ||
|
|
||
| ### Record Components | ||
|
|
||
| * `record:details` | ||
| * `record:related_list` | ||
| * `record:highlights` | ||
| * `record:activity` | ||
| * `record:chatter` | ||
| * `record:path` | ||
|
|
||
| ### Navigation Components | ||
|
|
||
| * `app:launcher` | ||
| * `nav:menu` | ||
| * `nav:breadcrumb` | ||
|
|
||
| ### Utility Components | ||
|
|
||
| * `global:search` | ||
| * `global:notifications` | ||
| * `user:profile` | ||
|
|
||
| ### AI Components | ||
|
|
||
| * `ai:chat_window` | ||
| * `ai:suggestion` | ||
|
|
||
| --- | ||
|
|
||
| ## PageHeaderProps | ||
|
|
||
| ### Properties | ||
|
|
||
| | Property | Type | Required | Description | | ||
| | :--- | :--- | :--- | :--- | | ||
| | **title** | `string` | ✅ | Page title | | ||
| | **subtitle** | `string` | optional | Page subtitle | | ||
| | **icon** | `string` | optional | Icon name | | ||
| | **breadcrumb** | `boolean` | optional | Show breadcrumb (default: true) | | ||
| | **actions** | `string[]` | optional | Action IDs to show in header | | ||
|
Comment on lines
+77
to
+83
|
||
|
|
||
| --- | ||
|
|
||
| ## PageTabsProps | ||
|
|
||
| ### Properties | ||
|
|
||
| | Property | Type | Required | Description | | ||
| | :--- | :--- | :--- | :--- | | ||
| | **type** | `Enum<'line' \| 'card' \| 'pill'>` | optional | Tab type (default: 'line') | | ||
| | **position** | `Enum<'top' \| 'left'>` | optional | Tab position (default: 'top') | | ||
| | **items** | `object[]` | ✅ | Tab items | | ||
|
|
||
|
Comment on lines
+91
to
+96
|
||
| ### Tab Item Properties | ||
|
|
||
| | Property | Type | Required | Description | | ||
| | :--- | :--- | :--- | :--- | | ||
| | **label** | `string` | ✅ | Tab label | | ||
| | **icon** | `string` | optional | Tab icon | | ||
| | **children** | `any[]` | ✅ | Child components | | ||
|
Comment on lines
+99
to
+103
|
||
|
|
||
| --- | ||
|
|
||
| ## PageCardProps | ||
|
|
||
| ### Properties | ||
|
|
||
| | Property | Type | Required | Description | | ||
| | :--- | :--- | :--- | :--- | | ||
| | **title** | `string` | optional | Card title | | ||
| | **bordered** | `boolean` | optional | Show border (default: true) | | ||
| | **actions** | `string[]` | optional | Action IDs | | ||
| | **children** | `any[]` | ✅ | Card content | | ||
|
Comment on lines
+111
to
+116
|
||
|
|
||
| --- | ||
|
|
||
| ## RecordDetailsProps | ||
|
|
||
| ### Properties | ||
|
|
||
| | Property | Type | Required | Description | | ||
| | :--- | :--- | :--- | :--- | | ||
| | **columns** | `Enum<'1' \| '2' \| '3' \| '4'>` | optional | Number of columns (default: '2') | | ||
| | **layout** | `Enum<'auto' \| 'custom'>` | optional | Layout mode (default: 'auto') | | ||
| | **sections** | `string[]` | optional | Section IDs to show (for custom layout) | | ||
|
Comment on lines
+124
to
+128
|
||
|
|
||
| --- | ||
|
|
||
| ## RecordRelatedListProps | ||
|
|
||
| ### Properties | ||
|
|
||
| | Property | Type | Required | Description | | ||
| | :--- | :--- | :--- | :--- | | ||
| | **objectName** | `string` | ✅ | Related object name | | ||
| | **relationshipField** | `string` | ✅ | Field on related object that points to this record | | ||
| | **columns** | `string[]` | ✅ | Fields to display | | ||
| | **sort** | `string` | optional | Sort order | | ||
| | **limit** | `number` | optional | Maximum number of records (default: 5) | | ||
|
Comment on lines
+136
to
+142
|
||
|
|
||
| --- | ||
|
|
||
| ## RecordHighlightsProps | ||
|
|
||
| ### Properties | ||
|
|
||
| | Property | Type | Required | Description | | ||
| | :--- | :--- | :--- | :--- | | ||
| | **fields** | `string[]` | ✅ | Key fields to highlight (minimum 1, maximum 7) | | ||
|
Comment on lines
+150
to
+152
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TypeScript Usage example imports
MappingSchema,FieldMappingSchema,TransformType,Mapping, andFieldMappingfrom@objectstack/spec/data, butpackages/spec/src/data/index.tsdoes not currently re-exportmapping.zod.ts, so this import path will fail. Either update the data index to export these symbols or adjust the example to import directly from themapping.zodmodule so that the snippet reflects the actual public API.