@api-client/core 0.15.0 → 0.16.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/TESTING_READY.md +114 -0
- package/TESTING_SETUP.md +198 -0
- package/build/src/modeling/Semantics.d.ts +126 -2
- package/build/src/modeling/Semantics.d.ts.map +1 -1
- package/build/src/modeling/Semantics.js +281 -13
- package/build/src/modeling/Semantics.js.map +1 -1
- package/build/src/modeling/definitions/Calculated.d.ts +54 -0
- package/build/src/modeling/definitions/Calculated.d.ts.map +1 -0
- package/build/src/modeling/definitions/Calculated.js +31 -0
- package/build/src/modeling/definitions/Calculated.js.map +1 -0
- package/build/src/modeling/definitions/Categories.d.ts +60 -0
- package/build/src/modeling/definitions/Categories.d.ts.map +1 -0
- package/build/src/modeling/definitions/Categories.js +33 -0
- package/build/src/modeling/definitions/Categories.js.map +1 -0
- package/build/src/modeling/definitions/Derived.d.ts +54 -0
- package/build/src/modeling/definitions/Derived.d.ts.map +1 -0
- package/build/src/modeling/definitions/Derived.js +31 -0
- package/build/src/modeling/definitions/Derived.js.map +1 -0
- package/build/src/modeling/definitions/Description.d.ts +36 -0
- package/build/src/modeling/definitions/Description.d.ts.map +1 -0
- package/build/src/modeling/definitions/Description.js +28 -0
- package/build/src/modeling/definitions/Description.js.map +1 -0
- package/build/src/modeling/definitions/Email.d.ts +66 -0
- package/build/src/modeling/definitions/Email.d.ts.map +1 -0
- package/build/src/modeling/definitions/Email.js +33 -0
- package/build/src/modeling/definitions/Email.js.map +1 -0
- package/build/src/modeling/definitions/GeospatialCoordinates.d.ts +212 -0
- package/build/src/modeling/definitions/GeospatialCoordinates.d.ts.map +1 -0
- package/build/src/modeling/definitions/GeospatialCoordinates.js +129 -0
- package/build/src/modeling/definitions/GeospatialCoordinates.js.map +1 -0
- package/build/src/modeling/definitions/HTML.d.ts +88 -0
- package/build/src/modeling/definitions/HTML.d.ts.map +1 -0
- package/build/src/modeling/definitions/HTML.js +42 -0
- package/build/src/modeling/definitions/HTML.js.map +1 -0
- package/build/src/modeling/definitions/Markdown.d.ts +84 -0
- package/build/src/modeling/definitions/Markdown.d.ts.map +1 -0
- package/build/src/modeling/definitions/Markdown.js +41 -0
- package/build/src/modeling/definitions/Markdown.js.map +1 -0
- package/build/src/modeling/definitions/Password.d.ts +112 -0
- package/build/src/modeling/definitions/Password.d.ts.map +1 -0
- package/build/src/modeling/definitions/Password.js +57 -0
- package/build/src/modeling/definitions/Password.js.map +1 -0
- package/build/src/modeling/definitions/Phone.d.ts +83 -0
- package/build/src/modeling/definitions/Phone.d.ts.map +1 -0
- package/build/src/modeling/definitions/Phone.js +39 -0
- package/build/src/modeling/definitions/Phone.js.map +1 -0
- package/build/src/modeling/definitions/Price.d.ts +102 -0
- package/build/src/modeling/definitions/Price.d.ts.map +1 -0
- package/build/src/modeling/definitions/Price.js +99 -0
- package/build/src/modeling/definitions/Price.js.map +1 -0
- package/build/src/modeling/definitions/PublicUniqueName.d.ts +69 -0
- package/build/src/modeling/definitions/PublicUniqueName.d.ts.map +1 -0
- package/build/src/modeling/definitions/PublicUniqueName.js +34 -0
- package/build/src/modeling/definitions/PublicUniqueName.js.map +1 -0
- package/build/src/modeling/definitions/SKU.d.ts +127 -0
- package/build/src/modeling/definitions/SKU.d.ts.map +1 -0
- package/build/src/modeling/definitions/SKU.js +142 -0
- package/build/src/modeling/definitions/SKU.js.map +1 -0
- package/build/src/modeling/definitions/Status.d.ts +150 -0
- package/build/src/modeling/definitions/Status.d.ts.map +1 -0
- package/build/src/modeling/definitions/Status.js +60 -0
- package/build/src/modeling/definitions/Status.js.map +1 -0
- package/build/src/modeling/definitions/Summary.d.ts +53 -0
- package/build/src/modeling/definitions/Summary.d.ts.map +1 -0
- package/build/src/modeling/definitions/Summary.js +50 -0
- package/build/src/modeling/definitions/Summary.js.map +1 -0
- package/build/src/modeling/definitions/Tags.d.ts +52 -0
- package/build/src/modeling/definitions/Tags.d.ts.map +1 -0
- package/build/src/modeling/definitions/Tags.js +32 -0
- package/build/src/modeling/definitions/Tags.js.map +1 -0
- package/build/src/modeling/definitions/URL.d.ts +68 -0
- package/build/src/modeling/definitions/URL.d.ts.map +1 -0
- package/build/src/modeling/definitions/URL.js +37 -0
- package/build/src/modeling/definitions/URL.js.map +1 -0
- package/build/src/modeling/validation/semantic_validation.d.ts +4 -0
- package/build/src/modeling/validation/semantic_validation.d.ts.map +1 -1
- package/build/src/modeling/validation/semantic_validation.js +32 -1
- package/build/src/modeling/validation/semantic_validation.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +9 -9
- package/package.json +1 -1
- package/src/modeling/Semantics.ts +297 -14
- package/src/modeling/definitions/Calculated.ts +76 -0
- package/src/modeling/definitions/Categories.ts +84 -0
- package/src/modeling/definitions/Derived.ts +76 -0
- package/src/modeling/definitions/Description.ts +55 -0
- package/src/modeling/definitions/Email.ts +90 -0
- package/src/modeling/definitions/GeospatialCoordinates.ts +274 -0
- package/src/modeling/definitions/HTML.ts +121 -0
- package/src/modeling/definitions/Markdown.ts +116 -0
- package/src/modeling/definitions/Password.ts +156 -0
- package/src/modeling/definitions/Phone.ts +116 -0
- package/src/modeling/definitions/Price.examples.md +158 -0
- package/src/modeling/definitions/Price.ts +180 -0
- package/src/modeling/definitions/PublicUniqueName.ts +98 -0
- package/src/modeling/definitions/SKU.examples.md +230 -0
- package/src/modeling/definitions/SKU.ts +254 -0
- package/src/modeling/definitions/Status.ts +227 -0
- package/src/modeling/definitions/Summary.ts +73 -0
- package/src/modeling/definitions/Tags.ts +75 -0
- package/src/modeling/definitions/URL.ts +96 -0
- package/src/modeling/validation/semantic_validation.ts +35 -1
- package/tests/example-test-setup.ts +133 -0
- package/tests/template-node.spec.ts +75 -0
- package/tests/test-utils.ts +293 -0
- package/tests/unit/modeling/definitions/calculated.spec.ts +33 -0
- package/tests/unit/modeling/definitions/categories.spec.ts +38 -0
- package/tests/unit/modeling/definitions/derived.spec.ts +34 -0
- package/tests/unit/modeling/definitions/description.spec.ts +38 -0
- package/tests/unit/modeling/definitions/email.spec.ts +38 -0
- package/tests/unit/modeling/definitions/geospatial-coordinates.spec.ts +41 -0
- package/tests/unit/modeling/definitions/html.spec.ts +38 -0
- package/tests/unit/modeling/definitions/markdown.spec.ts +38 -0
- package/tests/unit/modeling/definitions/password.spec.ts +347 -0
- package/tests/unit/modeling/definitions/phone.spec.ts +38 -0
- package/tests/unit/modeling/definitions/price.spec.ts +465 -0
- package/tests/unit/modeling/definitions/public-unique-name.spec.ts +38 -0
- package/tests/unit/modeling/definitions/sku.spec.ts +240 -0
- package/tests/unit/modeling/definitions/status.spec.ts +37 -0
- package/tests/unit/modeling/definitions/summary.spec.ts +36 -0
- package/tests/unit/modeling/definitions/tags.spec.ts +38 -0
- package/tests/unit/modeling/definitions/url.spec.ts +38 -0
- package/tests/unit/modeling/domain_property.spec.ts +106 -0
- package/tests/unit/modeling/domain_validation.spec.ts +5 -5
- package/tests/unit/modeling/semantic-configs.spec.ts +569 -0
- package/tests/unit/modeling/semantics.spec.ts +52 -0
package/TESTING_READY.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Testing Setup Complete! 🎉
|
|
2
|
+
|
|
3
|
+
Your API Client Core project now has a comprehensive testing setup with documentation and utilities.
|
|
4
|
+
|
|
5
|
+
## What's Been Added
|
|
6
|
+
|
|
7
|
+
### 📚 Documentation
|
|
8
|
+
|
|
9
|
+
- **`TESTING_SETUP.md`** - Complete testing guide and reference
|
|
10
|
+
- **Test Templates** - Ready-to-use templates for new tests
|
|
11
|
+
|
|
12
|
+
### 🛠️ Utilities
|
|
13
|
+
|
|
14
|
+
- **`tests/test-utils.ts`** - Common testing utilities and helpers
|
|
15
|
+
- **`tests/example-test-setup.ts`** - Working examples of test patterns
|
|
16
|
+
- **`tests/template-node.spec.ts`** - Template for Node.js tests
|
|
17
|
+
- **`test/template-browser.test.ts`** - Template for browser tests
|
|
18
|
+
|
|
19
|
+
### ⚡ VS Code Tasks
|
|
20
|
+
|
|
21
|
+
- **Test: Run All Tests** - Runs both Node.js and browser tests
|
|
22
|
+
- Additional test tasks available in the Command Palette
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
### Run All Tests
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm test
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Run Node.js Tests Only
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm run test:node
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Run Browser Tests Only
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm run test:browser
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Run Tests with Coverage
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm run test:coverage
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Run Tests in Watch Mode
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm run test:browser:watch
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Your Testing Stack
|
|
57
|
+
|
|
58
|
+
### Node.js Tests (Japa)
|
|
59
|
+
|
|
60
|
+
- **Location**: `tests/unit/**/*.spec.ts`
|
|
61
|
+
- **Framework**: Japa with Assert plugin
|
|
62
|
+
- **Features**: Sinon mocking, API client testing, type checking
|
|
63
|
+
- **Run with**: `npm run test:node`
|
|
64
|
+
|
|
65
|
+
### Browser Tests (Web Test Runner)
|
|
66
|
+
|
|
67
|
+
- **Location**: `test/**/*.browser.test.ts` or `test/**/*.spec.ts`
|
|
68
|
+
- **Framework**: Web Test Runner with Chai
|
|
69
|
+
- **Features**: Playwright automation, OAuth2 mock server, DOM testing
|
|
70
|
+
- **Run with**: `npm run test:browser`
|
|
71
|
+
|
|
72
|
+
## File Naming Conventions
|
|
73
|
+
|
|
74
|
+
- **Node.js tests**: `*.spec.ts` in `tests/unit/`
|
|
75
|
+
- **Browser tests**: `*.browser.test.ts` or `*.spec.ts` in `test/`
|
|
76
|
+
- **Shared utilities**: Place in `test/` directory
|
|
77
|
+
|
|
78
|
+
## Next Steps
|
|
79
|
+
|
|
80
|
+
1. **Review the documentation** in `TESTING_SETUP.md`
|
|
81
|
+
2. **Explore the examples** in `test/example-test-setup.ts`
|
|
82
|
+
3. **Use the templates** to create new tests:
|
|
83
|
+
- Copy `test/template-node.spec.ts` for Node.js tests
|
|
84
|
+
- Copy `test/template-browser.test.ts` for browser tests
|
|
85
|
+
4. **Run the existing tests** to ensure everything works
|
|
86
|
+
5. **Write tests for your modules** using the patterns shown
|
|
87
|
+
|
|
88
|
+
## Testing Best Practices
|
|
89
|
+
|
|
90
|
+
✅ **Separate Node.js and browser tests** - Use appropriate file naming
|
|
91
|
+
✅ **Use test utilities** - Leverage `TestUtils` for common operations
|
|
92
|
+
✅ **Mock external dependencies** - Use Sinon for consistent mocking
|
|
93
|
+
✅ **Test both success and error cases** - Ensure comprehensive coverage
|
|
94
|
+
✅ **Group related tests** - Use test groups for better organization
|
|
95
|
+
✅ **Clean up after tests** - Restore mocks and clean up resources
|
|
96
|
+
|
|
97
|
+
## Available Test Utilities
|
|
98
|
+
|
|
99
|
+
- `TestUtils.createMockResponse()` - HTTP response mocking
|
|
100
|
+
- `TestUtils.createTestRequest()` - HTTP request creation
|
|
101
|
+
- `TestUtils.generateTestData()` - Random test data
|
|
102
|
+
- `TestUtils.assertThrows()` - Error testing
|
|
103
|
+
- `TestUtils.mockFetch()` - Fetch API mocking
|
|
104
|
+
- `BrowserTestUtils.waitForElement()` - DOM element waiting
|
|
105
|
+
- `BrowserTestUtils.createMockLocalStorage()` - Storage mocking
|
|
106
|
+
|
|
107
|
+
## Need Help?
|
|
108
|
+
|
|
109
|
+
- Check `TESTING_SETUP.md` for detailed documentation
|
|
110
|
+
- Look at existing tests in `tests/unit/` for examples
|
|
111
|
+
- Review the templates for common patterns
|
|
112
|
+
- Run tests with `--verbose` flag for more output
|
|
113
|
+
|
|
114
|
+
Happy testing! 🚀
|
package/TESTING_SETUP.md
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# Testing Setup Guide
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This project uses a sophisticated dual-testing approach with:
|
|
6
|
+
|
|
7
|
+
- **Japa** for Node.js unit tests (server-side)
|
|
8
|
+
- **Web Test Runner** for browser tests (client-side)
|
|
9
|
+
|
|
10
|
+
## Test Structure
|
|
11
|
+
|
|
12
|
+
```text
|
|
13
|
+
├── test/ # Browser tests (Web Test Runner)
|
|
14
|
+
│ ├── **/*.browser.test.ts # Browser-specific tests
|
|
15
|
+
│ ├── **/*.spec.ts # Browser test specs
|
|
16
|
+
│ └── env.ts # Test environment configuration
|
|
17
|
+
├── tests/ # Node.js tests (Japa)
|
|
18
|
+
│ └── unit/ # Unit tests for server-side code
|
|
19
|
+
│ └── **/*.spec.ts # Node.js test specs
|
|
20
|
+
└── bin/
|
|
21
|
+
├── test.ts # Japa test runner
|
|
22
|
+
├── test-web.ts # Web Test Runner launcher
|
|
23
|
+
└── plugins/ # Custom test plugins
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Available Test Commands
|
|
27
|
+
|
|
28
|
+
### Node.js Tests
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm run test:node # Run all Node.js tests
|
|
32
|
+
npm run test:node:coverage # Run with coverage
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Browser Tests
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm run test:browser # Run all browser tests
|
|
39
|
+
npm run test:browser:watch # Run in watch mode
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Combined Tests
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm test # Run both Node.js and browser tests
|
|
46
|
+
npm run test:coverage # Run both with coverage
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Test Frameworks & Libraries
|
|
50
|
+
|
|
51
|
+
### Node.js Testing Stack
|
|
52
|
+
|
|
53
|
+
- **@japa/runner** - Test runner
|
|
54
|
+
- **@japa/assert** - Assertions
|
|
55
|
+
- **@japa/api-client** - HTTP client for API testing
|
|
56
|
+
- **@japa/expect-type** - TypeScript type testing
|
|
57
|
+
- **sinon** - Mocking and spying
|
|
58
|
+
- **c8** - Code coverage
|
|
59
|
+
|
|
60
|
+
### Browser Testing Stack
|
|
61
|
+
|
|
62
|
+
- **@web/test-runner** - Test runner
|
|
63
|
+
- **@esm-bundle/chai** - Assertions for browser
|
|
64
|
+
- **@web/test-runner-playwright** - Browser automation
|
|
65
|
+
- **sinon** - Mocking (browser compatible)
|
|
66
|
+
|
|
67
|
+
## Writing Tests
|
|
68
|
+
|
|
69
|
+
### Node.js Tests Example
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { test } from '@japa/runner'
|
|
73
|
+
|
|
74
|
+
test.group('YourModule', (group) => {
|
|
75
|
+
group.each.setup(() => {
|
|
76
|
+
// Setup before each test
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
test('should do something', ({ assert }) => {
|
|
80
|
+
// Your test logic
|
|
81
|
+
assert.equal(actual, expected)
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Browser Tests Example
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { assert } from '@esm-bundle/chai'
|
|
90
|
+
|
|
91
|
+
describe('YourModule', () => {
|
|
92
|
+
it('should work in browser', () => {
|
|
93
|
+
// Your browser test logic
|
|
94
|
+
assert.equal(actual, expected)
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Test Environment Setup
|
|
100
|
+
|
|
101
|
+
### OAuth2 Mock Server
|
|
102
|
+
|
|
103
|
+
- Automatically starts on available port 8000-8100
|
|
104
|
+
- Provides endpoints for various OAuth2 flows
|
|
105
|
+
- Configured in `web-test-runner.config.js`
|
|
106
|
+
|
|
107
|
+
### HTTP Servers
|
|
108
|
+
|
|
109
|
+
- Express servers with CORS support
|
|
110
|
+
- NTLM authentication support
|
|
111
|
+
- Custom middleware for specific test scenarios
|
|
112
|
+
|
|
113
|
+
## Test Plugins
|
|
114
|
+
|
|
115
|
+
### Sinon Plugin
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
test('should mock', ({ sinon, assert }) => {
|
|
119
|
+
const stub = sinon.stub(obj, 'method')
|
|
120
|
+
// ... test logic
|
|
121
|
+
})
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Events Plugin
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
test('should handle events', ({ events, assert }) => {
|
|
128
|
+
// Custom event testing logic
|
|
129
|
+
})
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Configuration Files
|
|
133
|
+
|
|
134
|
+
### TypeScript Configurations
|
|
135
|
+
|
|
136
|
+
- `test/tsconfig.json` - Browser test compilation
|
|
137
|
+
- `tests/tsconfig.json` - Node.js test compilation
|
|
138
|
+
- `tsconfig.browser.json` - Browser build configuration
|
|
139
|
+
- `tsconfig.node.json` - Node.js build configuration
|
|
140
|
+
|
|
141
|
+
### Test Runner Configurations
|
|
142
|
+
|
|
143
|
+
- `web-test-runner.config.js` - Browser test configuration
|
|
144
|
+
- `bin/test.ts` - Japa test configuration
|
|
145
|
+
|
|
146
|
+
## Running Specific Tests
|
|
147
|
+
|
|
148
|
+
### Run specific test files
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Node.js specific file
|
|
152
|
+
npm run test:node -- --files=tests/unit/specific-test.spec.ts
|
|
153
|
+
|
|
154
|
+
# Browser specific file
|
|
155
|
+
npm run test:browser -- --files=test/specific-test.browser.test.ts
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Run tests with debugging
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Node.js with debugging
|
|
162
|
+
node --inspect --import ts-node-maintained/register/esm bin/test.ts
|
|
163
|
+
|
|
164
|
+
# Browser with debugging
|
|
165
|
+
npm run test:browser -- --open --manual
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Coverage Reports
|
|
169
|
+
|
|
170
|
+
Coverage is generated using **c8** for Node.js tests:
|
|
171
|
+
|
|
172
|
+
- Reports in `lcov` and `text` formats
|
|
173
|
+
- Configured to work with TypeScript source maps
|
|
174
|
+
- Excludes test files and build artifacts
|
|
175
|
+
|
|
176
|
+
## Best Practices
|
|
177
|
+
|
|
178
|
+
1. **Separate browser and Node.js tests** - Use appropriate file naming
|
|
179
|
+
2. **Use proper assertions** - Japa's assert for Node.js, Chai for browser
|
|
180
|
+
3. **Mock external dependencies** - Use Sinon for consistent mocking
|
|
181
|
+
4. **Test async code properly** - Use proper async/await patterns
|
|
182
|
+
5. **Group related tests** - Use test groups for better organization
|
|
183
|
+
|
|
184
|
+
## Troubleshooting
|
|
185
|
+
|
|
186
|
+
### Common Issues
|
|
187
|
+
|
|
188
|
+
1. **Port conflicts** - OAuth2 server uses dynamic ports
|
|
189
|
+
2. **TypeScript compilation** - Check tsconfig files
|
|
190
|
+
3. **Browser timeouts** - Increase timeout in web-test-runner config
|
|
191
|
+
4. **Import issues** - Ensure proper ES module imports
|
|
192
|
+
|
|
193
|
+
### Debug Tips
|
|
194
|
+
|
|
195
|
+
1. Use `--watch` mode for development
|
|
196
|
+
2. Check browser console for client-side errors
|
|
197
|
+
3. Use `console.log` or debugger statements
|
|
198
|
+
4. Verify mock server responses
|
|
@@ -38,11 +38,19 @@ export declare enum SemanticType {
|
|
|
38
38
|
*/
|
|
39
39
|
DeletedFlag = "Semantic#DeletedFlag",
|
|
40
40
|
/**
|
|
41
|
-
* Designates a Data Property as a unique public identifier for a resource.
|
|
41
|
+
* Designates a Data Property as a unique public identifier for a resource (the slug).
|
|
42
42
|
* This is often used in URLs to provide a user-friendly way to access the resource.
|
|
43
43
|
* For example, a blog post might have a public unique name like "my-first-post".
|
|
44
|
+
* A URL-friendly text field. The runtime automatically generates a unique, URL-safe string from another field (like a title or name). The user needs to specify which field is used to generate
|
|
45
|
+
* the slug.
|
|
44
46
|
*/
|
|
45
47
|
PublicUniqueName = "Semantic#PublicUniqueName",
|
|
48
|
+
/**
|
|
49
|
+
* A semantic that describes a title of an article, blog post, and so on. This semantic is used with
|
|
50
|
+
* the `PublicUniqueName` to determine which field is responsible for the slug generation. However,
|
|
51
|
+
* we may add more automation related to the `title` property in the future.
|
|
52
|
+
*/
|
|
53
|
+
Title = "Semantic#Title",
|
|
46
54
|
/**
|
|
47
55
|
* Designates a Data Property as the `role` of a user within the system.
|
|
48
56
|
* This is used to define the user's permissions and access levels.
|
|
@@ -51,12 +59,128 @@ export declare enum SemanticType {
|
|
|
51
59
|
* Roles are defined on the entity as enums, or as a string property with a controlled vocabulary.
|
|
52
60
|
*/
|
|
53
61
|
UserRole = "Semantic#UserRole",
|
|
62
|
+
/**
|
|
63
|
+
* A text or enum field to represent the state of a record (e.g., `draft`, `published`, `pending_review`, `archived`).
|
|
64
|
+
*
|
|
65
|
+
* Defined behaviors:
|
|
66
|
+
* - State-Based Filtering: Automatically prevents public users from seeing records in a draft state.
|
|
67
|
+
* - State Transitions: In principle, the runtime should prevent the user from skipping some states.
|
|
68
|
+
* For example, when the record is in the `draft` state, it cannot be moved to the `archived` state without publishing it first. However,
|
|
69
|
+
* we do not have enough customer feedback to design this functionality correctly right now, so
|
|
70
|
+
* it serves as a placeholder semantic annotation.
|
|
71
|
+
*/
|
|
72
|
+
Status = "Semantic#Status",
|
|
73
|
+
/**
|
|
74
|
+
* Annotates an integer field that automatically increments.
|
|
75
|
+
* The runtime automatically increments this number on every update, providing a simple way
|
|
76
|
+
* to track changes and implement optimistic locking to prevent mid-air collisions.
|
|
77
|
+
*/
|
|
78
|
+
Version = "Semantic#Version",
|
|
79
|
+
/**
|
|
80
|
+
* Annotates a field that holds a reference to an image data via an URL.
|
|
81
|
+
* The application + runtime should validate that the input is a well-formed URL.
|
|
82
|
+
*/
|
|
83
|
+
ImageURL = "Semantic#ImageURL",
|
|
84
|
+
/**
|
|
85
|
+
* Annotates a field that holds a reference to a file object via an URL. Ity is distinct from the
|
|
86
|
+
* `ImageURL` semantic as it implicitly states that the target is non-image, binary data (an attachment, for example).
|
|
87
|
+
*/
|
|
88
|
+
FileURL = "Semantic#FileURL",
|
|
89
|
+
/**
|
|
90
|
+
* Annotates the field as a markdown-interpreted field.
|
|
91
|
+
* When an object is created, the runtime performs additional sanitization to prevent XSS attacks.
|
|
92
|
+
*
|
|
93
|
+
* The annotation describes whether the data should be translated to the HTML output when
|
|
94
|
+
* record is read or the original MD content should be returned.
|
|
95
|
+
*/
|
|
96
|
+
Markdown = "Semantic#Markdown",
|
|
97
|
+
/**
|
|
98
|
+
* Annotates the field as containing HTML content.
|
|
99
|
+
* The runtime performs sanitization to prevent XSS attacks and validates HTML structure.
|
|
100
|
+
*
|
|
101
|
+
* The annotation describes whether the data should be rendered as HTML output when
|
|
102
|
+
* record is read or the original HTML content should be returned.
|
|
103
|
+
*/
|
|
104
|
+
HTML = "Semantic#HTML",
|
|
105
|
+
/**
|
|
106
|
+
* Annotates a field that holds geospatial coordinate data (latitude/longitude).
|
|
107
|
+
* The runtime automatically generates API capabilities for location-based queries,
|
|
108
|
+
* such as "find all restaurants within a 5-mile radius."
|
|
109
|
+
*
|
|
110
|
+
* The field should contain coordinate data in a standard format:
|
|
111
|
+
* - "40.7128,-74.0060" (lat,lon)
|
|
112
|
+
* - "POINT(-74.0060 40.7128)" (PostGIS format)
|
|
113
|
+
* - "40.7128°N, 74.0060°W" (degree format)
|
|
114
|
+
*
|
|
115
|
+
* Defined behaviors:
|
|
116
|
+
* - Spatial Indexing: The runtime automatically creates spatial indexes for efficient location-based queries
|
|
117
|
+
* - Distance Queries: Enables API endpoints for finding records within specified distances
|
|
118
|
+
* - Coordinate Validation: Validates that the input follows proper coordinate format
|
|
119
|
+
* - PostGIS Integration: When using PostgreSQL, automatically maps to PostGIS geometry types
|
|
120
|
+
*/
|
|
121
|
+
GeospatialCoordinates = "Semantic#GeospatialCoordinates",
|
|
122
|
+
/**
|
|
123
|
+
* Annotates a field as an email address with validation and verification options.
|
|
124
|
+
*/
|
|
125
|
+
Email = "Semantic#Email",
|
|
126
|
+
/**
|
|
127
|
+
* Annotates a field as a phone number with validation and formatting options.
|
|
128
|
+
*/
|
|
129
|
+
Phone = "Semantic#Phone",
|
|
130
|
+
/**
|
|
131
|
+
* Annotates a field as a monetary value with currency support and precision control.
|
|
132
|
+
* Can store simple decimal amounts or complex objects with amount and currency.
|
|
133
|
+
* Enforces proper decimal handling to avoid floating-point errors.
|
|
134
|
+
*/
|
|
135
|
+
Price = "Semantic#Price",
|
|
136
|
+
/**
|
|
137
|
+
* Annotates a field as a URL with validation and allowed protocols.
|
|
138
|
+
*/
|
|
139
|
+
URL = "Semantic#URL",
|
|
140
|
+
/**
|
|
141
|
+
* Annotates a field as a Stock Keeping Unit (SKU).
|
|
142
|
+
* Enforces uniqueness at the database level, critical for product catalogs.
|
|
143
|
+
* Provides automatic validation and formatting for product identification codes.
|
|
144
|
+
*/
|
|
145
|
+
SKU = "Semantic#SKU",
|
|
146
|
+
/**
|
|
147
|
+
* Annotates a field as a long-form description.
|
|
148
|
+
*/
|
|
149
|
+
Description = "Semantic#Description",
|
|
150
|
+
/**
|
|
151
|
+
* Annotates a field as a short summary.
|
|
152
|
+
*/
|
|
153
|
+
Summary = "Semantic#Summary",
|
|
154
|
+
/**
|
|
155
|
+
* Annotates a field as a calculated value based on a formula.
|
|
156
|
+
*/
|
|
157
|
+
Calculated = "Semantic#Calculated",
|
|
158
|
+
/**
|
|
159
|
+
* Annotates a field as derived from other fields.
|
|
160
|
+
*/
|
|
161
|
+
Derived = "Semantic#Derived",
|
|
54
162
|
/**
|
|
55
163
|
* Designates an association that links a resource to a "User" entity instance.
|
|
56
164
|
* This is used to indicate ownership of the resource for access control purposes.
|
|
57
165
|
* For example, a blog post might have a resource owner identifier that points to the user who created it.
|
|
166
|
+
*
|
|
167
|
+
* Defined behaviors:
|
|
168
|
+
* - Automatic Ownership: When a new record is created, this field is automatically populated with the ID of the authenticated user. It also creates a foreign relationship to the `User` semantic object.
|
|
169
|
+
* - Scoped Access: The runtime automatically filters list and read operations to show only records where the Owner matches the current user. update and delete operations are similarly restricted.
|
|
170
|
+
*/
|
|
171
|
+
ResourceOwnerIdentifier = "Semantic#ResourceOwnerIdentifier",
|
|
172
|
+
/**
|
|
173
|
+
* Annotates an association as supporting tag functionality.
|
|
174
|
+
* Applied to associations between entities to enable tagging behavior.
|
|
175
|
+
* For example, a Product-Category association with Tags semantic enables product tagging.
|
|
176
|
+
*/
|
|
177
|
+
Tags = "Semantic#Tags",
|
|
178
|
+
/**
|
|
179
|
+
* Annotates an association as supporting category functionality.
|
|
180
|
+
* Applied to associations between entities to enable categorization behavior.
|
|
181
|
+
* For example, a Product-Category association with Categories semantic enables product categorization.
|
|
58
182
|
*/
|
|
59
|
-
|
|
183
|
+
Categories = "Semantic#Categories"
|
|
60
184
|
}
|
|
61
185
|
/**
|
|
62
186
|
* Defines the scope at which a semantic can be applied.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Semantics.d.ts","sourceRoot":"","sources":["../../../src/modeling/Semantics.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEzD;;;GAGG;AACH,oBAAY,YAAY;
|
|
1
|
+
{"version":3,"file":"Semantics.d.ts","sourceRoot":"","sources":["../../../src/modeling/Semantics.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEzD;;;GAGG;AACH,oBAAY,YAAY;IAKtB;;OAEG;IACH,IAAI,kBAAkB;IAMtB;;;;OAIG;IACH,QAAQ,sBAAsB;IAC9B;;;OAGG;IACH,gBAAgB,8BAA8B;IAC9C;;;OAGG;IACH,gBAAgB,8BA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