@objectstack/spec 0.8.2 → 0.9.1
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/README.md +58 -4
- package/dist/ai/devops-agent.zod.d.ts +1 -1
- package/dist/ai/feedback-loop.zod.d.ts +4293 -0
- package/dist/ai/feedback-loop.zod.d.ts.map +1 -0
- package/dist/ai/feedback-loop.zod.js +53 -0
- package/dist/ai/index.d.ts +1 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +1 -0
- package/dist/api/documentation.zod.d.ts +1073 -0
- package/dist/api/documentation.zod.d.ts.map +1 -0
- package/dist/api/documentation.zod.js +487 -0
- package/dist/api/errors.zod.d.ts +6 -6
- package/dist/api/graphql.zod.d.ts +3 -3
- package/dist/api/hub.zod.d.ts +5239 -0
- package/dist/api/hub.zod.d.ts.map +1 -0
- package/dist/api/hub.zod.js +784 -0
- package/dist/api/index.d.ts +4 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +4 -0
- package/dist/api/odata.zod.d.ts +1 -1
- package/dist/api/registry.example.d.ts +411 -0
- package/dist/api/registry.example.d.ts.map +1 -0
- package/dist/api/registry.example.js +470 -0
- package/dist/api/registry.zod.d.ts +2095 -0
- package/dist/api/registry.zod.d.ts.map +1 -0
- package/dist/api/registry.zod.js +755 -0
- package/dist/api/websocket.zod.d.ts +8 -8
- package/dist/auth/scim.zod.d.ts +3 -3
- package/dist/automation/flow.zod.d.ts +3 -3
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +1 -0
- package/dist/contracts/schema-driver.d.ts +21 -0
- package/dist/contracts/schema-driver.d.ts.map +1 -0
- package/dist/contracts/schema-driver.js +2 -0
- package/dist/hub/composer.zod.d.ts +226 -0
- package/dist/hub/composer.zod.d.ts.map +1 -1
- package/dist/hub/hub-federation.zod.d.ts +764 -0
- package/dist/hub/hub-federation.zod.d.ts.map +1 -0
- package/dist/hub/hub-federation.zod.js +441 -0
- package/dist/hub/index.d.ts +2 -0
- package/dist/hub/index.d.ts.map +1 -1
- package/dist/hub/index.js +3 -0
- package/dist/hub/plugin-security.zod.d.ts +1029 -0
- package/dist/hub/plugin-security.zod.d.ts.map +1 -0
- package/dist/hub/plugin-security.zod.js +637 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/integration/connector/vercel.zod.d.ts +2 -2
- package/dist/qa/index.d.ts +11 -0
- package/dist/qa/index.d.ts.map +1 -0
- package/dist/qa/index.js +26 -0
- package/dist/qa/testing.zod.d.ts +345 -0
- package/dist/qa/testing.zod.d.ts.map +1 -0
- package/dist/qa/testing.zod.js +69 -0
- package/dist/stack.zod.d.ts +3395 -596
- package/dist/stack.zod.d.ts.map +1 -1
- package/dist/stack.zod.js +20 -2
- package/dist/system/index.d.ts +2 -0
- package/dist/system/index.d.ts.map +1 -1
- package/dist/system/index.js +2 -0
- package/dist/system/manifest.zod.d.ts +226 -0
- package/dist/system/manifest.zod.d.ts.map +1 -1
- package/dist/system/manifest.zod.js +8 -0
- package/dist/system/message-queue.zod.d.ts +2 -2
- package/dist/system/metadata-loader.zod.d.ts +1 -1
- package/dist/system/migration.zod.d.ts +4205 -0
- package/dist/system/migration.zod.d.ts.map +1 -0
- package/dist/system/migration.zod.js +70 -0
- package/dist/system/plugin-loading.zod.d.ts +575 -0
- package/dist/system/plugin-loading.zod.d.ts.map +1 -0
- package/dist/system/plugin-loading.zod.js +612 -0
- package/json-schema/ai/FeedbackLoop.json +7 -0
- package/json-schema/ai/Issue.json +7 -0
- package/json-schema/ai/MetadataSource.json +7 -0
- package/json-schema/ai/Resolution.json +7 -0
- package/json-schema/api/ApiChangelogEntry.json +7 -0
- package/json-schema/api/ApiDiscoveryQuery.json +7 -0
- package/json-schema/api/ApiDiscoveryResponse.json +7 -0
- package/json-schema/api/ApiDocumentationConfig.json +7 -0
- package/json-schema/api/ApiEndpointRegistration.json +7 -0
- package/json-schema/api/ApiMetadata.json +7 -0
- package/json-schema/api/ApiParameter.json +7 -0
- package/json-schema/api/ApiProtocolType.json +7 -0
- package/json-schema/api/ApiRegistry.json +7 -0
- package/json-schema/api/ApiRegistryEntry.json +7 -0
- package/json-schema/api/ApiResponse.json +7 -0
- package/json-schema/api/ApiTestCollection.json +7 -0
- package/json-schema/api/ApiTestRequest.json +7 -0
- package/json-schema/api/ApiTestingUiConfig.json +7 -0
- package/json-schema/api/ApiTestingUiType.json +7 -0
- package/json-schema/api/BuildStatusResponse.json +7 -0
- package/json-schema/api/CodeGenerationTemplate.json +7 -0
- package/json-schema/api/CompileManifestRequest.json +7 -0
- package/json-schema/api/CompileManifestResponse.json +7 -0
- package/json-schema/api/ConflictResolutionStrategy.json +7 -0
- package/json-schema/api/CreateSpaceRequest.json +7 -0
- package/json-schema/api/CreateTenantRequest.json +7 -0
- package/json-schema/api/GeneratedApiDocumentation.json +7 -0
- package/json-schema/api/GetBuildStatusRequest.json +7 -0
- package/json-schema/api/GetMarketplacePluginRequest.json +7 -0
- package/json-schema/api/GetPluginVersionsRequest.json +7 -0
- package/json-schema/api/GetPluginVersionsResponse.json +7 -0
- package/json-schema/api/HttpStatusCode.json +7 -0
- package/json-schema/api/HubHealthResponse.json +7 -0
- package/json-schema/api/HubMetricsResponse.json +7 -0
- package/json-schema/api/IssueLicenseRequest.json +7 -0
- package/json-schema/api/LicenseResponse.json +7 -0
- package/json-schema/api/ListLicensesRequest.json +7 -0
- package/json-schema/api/ListLicensesResponse.json +7 -0
- package/json-schema/api/ListMarketplaceRequest.json +7 -0
- package/json-schema/api/ListMarketplaceResponse.json +7 -0
- package/json-schema/api/ListSpacesRequest.json +7 -0
- package/json-schema/api/ListSpacesResponse.json +7 -0
- package/json-schema/api/ListTenantsRequest.json +7 -0
- package/json-schema/api/ListTenantsResponse.json +7 -0
- package/json-schema/api/MarketplacePluginResponse.json +7 -0
- package/json-schema/api/ObjectQLReference.json +7 -0
- package/json-schema/api/OpenApiSecurityScheme.json +7 -0
- package/json-schema/api/OpenApiServer.json +7 -0
- package/json-schema/api/OpenApiSpec.json +7 -0
- package/json-schema/api/PaginationRequest.json +7 -0
- package/json-schema/api/PaginationResponse.json +7 -0
- package/json-schema/api/PluginResponse.json +7 -0
- package/json-schema/api/PluginVersionInfo.json +7 -0
- package/json-schema/api/PublishPluginRequest.json +7 -0
- package/json-schema/api/RevokeLicenseRequest.json +7 -0
- package/json-schema/api/SchemaDefinition.json +7 -0
- package/json-schema/api/SearchPluginsRequest.json +7 -0
- package/json-schema/api/SearchPluginsResponse.json +7 -0
- package/json-schema/api/SpaceResponse.json +7 -0
- package/json-schema/api/TenantResponse.json +7 -0
- package/json-schema/api/UpdatePluginRequest.json +7 -0
- package/json-schema/api/UpdateSpaceRequest.json +7 -0
- package/json-schema/api/UpdateTenantRequest.json +7 -0
- package/json-schema/api/ValidateLicenseRequest.json +7 -0
- package/json-schema/api/ValidateLicenseResponse.json +7 -0
- package/json-schema/hub/DependencyConflict.json +7 -0
- package/json-schema/hub/DependencyGraph.json +7 -0
- package/json-schema/hub/DependencyGraphNode.json +7 -0
- package/json-schema/hub/DependencyResolutionResult.json +7 -0
- package/json-schema/hub/EdgeLocation.json +7 -0
- package/json-schema/hub/FederationTopology.json +7 -0
- package/json-schema/hub/GlobalRegistryEntry.json +7 -0
- package/json-schema/hub/HubInstance.json +7 -0
- package/json-schema/hub/PackageDependency.json +7 -0
- package/json-schema/hub/PluginProvenance.json +7 -0
- package/json-schema/hub/PluginTrustScore.json +7 -0
- package/json-schema/hub/Region.json +7 -0
- package/json-schema/hub/ReplicationJob.json +7 -0
- package/json-schema/hub/SBOM.json +7 -0
- package/json-schema/hub/SBOMEntry.json +7 -0
- package/json-schema/hub/SecurityPolicy.json +7 -0
- package/json-schema/hub/SecurityScanResult.json +7 -0
- package/json-schema/hub/SecurityVulnerability.json +7 -0
- package/json-schema/hub/TenantPlacementPolicy.json +7 -0
- package/json-schema/hub/VulnerabilitySeverity.json +7 -0
- package/json-schema/qa/TestAction.json +7 -0
- package/json-schema/qa/TestActionType.json +7 -0
- package/json-schema/qa/TestAssertion.json +7 -0
- package/json-schema/qa/TestAssertionType.json +7 -0
- package/json-schema/qa/TestContext.json +7 -0
- package/json-schema/qa/TestScenario.json +7 -0
- package/json-schema/qa/TestStep.json +7 -0
- package/json-schema/qa/TestSuite.json +7 -0
- package/json-schema/system/AddFieldOperation.json +7 -0
- package/json-schema/system/ChangeSet.json +7 -0
- package/json-schema/system/CreateObjectOperation.json +7 -0
- package/json-schema/system/DeleteObjectOperation.json +7 -0
- package/json-schema/system/ExecuteSqlOperation.json +7 -0
- package/json-schema/system/MigrationDependency.json +7 -0
- package/json-schema/system/MigrationOperation.json +7 -0
- package/json-schema/system/ModifyFieldOperation.json +7 -0
- package/json-schema/system/PluginCaching.json +7 -0
- package/json-schema/system/PluginCodeSplitting.json +7 -0
- package/json-schema/system/PluginDependencyResolution.json +7 -0
- package/json-schema/system/PluginDynamicImport.json +7 -0
- package/json-schema/system/PluginHotReload.json +7 -0
- package/json-schema/system/PluginInitialization.json +7 -0
- package/json-schema/system/PluginLoadingConfig.json +7 -0
- package/json-schema/system/PluginLoadingEvent.json +7 -0
- package/json-schema/system/PluginLoadingState.json +7 -0
- package/json-schema/system/PluginLoadingStrategy.json +7 -0
- package/json-schema/system/PluginPerformanceMonitoring.json +7 -0
- package/json-schema/system/PluginPreloadConfig.json +7 -0
- package/json-schema/system/PluginSandboxing.json +7 -0
- package/json-schema/system/RemoveFieldOperation.json +7 -0
- package/json-schema/system/RenameObjectOperation.json +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* API Registry Enhancement Examples
|
|
4
|
+
*
|
|
5
|
+
* This file demonstrates all the enhancements made to the Unified API Registry:
|
|
6
|
+
* 1. RBAC Integration
|
|
7
|
+
* 2. Dynamic Schema Linking (ObjectQL References)
|
|
8
|
+
* 3. Protocol Extensibility
|
|
9
|
+
* 4. Route Conflict Detection
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.productionEndpoint = exports.completeRegistry = exports.fallbackEndpoint = exports.pluginEndpoint = exports.coreEndpoint = exports.websocketEndpoint = exports.trpcEndpoint = exports.grpcEndpoint = exports.orderWithRelations = exports.createEndpointWithDynamicSchema = exports.endpointWithDynamicSchema = exports.adminEndpoint = exports.endpointWithRBAC = void 0;
|
|
13
|
+
const registry_zod_1 = require("./registry.zod");
|
|
14
|
+
// ==========================================
|
|
15
|
+
// Example 1: RBAC Integration
|
|
16
|
+
// ==========================================
|
|
17
|
+
/**
|
|
18
|
+
* Example: Endpoint with RBAC Permission Requirements
|
|
19
|
+
*
|
|
20
|
+
* The gateway automatically validates these permissions before
|
|
21
|
+
* allowing the request to proceed.
|
|
22
|
+
*/
|
|
23
|
+
const endpointWithRBAC = registry_zod_1.ApiEndpointRegistration.create({
|
|
24
|
+
id: 'get_customer_by_id',
|
|
25
|
+
method: 'GET',
|
|
26
|
+
path: '/api/v1/customers/:id',
|
|
27
|
+
summary: 'Get customer by ID',
|
|
28
|
+
description: 'Retrieves a customer record with RBAC protection',
|
|
29
|
+
// RBAC Integration: Permissions checked at gateway level
|
|
30
|
+
requiredPermissions: ['customer.read'],
|
|
31
|
+
parameters: [
|
|
32
|
+
{
|
|
33
|
+
name: 'id',
|
|
34
|
+
in: 'path',
|
|
35
|
+
required: true,
|
|
36
|
+
schema: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
format: 'uuid',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
responses: [
|
|
43
|
+
{
|
|
44
|
+
statusCode: 200,
|
|
45
|
+
description: 'Customer found',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
statusCode: 403,
|
|
49
|
+
description: 'Permission denied - customer.read required',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
exports.endpointWithRBAC = endpointWithRBAC;
|
|
54
|
+
/**
|
|
55
|
+
* Example: Admin Endpoint with Multiple Permissions
|
|
56
|
+
*
|
|
57
|
+
* All listed permissions must be satisfied (AND logic).
|
|
58
|
+
*/
|
|
59
|
+
const adminEndpoint = registry_zod_1.ApiEndpointRegistration.create({
|
|
60
|
+
id: 'bulk_update_customers',
|
|
61
|
+
method: 'POST',
|
|
62
|
+
path: '/api/v1/admin/customers/bulk-update',
|
|
63
|
+
summary: 'Bulk update customers',
|
|
64
|
+
// Multiple permissions required
|
|
65
|
+
requiredPermissions: [
|
|
66
|
+
'customer.modifyAll', // Can modify all customer records
|
|
67
|
+
'api_enabled', // API access enabled
|
|
68
|
+
],
|
|
69
|
+
responses: [],
|
|
70
|
+
});
|
|
71
|
+
exports.adminEndpoint = adminEndpoint;
|
|
72
|
+
// ==========================================
|
|
73
|
+
// Example 2: Dynamic Schema Linking
|
|
74
|
+
// ==========================================
|
|
75
|
+
/**
|
|
76
|
+
* Example: Response with ObjectQL Reference
|
|
77
|
+
*
|
|
78
|
+
* Instead of duplicating the customer schema, we reference
|
|
79
|
+
* the ObjectQL object definition. When the object schema changes,
|
|
80
|
+
* the API documentation automatically updates.
|
|
81
|
+
*/
|
|
82
|
+
const endpointWithDynamicSchema = registry_zod_1.ApiEndpointRegistration.create({
|
|
83
|
+
id: 'get_customer_dynamic',
|
|
84
|
+
method: 'GET',
|
|
85
|
+
path: '/api/v1/customers/:id',
|
|
86
|
+
summary: 'Get customer (with dynamic schema)',
|
|
87
|
+
parameters: [
|
|
88
|
+
{
|
|
89
|
+
name: 'id',
|
|
90
|
+
in: 'path',
|
|
91
|
+
required: true,
|
|
92
|
+
schema: {
|
|
93
|
+
type: 'string',
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
responses: [
|
|
98
|
+
{
|
|
99
|
+
statusCode: 200,
|
|
100
|
+
description: 'Customer retrieved successfully',
|
|
101
|
+
// Dynamic schema reference - auto-updates when object changes
|
|
102
|
+
schema: {
|
|
103
|
+
$ref: {
|
|
104
|
+
objectId: 'customer',
|
|
105
|
+
// Exclude sensitive fields from API response
|
|
106
|
+
excludeFields: ['password_hash', 'internal_notes'],
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
});
|
|
112
|
+
exports.endpointWithDynamicSchema = endpointWithDynamicSchema;
|
|
113
|
+
/**
|
|
114
|
+
* Example: Request Body with ObjectQL Reference
|
|
115
|
+
*
|
|
116
|
+
* The request body schema references the customer object,
|
|
117
|
+
* but only includes specific fields allowed for creation.
|
|
118
|
+
*/
|
|
119
|
+
const createEndpointWithDynamicSchema = registry_zod_1.ApiEndpointRegistration.create({
|
|
120
|
+
id: 'create_customer_dynamic',
|
|
121
|
+
method: 'POST',
|
|
122
|
+
path: '/api/v1/customers',
|
|
123
|
+
summary: 'Create customer (with dynamic schema)',
|
|
124
|
+
requestBody: {
|
|
125
|
+
description: 'Customer data',
|
|
126
|
+
required: true,
|
|
127
|
+
schema: {
|
|
128
|
+
$ref: {
|
|
129
|
+
objectId: 'customer',
|
|
130
|
+
// Only allow these fields in creation
|
|
131
|
+
includeFields: ['name', 'email', 'phone', 'company'],
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
responses: [
|
|
136
|
+
{
|
|
137
|
+
statusCode: 201,
|
|
138
|
+
description: 'Customer created',
|
|
139
|
+
schema: {
|
|
140
|
+
$ref: {
|
|
141
|
+
objectId: 'customer',
|
|
142
|
+
excludeFields: ['password_hash'],
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
});
|
|
148
|
+
exports.createEndpointWithDynamicSchema = createEndpointWithDynamicSchema;
|
|
149
|
+
/**
|
|
150
|
+
* Example: Complex Schema with Related Objects
|
|
151
|
+
*
|
|
152
|
+
* Include related objects via lookup fields for a complete response.
|
|
153
|
+
*/
|
|
154
|
+
const orderWithRelations = registry_zod_1.ApiEndpointRegistration.create({
|
|
155
|
+
id: 'get_order_with_relations',
|
|
156
|
+
method: 'GET',
|
|
157
|
+
path: '/api/v1/orders/:id',
|
|
158
|
+
summary: 'Get order with customer and items',
|
|
159
|
+
parameters: [
|
|
160
|
+
{
|
|
161
|
+
name: 'id',
|
|
162
|
+
in: 'path',
|
|
163
|
+
required: true,
|
|
164
|
+
schema: { type: 'string' },
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
responses: [
|
|
168
|
+
{
|
|
169
|
+
statusCode: 200,
|
|
170
|
+
description: 'Order with related objects',
|
|
171
|
+
schema: {
|
|
172
|
+
$ref: {
|
|
173
|
+
objectId: 'order',
|
|
174
|
+
// Include related customer and order items
|
|
175
|
+
includeRelated: ['customer', 'items'],
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
});
|
|
181
|
+
exports.orderWithRelations = orderWithRelations;
|
|
182
|
+
// ==========================================
|
|
183
|
+
// Example 3: Protocol Extensibility
|
|
184
|
+
// ==========================================
|
|
185
|
+
/**
|
|
186
|
+
* Example: gRPC Service Endpoint
|
|
187
|
+
*
|
|
188
|
+
* Plugin-registered gRPC service with protocol-specific configuration.
|
|
189
|
+
*/
|
|
190
|
+
const grpcEndpoint = registry_zod_1.ApiEndpointRegistration.create({
|
|
191
|
+
id: 'grpc_get_customer',
|
|
192
|
+
path: '/grpc/CustomerService/GetCustomer',
|
|
193
|
+
summary: 'gRPC: Get Customer',
|
|
194
|
+
// Protocol-specific configuration for gRPC
|
|
195
|
+
protocolConfig: {
|
|
196
|
+
subProtocol: 'grpc',
|
|
197
|
+
serviceName: 'CustomerService',
|
|
198
|
+
methodName: 'GetCustomer',
|
|
199
|
+
streaming: false,
|
|
200
|
+
packageName: 'objectstack.customer.v1',
|
|
201
|
+
},
|
|
202
|
+
responses: [],
|
|
203
|
+
});
|
|
204
|
+
exports.grpcEndpoint = grpcEndpoint;
|
|
205
|
+
/**
|
|
206
|
+
* Example: tRPC Procedure
|
|
207
|
+
*
|
|
208
|
+
* tRPC query with procedure-specific metadata.
|
|
209
|
+
*/
|
|
210
|
+
const trpcEndpoint = registry_zod_1.ApiEndpointRegistration.create({
|
|
211
|
+
id: 'trpc_customer_get_by_id',
|
|
212
|
+
path: '/trpc/customer.getById',
|
|
213
|
+
summary: 'tRPC: Get Customer by ID',
|
|
214
|
+
// tRPC-specific configuration
|
|
215
|
+
protocolConfig: {
|
|
216
|
+
subProtocol: 'trpc',
|
|
217
|
+
procedureType: 'query',
|
|
218
|
+
router: 'customer',
|
|
219
|
+
procedureName: 'getById',
|
|
220
|
+
},
|
|
221
|
+
responses: [],
|
|
222
|
+
});
|
|
223
|
+
exports.trpcEndpoint = trpcEndpoint;
|
|
224
|
+
/**
|
|
225
|
+
* Example: WebSocket Event
|
|
226
|
+
*
|
|
227
|
+
* Real-time event with WebSocket-specific metadata.
|
|
228
|
+
*/
|
|
229
|
+
const websocketEndpoint = registry_zod_1.ApiEndpointRegistration.create({
|
|
230
|
+
id: 'ws_customer_updated',
|
|
231
|
+
path: '/ws/events/customer.updated',
|
|
232
|
+
summary: 'WebSocket: Customer Updated Event',
|
|
233
|
+
// WebSocket-specific configuration
|
|
234
|
+
protocolConfig: {
|
|
235
|
+
subProtocol: 'websocket',
|
|
236
|
+
eventName: 'customer.updated',
|
|
237
|
+
direction: 'server-to-client',
|
|
238
|
+
requiresAuth: true,
|
|
239
|
+
room: 'customer_updates',
|
|
240
|
+
},
|
|
241
|
+
responses: [],
|
|
242
|
+
});
|
|
243
|
+
exports.websocketEndpoint = websocketEndpoint;
|
|
244
|
+
// ==========================================
|
|
245
|
+
// Example 4: Route Priority & Conflict Resolution
|
|
246
|
+
// ==========================================
|
|
247
|
+
/**
|
|
248
|
+
* Example: High Priority Core Endpoint
|
|
249
|
+
*
|
|
250
|
+
* Core system endpoints should have high priority (900-1000)
|
|
251
|
+
* to ensure they're registered before plugin endpoints.
|
|
252
|
+
*/
|
|
253
|
+
const coreEndpoint = registry_zod_1.ApiEndpointRegistration.create({
|
|
254
|
+
id: 'core_data_operation',
|
|
255
|
+
method: 'GET',
|
|
256
|
+
path: '/api/v1/data/:object/:id',
|
|
257
|
+
summary: 'Core data operation',
|
|
258
|
+
// High priority for core system endpoint
|
|
259
|
+
priority: 950,
|
|
260
|
+
responses: [],
|
|
261
|
+
});
|
|
262
|
+
exports.coreEndpoint = coreEndpoint;
|
|
263
|
+
/**
|
|
264
|
+
* Example: Medium Priority Plugin Endpoint
|
|
265
|
+
*
|
|
266
|
+
* Plugin endpoints should have medium priority (100-500).
|
|
267
|
+
*/
|
|
268
|
+
const pluginEndpoint = registry_zod_1.ApiEndpointRegistration.create({
|
|
269
|
+
id: 'plugin_custom_action',
|
|
270
|
+
method: 'POST',
|
|
271
|
+
path: '/api/v1/custom/action',
|
|
272
|
+
summary: 'Plugin custom action',
|
|
273
|
+
// Medium priority for plugin endpoint
|
|
274
|
+
priority: 300,
|
|
275
|
+
protocolConfig: {
|
|
276
|
+
pluginId: 'custom_actions_plugin',
|
|
277
|
+
},
|
|
278
|
+
responses: [],
|
|
279
|
+
});
|
|
280
|
+
exports.pluginEndpoint = pluginEndpoint;
|
|
281
|
+
/**
|
|
282
|
+
* Example: Low Priority Fallback Endpoint
|
|
283
|
+
*
|
|
284
|
+
* Fallback or catch-all endpoints should have low priority (0-100).
|
|
285
|
+
*/
|
|
286
|
+
const fallbackEndpoint = registry_zod_1.ApiEndpointRegistration.create({
|
|
287
|
+
id: 'fallback_handler',
|
|
288
|
+
method: 'GET',
|
|
289
|
+
path: '/api/*',
|
|
290
|
+
summary: 'Fallback handler',
|
|
291
|
+
// Low priority for fallback endpoint
|
|
292
|
+
priority: 50,
|
|
293
|
+
responses: [
|
|
294
|
+
{
|
|
295
|
+
statusCode: 404,
|
|
296
|
+
description: 'Not found',
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
});
|
|
300
|
+
exports.fallbackEndpoint = fallbackEndpoint;
|
|
301
|
+
// ==========================================
|
|
302
|
+
// Example 5: Complete Registry with Conflict Resolution
|
|
303
|
+
// ==========================================
|
|
304
|
+
/**
|
|
305
|
+
* Example: Complete Registry with Priority-based Conflict Resolution
|
|
306
|
+
*
|
|
307
|
+
* When multiple endpoints have overlapping routes, the priority field
|
|
308
|
+
* determines which endpoint wins.
|
|
309
|
+
*/
|
|
310
|
+
const completeRegistry = registry_zod_1.ApiRegistry.create({
|
|
311
|
+
version: '1.0.0',
|
|
312
|
+
// Use priority-based conflict resolution
|
|
313
|
+
conflictResolution: 'priority',
|
|
314
|
+
apis: [
|
|
315
|
+
// Core REST API (high priority endpoints)
|
|
316
|
+
registry_zod_1.ApiRegistryEntry.create({
|
|
317
|
+
id: 'core_rest_api',
|
|
318
|
+
name: 'Core REST API',
|
|
319
|
+
type: 'rest',
|
|
320
|
+
version: 'v1',
|
|
321
|
+
basePath: '/api/v1',
|
|
322
|
+
description: 'Core system REST API',
|
|
323
|
+
endpoints: [
|
|
324
|
+
coreEndpoint,
|
|
325
|
+
],
|
|
326
|
+
metadata: {
|
|
327
|
+
owner: 'platform_team',
|
|
328
|
+
status: 'active',
|
|
329
|
+
},
|
|
330
|
+
}),
|
|
331
|
+
// Plugin API (medium priority endpoints)
|
|
332
|
+
registry_zod_1.ApiRegistryEntry.create({
|
|
333
|
+
id: 'plugin_api',
|
|
334
|
+
name: 'Custom Actions Plugin API',
|
|
335
|
+
type: 'plugin',
|
|
336
|
+
version: '1.0.0',
|
|
337
|
+
basePath: '/api/v1/custom',
|
|
338
|
+
description: 'Custom actions provided by plugin',
|
|
339
|
+
endpoints: [
|
|
340
|
+
pluginEndpoint,
|
|
341
|
+
],
|
|
342
|
+
metadata: {
|
|
343
|
+
owner: 'plugin_team',
|
|
344
|
+
status: 'active',
|
|
345
|
+
pluginSource: 'custom_actions_plugin',
|
|
346
|
+
},
|
|
347
|
+
}),
|
|
348
|
+
// gRPC API
|
|
349
|
+
registry_zod_1.ApiRegistryEntry.create({
|
|
350
|
+
id: 'grpc_api',
|
|
351
|
+
name: 'gRPC API',
|
|
352
|
+
type: 'plugin',
|
|
353
|
+
version: '1.0.0',
|
|
354
|
+
basePath: '/grpc',
|
|
355
|
+
description: 'gRPC services',
|
|
356
|
+
endpoints: [
|
|
357
|
+
grpcEndpoint,
|
|
358
|
+
],
|
|
359
|
+
config: {
|
|
360
|
+
grpcVersion: '1.0.0',
|
|
361
|
+
reflection: true,
|
|
362
|
+
},
|
|
363
|
+
metadata: {
|
|
364
|
+
status: 'beta',
|
|
365
|
+
},
|
|
366
|
+
}),
|
|
367
|
+
],
|
|
368
|
+
totalApis: 3,
|
|
369
|
+
totalEndpoints: 3,
|
|
370
|
+
});
|
|
371
|
+
exports.completeRegistry = completeRegistry;
|
|
372
|
+
// ==========================================
|
|
373
|
+
// Example 6: Complete Endpoint with All Features
|
|
374
|
+
// ==========================================
|
|
375
|
+
/**
|
|
376
|
+
* Example: Production-ready Endpoint with All Enhancements
|
|
377
|
+
*
|
|
378
|
+
* This example combines all four enhancements:
|
|
379
|
+
* - RBAC permissions
|
|
380
|
+
* - Dynamic schema linking
|
|
381
|
+
* - Protocol configuration
|
|
382
|
+
* - Route priority
|
|
383
|
+
*/
|
|
384
|
+
const productionEndpoint = registry_zod_1.ApiEndpointRegistration.create({
|
|
385
|
+
id: 'get_customer_full_featured',
|
|
386
|
+
method: 'GET',
|
|
387
|
+
path: '/api/v1/customers/:id',
|
|
388
|
+
summary: 'Get customer by ID (full-featured)',
|
|
389
|
+
description: 'Production-ready endpoint with all enhancements',
|
|
390
|
+
operationId: 'getCustomerById',
|
|
391
|
+
tags: ['customer', 'crm', 'public'],
|
|
392
|
+
// 1. RBAC Integration
|
|
393
|
+
requiredPermissions: ['customer.read'],
|
|
394
|
+
// 2. Route Priority
|
|
395
|
+
priority: 500,
|
|
396
|
+
// 3. Protocol Configuration
|
|
397
|
+
protocolConfig: {
|
|
398
|
+
cacheEnabled: true,
|
|
399
|
+
cacheTtl: 300, // 5 minutes
|
|
400
|
+
rateLimitPerMinute: 100,
|
|
401
|
+
},
|
|
402
|
+
// Standard OpenAPI security (in addition to RBAC)
|
|
403
|
+
security: [
|
|
404
|
+
{
|
|
405
|
+
type: 'http',
|
|
406
|
+
scheme: 'bearer',
|
|
407
|
+
},
|
|
408
|
+
],
|
|
409
|
+
parameters: [
|
|
410
|
+
{
|
|
411
|
+
name: 'id',
|
|
412
|
+
in: 'path',
|
|
413
|
+
description: 'Customer ID',
|
|
414
|
+
required: true,
|
|
415
|
+
schema: {
|
|
416
|
+
type: 'string',
|
|
417
|
+
format: 'uuid',
|
|
418
|
+
},
|
|
419
|
+
example: '123e4567-e89b-12d3-a456-426614174000',
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
name: 'include',
|
|
423
|
+
in: 'query',
|
|
424
|
+
description: 'Related objects to include',
|
|
425
|
+
required: false,
|
|
426
|
+
schema: {
|
|
427
|
+
type: 'array',
|
|
428
|
+
items: { type: 'string' },
|
|
429
|
+
enum: ['orders', 'contacts', 'activities'],
|
|
430
|
+
},
|
|
431
|
+
},
|
|
432
|
+
],
|
|
433
|
+
// 4. Dynamic Schema Linking
|
|
434
|
+
responses: [
|
|
435
|
+
{
|
|
436
|
+
statusCode: 200,
|
|
437
|
+
description: 'Customer found',
|
|
438
|
+
schema: {
|
|
439
|
+
$ref: {
|
|
440
|
+
objectId: 'customer',
|
|
441
|
+
excludeFields: ['password_hash', 'internal_notes'],
|
|
442
|
+
includeRelated: ['account'],
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
example: {
|
|
446
|
+
id: '123e4567-e89b-12d3-a456-426614174000',
|
|
447
|
+
name: 'Acme Corporation',
|
|
448
|
+
email: 'contact@acme.com',
|
|
449
|
+
phone: '+1-555-0100',
|
|
450
|
+
account: {
|
|
451
|
+
id: 'acc-001',
|
|
452
|
+
name: 'Acme Account',
|
|
453
|
+
},
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
statusCode: 404,
|
|
458
|
+
description: 'Customer not found',
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
statusCode: 403,
|
|
462
|
+
description: 'Permission denied',
|
|
463
|
+
},
|
|
464
|
+
],
|
|
465
|
+
externalDocs: {
|
|
466
|
+
description: 'Customer API Documentation',
|
|
467
|
+
url: 'https://docs.objectstack.ai/api/customers',
|
|
468
|
+
},
|
|
469
|
+
});
|
|
470
|
+
exports.productionEndpoint = productionEndpoint;
|