@meshery/schemas 0.8.106 → 0.8.108
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 +294 -23
- package/dist/Core-Wy_3jcVT.d.mts +736 -0
- package/dist/Core-Wy_3jcVT.d.ts +736 -0
- package/dist/cloudApi.d.mts +6882 -3601
- package/dist/cloudApi.d.ts +6882 -3601
- package/dist/cloudApi.js +1 -1
- package/dist/cloudApi.mjs +1 -1
- package/dist/constructs/v1alpha1/capability/Capability.d.mts +115 -0
- package/dist/constructs/v1alpha1/capability/Capability.d.ts +115 -0
- package/dist/constructs/v1alpha1/capability/Capability.js +1 -0
- package/dist/constructs/v1alpha1/capability/Capability.mjs +0 -0
- package/dist/constructs/v1alpha1/capability/CapabilitySchema.d.mts +155 -0
- package/dist/constructs/v1alpha1/capability/CapabilitySchema.d.ts +155 -0
- package/dist/constructs/v1alpha1/capability/CapabilitySchema.js +2 -0
- package/dist/constructs/v1alpha1/capability/CapabilitySchema.mjs +2 -0
- package/dist/constructs/v1alpha1/core/Core.d.mts +1 -0
- package/dist/constructs/v1alpha1/core/Core.d.ts +1 -0
- package/dist/constructs/v1alpha1/core/Core.js +1 -0
- package/dist/constructs/v1alpha1/core/Core.mjs +0 -0
- package/dist/constructs/v1alpha1/core/CoreSchema.d.mts +1649 -0
- package/dist/constructs/v1alpha1/core/CoreSchema.d.ts +1649 -0
- package/dist/constructs/v1alpha1/core/CoreSchema.js +2 -0
- package/dist/constructs/v1alpha1/core/CoreSchema.mjs +2 -0
- package/dist/constructs/v1alpha2/catalog/Catalog.d.mts +46 -0
- package/dist/constructs/v1alpha2/catalog/Catalog.d.ts +46 -0
- package/dist/constructs/v1alpha2/catalog/Catalog.js +1 -0
- package/dist/constructs/v1alpha2/catalog/Catalog.mjs +0 -0
- package/dist/constructs/v1alpha2/catalog/CatalogSchema.d.mts +80 -0
- package/dist/constructs/v1alpha2/catalog/CatalogSchema.d.ts +80 -0
- package/dist/constructs/v1alpha2/catalog/CatalogSchema.js +2 -0
- package/dist/constructs/v1alpha2/catalog/CatalogSchema.mjs +2 -0
- package/dist/constructs/v1beta1/academy/Academy.d.mts +5762 -0
- package/dist/constructs/v1beta1/academy/Academy.d.ts +5762 -0
- package/dist/constructs/v1beta1/academy/Academy.js +1 -0
- package/dist/constructs/v1beta1/academy/Academy.mjs +0 -0
- package/dist/constructs/v1beta1/academy/AcademySchema.d.mts +11838 -0
- package/dist/constructs/v1beta1/academy/AcademySchema.d.ts +11838 -0
- package/dist/constructs/v1beta1/academy/AcademySchema.js +2 -0
- package/dist/constructs/v1beta1/academy/AcademySchema.mjs +2 -0
- package/dist/constructs/v1beta1/badge/Badge.d.mts +253 -0
- package/dist/constructs/v1beta1/badge/Badge.d.ts +253 -0
- package/dist/constructs/v1beta1/badge/Badge.js +1 -0
- package/dist/constructs/v1beta1/badge/Badge.mjs +0 -0
- package/dist/constructs/v1beta1/badge/BadgeSchema.d.mts +519 -0
- package/dist/constructs/v1beta1/badge/BadgeSchema.d.ts +519 -0
- package/dist/constructs/v1beta1/badge/BadgeSchema.js +2 -0
- package/dist/constructs/v1beta1/badge/BadgeSchema.mjs +2 -0
- package/dist/constructs/v1beta1/category/Category.d.mts +33 -0
- package/dist/constructs/v1beta1/category/Category.d.ts +33 -0
- package/dist/constructs/v1beta1/category/Category.js +1 -0
- package/dist/constructs/v1beta1/category/Category.mjs +0 -0
- package/dist/constructs/v1beta1/category/CategorySchema.d.mts +60 -0
- package/dist/constructs/v1beta1/category/CategorySchema.d.ts +60 -0
- package/dist/constructs/v1beta1/category/CategorySchema.js +2 -0
- package/dist/constructs/v1beta1/category/CategorySchema.mjs +2 -0
- package/dist/constructs/v1beta1/component/Component.d.mts +737 -0
- package/dist/constructs/v1beta1/component/Component.d.ts +737 -0
- package/dist/constructs/v1beta1/component/Component.js +1 -0
- package/dist/constructs/v1beta1/component/Component.mjs +0 -0
- package/dist/constructs/v1beta1/component/ComponentSchema.d.mts +1751 -0
- package/dist/constructs/v1beta1/component/ComponentSchema.d.ts +1751 -0
- package/dist/constructs/v1beta1/component/ComponentSchema.js +10 -0
- package/dist/constructs/v1beta1/component/ComponentSchema.mjs +10 -0
- package/dist/constructs/v1beta1/connection/Connection.d.mts +186 -0
- package/dist/constructs/v1beta1/connection/Connection.d.ts +186 -0
- package/dist/constructs/v1beta1/connection/Connection.js +1 -0
- package/dist/constructs/v1beta1/connection/Connection.mjs +0 -0
- package/dist/constructs/v1beta1/connection/ConnectionSchema.d.mts +612 -0
- package/dist/constructs/v1beta1/connection/ConnectionSchema.d.ts +612 -0
- package/dist/constructs/v1beta1/connection/ConnectionSchema.js +2 -0
- package/dist/constructs/v1beta1/connection/ConnectionSchema.mjs +2 -0
- package/dist/constructs/v1beta1/environment/Environment.d.mts +307 -0
- package/dist/constructs/v1beta1/environment/Environment.d.ts +307 -0
- package/dist/constructs/v1beta1/environment/Environment.js +1 -0
- package/dist/constructs/v1beta1/environment/Environment.mjs +0 -0
- package/dist/constructs/v1beta1/environment/EnvironmentSchema.d.mts +904 -0
- package/dist/constructs/v1beta1/environment/EnvironmentSchema.d.ts +904 -0
- package/dist/constructs/v1beta1/environment/EnvironmentSchema.js +2 -0
- package/dist/constructs/v1beta1/environment/EnvironmentSchema.mjs +2 -0
- package/dist/constructs/v1beta1/evaluation/Evaluation.d.mts +5729 -0
- package/dist/constructs/v1beta1/evaluation/Evaluation.d.ts +5729 -0
- package/dist/constructs/v1beta1/evaluation/Evaluation.js +1 -0
- package/dist/constructs/v1beta1/evaluation/Evaluation.mjs +0 -0
- package/dist/constructs/v1beta1/evaluation/EvaluationSchema.d.mts +15473 -0
- package/dist/constructs/v1beta1/evaluation/EvaluationSchema.d.ts +15473 -0
- package/dist/constructs/v1beta1/evaluation/EvaluationSchema.js +210 -0
- package/dist/constructs/v1beta1/evaluation/EvaluationSchema.mjs +210 -0
- package/dist/constructs/v1beta1/event/Event.d.mts +177 -0
- package/dist/constructs/v1beta1/event/Event.d.ts +177 -0
- package/dist/constructs/v1beta1/event/Event.js +1 -0
- package/dist/constructs/v1beta1/event/Event.mjs +0 -0
- package/dist/constructs/v1beta1/event/EventSchema.d.mts +360 -0
- package/dist/constructs/v1beta1/event/EventSchema.d.ts +360 -0
- package/dist/constructs/v1beta1/event/EventSchema.js +1 -0
- package/dist/constructs/v1beta1/event/EventSchema.mjs +1 -0
- package/dist/constructs/v1beta1/feature/Feature.d.mts +287 -0
- package/dist/constructs/v1beta1/feature/Feature.d.ts +287 -0
- package/dist/constructs/v1beta1/feature/Feature.js +1 -0
- package/dist/constructs/v1beta1/feature/Feature.mjs +0 -0
- package/dist/constructs/v1beta1/feature/FeatureSchema.d.mts +773 -0
- package/dist/constructs/v1beta1/feature/FeatureSchema.d.ts +773 -0
- package/dist/constructs/v1beta1/feature/FeatureSchema.js +1 -0
- package/dist/constructs/v1beta1/feature/FeatureSchema.mjs +1 -0
- package/dist/constructs/v1beta1/invitation/Invitation.d.mts +644 -0
- package/dist/constructs/v1beta1/invitation/Invitation.d.ts +644 -0
- package/dist/constructs/v1beta1/invitation/Invitation.js +1 -0
- package/dist/constructs/v1beta1/invitation/Invitation.mjs +0 -0
- package/dist/constructs/v1beta1/invitation/InvitationSchema.d.mts +1652 -0
- package/dist/constructs/v1beta1/invitation/InvitationSchema.d.ts +1652 -0
- package/dist/constructs/v1beta1/invitation/InvitationSchema.js +1 -0
- package/dist/constructs/v1beta1/invitation/InvitationSchema.mjs +1 -0
- package/dist/constructs/v1beta1/key/Key.d.mts +409 -0
- package/dist/constructs/v1beta1/key/Key.d.ts +409 -0
- package/dist/constructs/v1beta1/key/Key.js +1 -0
- package/dist/constructs/v1beta1/key/Key.mjs +0 -0
- package/dist/constructs/v1beta1/key/KeySchema.d.mts +1029 -0
- package/dist/constructs/v1beta1/key/KeySchema.d.ts +1029 -0
- package/dist/constructs/v1beta1/key/KeySchema.js +1 -0
- package/dist/constructs/v1beta1/key/KeySchema.mjs +1 -0
- package/dist/constructs/v1beta1/keychain/Keychain.d.mts +641 -0
- package/dist/constructs/v1beta1/keychain/Keychain.d.ts +641 -0
- package/dist/constructs/v1beta1/keychain/Keychain.js +1 -0
- package/dist/constructs/v1beta1/keychain/Keychain.mjs +0 -0
- package/dist/constructs/v1beta1/keychain/KeychainSchema.d.mts +1541 -0
- package/dist/constructs/v1beta1/keychain/KeychainSchema.d.ts +1541 -0
- package/dist/constructs/v1beta1/keychain/KeychainSchema.js +1 -0
- package/dist/constructs/v1beta1/keychain/KeychainSchema.mjs +1 -0
- package/dist/constructs/v1beta1/model/Model.d.mts +474 -0
- package/dist/constructs/v1beta1/model/Model.d.ts +474 -0
- package/dist/constructs/v1beta1/model/Model.js +1 -0
- package/dist/constructs/v1beta1/model/Model.mjs +0 -0
- package/dist/constructs/v1beta1/model/ModelSchema.d.mts +1281 -0
- package/dist/constructs/v1beta1/model/ModelSchema.d.ts +1281 -0
- package/dist/constructs/v1beta1/model/ModelSchema.js +6 -0
- package/dist/constructs/v1beta1/model/ModelSchema.mjs +6 -0
- package/dist/constructs/v1beta1/organization/Organization.d.mts +268 -0
- package/dist/constructs/v1beta1/organization/Organization.d.ts +268 -0
- package/dist/constructs/v1beta1/organization/Organization.js +1 -0
- package/dist/constructs/v1beta1/organization/Organization.mjs +0 -0
- package/dist/constructs/v1beta1/organization/OrganizationSchema.d.mts +765 -0
- package/dist/constructs/v1beta1/organization/OrganizationSchema.d.ts +765 -0
- package/dist/constructs/v1beta1/organization/OrganizationSchema.js +1 -0
- package/dist/constructs/v1beta1/organization/OrganizationSchema.mjs +1 -0
- package/dist/constructs/v1beta1/pattern/Pattern.d.mts +5776 -0
- package/dist/constructs/v1beta1/pattern/Pattern.d.ts +5776 -0
- package/dist/constructs/v1beta1/pattern/Pattern.js +1 -0
- package/dist/constructs/v1beta1/pattern/Pattern.mjs +0 -0
- package/dist/constructs/v1beta1/pattern/PatternSchema.d.mts +15669 -0
- package/dist/constructs/v1beta1/pattern/PatternSchema.d.ts +15669 -0
- package/dist/constructs/v1beta1/pattern/PatternSchema.js +210 -0
- package/dist/constructs/v1beta1/pattern/PatternSchema.mjs +210 -0
- package/dist/constructs/v1beta1/plan/Plan.d.mts +120 -0
- package/dist/constructs/v1beta1/plan/Plan.d.ts +120 -0
- package/dist/constructs/v1beta1/plan/Plan.js +1 -0
- package/dist/constructs/v1beta1/plan/Plan.mjs +0 -0
- package/dist/constructs/v1beta1/plan/PlanSchema.d.mts +322 -0
- package/dist/constructs/v1beta1/plan/PlanSchema.d.ts +322 -0
- package/dist/constructs/v1beta1/plan/PlanSchema.js +1 -0
- package/dist/constructs/v1beta1/plan/PlanSchema.mjs +1 -0
- package/dist/constructs/v1beta1/subcategory/Subcategory.d.mts +23 -0
- package/dist/constructs/v1beta1/subcategory/Subcategory.d.ts +23 -0
- package/dist/constructs/v1beta1/subcategory/Subcategory.js +1 -0
- package/dist/constructs/v1beta1/subcategory/Subcategory.mjs +0 -0
- package/dist/constructs/v1beta1/subcategory/SubcategorySchema.d.mts +33 -0
- package/dist/constructs/v1beta1/subcategory/SubcategorySchema.d.ts +33 -0
- package/dist/constructs/v1beta1/subcategory/SubcategorySchema.js +2 -0
- package/dist/constructs/v1beta1/subcategory/SubcategorySchema.mjs +2 -0
- package/dist/constructs/v1beta1/subscription/Subscription.d.mts +624 -0
- package/dist/constructs/v1beta1/subscription/Subscription.d.ts +624 -0
- package/dist/constructs/v1beta1/subscription/Subscription.js +1 -0
- package/dist/constructs/v1beta1/subscription/Subscription.mjs +0 -0
- package/dist/constructs/v1beta1/subscription/SubscriptionSchema.d.mts +1642 -0
- package/dist/constructs/v1beta1/subscription/SubscriptionSchema.d.ts +1642 -0
- package/dist/constructs/v1beta1/subscription/SubscriptionSchema.js +2 -0
- package/dist/constructs/v1beta1/subscription/SubscriptionSchema.mjs +2 -0
- package/dist/constructs/v1beta1/user/User.d.mts +473 -0
- package/dist/constructs/v1beta1/user/User.d.ts +473 -0
- package/dist/constructs/v1beta1/user/User.js +1 -0
- package/dist/constructs/v1beta1/user/User.mjs +0 -0
- package/dist/constructs/v1beta1/user/UserSchema.d.mts +1112 -0
- package/dist/constructs/v1beta1/user/UserSchema.d.ts +1112 -0
- package/dist/constructs/v1beta1/user/UserSchema.js +1 -0
- package/dist/constructs/v1beta1/user/UserSchema.mjs +1 -0
- package/dist/constructs/v1beta1/workspace/Workspace.d.mts +303 -0
- package/dist/constructs/v1beta1/workspace/Workspace.d.ts +303 -0
- package/dist/constructs/v1beta1/workspace/Workspace.js +1 -0
- package/dist/constructs/v1beta1/workspace/Workspace.mjs +0 -0
- package/dist/constructs/v1beta1/workspace/WorkspaceSchema.d.mts +964 -0
- package/dist/constructs/v1beta1/workspace/WorkspaceSchema.d.ts +964 -0
- package/dist/constructs/v1beta1/workspace/WorkspaceSchema.js +2 -0
- package/dist/constructs/v1beta1/workspace/WorkspaceSchema.mjs +2 -0
- package/dist/index.d.mts +40 -34677
- package/dist/index.d.ts +40 -34677
- package/dist/index.js +29 -93
- package/dist/index.mjs +29 -93
- package/dist/mesheryApi.d.mts +1825 -727
- package/dist/mesheryApi.d.ts +1825 -727
- package/dist/mesheryApi.js +1 -1
- package/dist/mesheryApi.mjs +1 -1
- package/dist/permissions.d.mts +422 -0
- package/dist/permissions.d.ts +422 -0
- package/dist/permissions.js +1 -0
- package/dist/permissions.mjs +1 -0
- package/package.json +52 -48
package/README.md
CHANGED
|
@@ -124,10 +124,35 @@ schemas/
|
|
|
124
124
|
constructs/
|
|
125
125
|
<schema-version>/ # e.g., v1beta1
|
|
126
126
|
<construct>/ # e.g., model, component
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
<
|
|
130
|
-
|
|
127
|
+
api.yml # Index file: references all subschemas + defines API endpoints
|
|
128
|
+
<construct>.yaml # Subschema: data model definition for the construct
|
|
129
|
+
<other_subschema>.yaml # Additional subschemas (optional)
|
|
130
|
+
templates/ # Manually defined templates directory
|
|
131
|
+
<construct>_template.json # JSON template from schema
|
|
132
|
+
<construct>_template.yaml # YAML template from schema
|
|
133
|
+
<variant>_template.json # Additional variant templates (optional)
|
|
134
|
+
|
|
135
|
+
typescript/ # TypeScript source and generated files
|
|
136
|
+
index.ts # Manually maintained - public API surface
|
|
137
|
+
generated/ # Auto-generated (do NOT commit)
|
|
138
|
+
<schema-version>/
|
|
139
|
+
<construct>/
|
|
140
|
+
<Construct>.d.ts # TypeScript type definitions
|
|
141
|
+
<Construct>Schema.ts # OpenAPI schema as JS object
|
|
142
|
+
rtk/ # RTK Query client configurations
|
|
143
|
+
cloud.ts
|
|
144
|
+
meshery.ts
|
|
145
|
+
|
|
146
|
+
dist/ # Built distribution (do NOT commit)
|
|
147
|
+
index.js, index.d.ts
|
|
148
|
+
cloudApi.js, mesheryApi.js
|
|
149
|
+
constructs/ # Built schema exports (renamed from 'generated')
|
|
150
|
+
<schema-version>/<construct>/<Construct>Schema.js
|
|
151
|
+
|
|
152
|
+
models/ # Auto-generated Go code (do NOT commit)
|
|
153
|
+
<schema-version>/
|
|
154
|
+
<construct>/
|
|
155
|
+
<construct>.go
|
|
131
156
|
```
|
|
132
157
|
|
|
133
158
|
### 🧠 Explanation
|
|
@@ -135,9 +160,203 @@ schemas/
|
|
|
135
160
|
* **`constructs/`** – Holds schemas for various versions.
|
|
136
161
|
* **`<schema-version>/`** – Represents a version (e.g., `v1alpha2`, `v1beta1`).
|
|
137
162
|
* **`<construct>/`** – A directory to contain all files for any given construct like `pattern`, `component`, etc.
|
|
138
|
-
*
|
|
139
|
-
|
|
140
|
-
|
|
163
|
+
* **`api.yml`** – The **index file** for the construct. This file:
|
|
164
|
+
1. References all subschemas (via `$ref`) to bundle them together
|
|
165
|
+
2. Defines all **API endpoints** (REST operations: GET, POST, PUT, DELETE) for the construct
|
|
166
|
+
3. Serves as the entry point for code generation tools (oapi-codegen, openapi-typescript)
|
|
167
|
+
* **`<construct>.yaml`** – A **subschema** that defines the data model (noun) for the construct. Contains the schema properties, types, and validation rules.
|
|
168
|
+
* **Other `.yaml` files** – Additional subschemas can be defined in separate files (e.g., `model_core.yml`, `component_metadata.yml`) and referenced from `api.yml`.
|
|
169
|
+
* **`templates/`** – A subdirectory containing manually defined template files. You can add as many different templates here for different variants, use cases, or configurations. Templates are example instances of the schema with default or sample values.
|
|
170
|
+
* `<construct>_template.json` / `<construct>_template.yaml` – Default templates in JSON/YAML format.
|
|
171
|
+
* Additional variant templates can be added (e.g., `<construct>_minimal_template.json`, `<construct>_full_template.yaml`) for different use cases.
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Naming Conventions
|
|
176
|
+
|
|
177
|
+
- Property names
|
|
178
|
+
- Use camelCase for property fields (e.g., `schemaVersion`, `displayName`, `componentsCount`).
|
|
179
|
+
- Identifier fields use lowerCamelCase with "Id" suffix (e.g., `modelId`, `registrantId`, `categoryId`).
|
|
180
|
+
- Enums use lowercase words (e.g., `enabled`, `ignored`, `duplicate`).
|
|
181
|
+
- Use singular nouns for object names (e.g., `model`, `component`, `design`).
|
|
182
|
+
|
|
183
|
+
- OpenAPI schema names
|
|
184
|
+
- PascalCase nouns under `components/schemas` (e.g., `Model`, `Component`).
|
|
185
|
+
- Files/folders are lowercase: `api.yml` (index), `<construct>.yaml` (subschemas), `templates/<construct>_template.(json|yaml)`.
|
|
186
|
+
|
|
187
|
+
- Endpoints and operations
|
|
188
|
+
- Paths are under `/api` with kebab-case , plural nouns (e.g., `/api/workspaces`, `/api/environments`).
|
|
189
|
+
- Path params are camelCase (e.g., `{subscriptionId}`, `{connectionId}`).
|
|
190
|
+
- Non-CRUD actions append a verb segment (e.g., `.../register`, `.../export`, `.../cancel`); legacy lowerCamelCase may appear (e.g., `.../upgradePreview`).
|
|
191
|
+
- `operationId` is camelCase VerbNoun (e.g., `registerMeshmodels`).
|
|
192
|
+
|
|
193
|
+
- Versioning
|
|
194
|
+
- `schemaVersion` uses group/version (e.g., `models.meshery.io/v1beta1`, `components.meshery.io/v1beta1`).
|
|
195
|
+
- Version strings follow k8s-style (`v1`, `v1alpha1`, `v1beta1`); semver fields use standard SemVer.
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## 🔧 Go Helper Files
|
|
200
|
+
|
|
201
|
+
While Go structs are auto-generated from schemas, you often need to add **custom methods** to make these structs compatible with databases, implement interfaces, or add utility functions. This is done through manually created **helper files**.
|
|
202
|
+
|
|
203
|
+
### When to Create Helper Files
|
|
204
|
+
|
|
205
|
+
Create a helper file (`*_helper.go` or `helpers.go`) in the generated package when you need:
|
|
206
|
+
|
|
207
|
+
1. **SQL Driver Compatibility** - Implement `database/sql/driver.Scanner` and `driver.Valuer` interfaces
|
|
208
|
+
2. **Entity Interface Implementation** - Implement the `entity.Entity` interface for database operations
|
|
209
|
+
3. **GORM Table Names** - Define custom table names via `TableName()` method
|
|
210
|
+
4. **Utility Methods** - Add helper functions for serialization, validation, or business logic
|
|
211
|
+
5. **Type Conversions** - Add methods to convert between related types
|
|
212
|
+
|
|
213
|
+
### Helper File Location
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
models/
|
|
217
|
+
├── core/
|
|
218
|
+
│ ├── core.go # Auto-generated (do NOT edit)
|
|
219
|
+
│ ├── helpers.go # Manual: utility functions
|
|
220
|
+
│ ├── datatype_map.go # Manual: Map type with SQL driver methods
|
|
221
|
+
│ └── datatype_null_time.go # Manual: NullTime with SQL driver methods
|
|
222
|
+
├── v1beta1/
|
|
223
|
+
│ ├── model/
|
|
224
|
+
│ │ ├── model.go # Auto-generated (do NOT edit)
|
|
225
|
+
│ │ └── model_helper.go # Manual: Entity interface, TableName, etc.
|
|
226
|
+
│ ├── component/
|
|
227
|
+
│ │ ├── component.go # Auto-generated (do NOT edit)
|
|
228
|
+
│ │ └── component_helper.go # Manual: Entity interface, TableName, etc.
|
|
229
|
+
│ └── category/
|
|
230
|
+
│ ├── category.go # Auto-generated (do NOT edit)
|
|
231
|
+
│ └── category_helper.go # Manual: Entity interface, TableName, etc.
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### SQL Driver Interface Implementation
|
|
235
|
+
|
|
236
|
+
To store complex types in SQL databases, implement `Scan` and `Value` methods:
|
|
237
|
+
|
|
238
|
+
```go
|
|
239
|
+
// helpers.go - This is NOT autogenerated
|
|
240
|
+
package mypackage
|
|
241
|
+
|
|
242
|
+
import (
|
|
243
|
+
"database/sql/driver"
|
|
244
|
+
"encoding/json"
|
|
245
|
+
|
|
246
|
+
"github.com/meshery/schemas/models/core"
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
// Scan implements sql.Scanner interface for reading from database
|
|
250
|
+
func (m *MyComplexType) Scan(value interface{}) error {
|
|
251
|
+
mapVal := core.Map{}
|
|
252
|
+
err := mapVal.Scan(value)
|
|
253
|
+
if err != nil {
|
|
254
|
+
return err
|
|
255
|
+
}
|
|
256
|
+
return core.MapToStruct(mapVal, m)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Value implements driver.Valuer interface for writing to database
|
|
260
|
+
func (m MyComplexType) Value() (driver.Value, error) {
|
|
261
|
+
mapVal, err := core.StructToMap(m)
|
|
262
|
+
if err != nil {
|
|
263
|
+
return nil, err
|
|
264
|
+
}
|
|
265
|
+
return core.Map(mapVal).Value()
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Entity Interface Implementation
|
|
270
|
+
|
|
271
|
+
For structs that need database CRUD operations, implement the `entity.Entity` interface:
|
|
272
|
+
|
|
273
|
+
```go
|
|
274
|
+
// component_helper.go - This is NOT autogenerated
|
|
275
|
+
package component
|
|
276
|
+
|
|
277
|
+
import (
|
|
278
|
+
"fmt"
|
|
279
|
+
|
|
280
|
+
"github.com/gofrs/uuid"
|
|
281
|
+
"github.com/meshery/meshkit/database"
|
|
282
|
+
"github.com/meshery/meshkit/models/meshmodel/entity"
|
|
283
|
+
"gorm.io/gorm/clause"
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
// TableName returns the database table name for GORM
|
|
287
|
+
func (c ComponentDefinition) TableName() string {
|
|
288
|
+
return "component_definition_dbs"
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// Type returns the entity type identifier
|
|
292
|
+
func (c ComponentDefinition) Type() entity.EntityType {
|
|
293
|
+
return entity.ComponentDefinition
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// GenerateID generates a new UUID for the entity
|
|
297
|
+
func (c *ComponentDefinition) GenerateID() (uuid.UUID, error) {
|
|
298
|
+
return uuid.NewV4()
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// GetID returns the entity's ID
|
|
302
|
+
func (c ComponentDefinition) GetID() uuid.UUID {
|
|
303
|
+
return c.Id
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// GetEntityDetail returns a human-readable description
|
|
307
|
+
func (c *ComponentDefinition) GetEntityDetail() string {
|
|
308
|
+
return fmt.Sprintf("type: %s, name: %s, model: %s",
|
|
309
|
+
c.Type(), c.DisplayName, c.Model.Name)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// Create inserts the entity into the database
|
|
313
|
+
func (c *ComponentDefinition) Create(db *database.Handler, hostID uuid.UUID) (uuid.UUID, error) {
|
|
314
|
+
c.Id, _ = c.GenerateID()
|
|
315
|
+
err := db.Omit(clause.Associations).Create(&c).Error
|
|
316
|
+
return c.Id, err
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// UpdateStatus updates the entity's status in the database
|
|
320
|
+
func (c *ComponentDefinition) UpdateStatus(db *database.Handler, status entity.EntityStatus) error {
|
|
321
|
+
return nil
|
|
322
|
+
}
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### Core Utility Types
|
|
326
|
+
|
|
327
|
+
The `models/core/` package provides reusable types with built-in SQL compatibility:
|
|
328
|
+
|
|
329
|
+
| Type | Purpose | Use Case |
|
|
330
|
+
|------|---------|----------|
|
|
331
|
+
| `core.Map` | `map[string]any` with SQL support | Storing JSON objects in database |
|
|
332
|
+
| `core.NullTime` | Nullable time with JSON/YAML support | Optional timestamp fields |
|
|
333
|
+
| `core.Time` | Time wrapper with custom formatting | Required timestamp fields |
|
|
334
|
+
|
|
335
|
+
### Example: Using Core Types
|
|
336
|
+
|
|
337
|
+
```go
|
|
338
|
+
// In your helper file
|
|
339
|
+
package mypackage
|
|
340
|
+
|
|
341
|
+
import "github.com/meshery/schemas/models/core"
|
|
342
|
+
|
|
343
|
+
// For nullable timestamps (e.g., deleted_at)
|
|
344
|
+
type MyStruct struct {
|
|
345
|
+
DeletedAt core.NullTime `json:"deleted_at" gorm:"column:deleted_at"`
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// For JSON metadata stored as blob
|
|
349
|
+
type MyStruct struct {
|
|
350
|
+
Metadata core.Map `json:"metadata" gorm:"type:bytes;serializer:json"`
|
|
351
|
+
}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Important Notes
|
|
355
|
+
|
|
356
|
+
1. **File Header Comment**: Always add `// This is not autogenerated.` at the top of helper files
|
|
357
|
+
2. **Same Package**: Helper files must be in the same package as the generated code
|
|
358
|
+
3. **Do Commit Helper Files**: Unlike generated `.go` files, helper files ARE committed to the repository
|
|
359
|
+
4. **Mutex for Creation**: Use sync.Mutex when implementing `Create()` to prevent race conditions
|
|
141
360
|
|
|
142
361
|
---
|
|
143
362
|
|
|
@@ -145,11 +364,41 @@ schemas/
|
|
|
145
364
|
|
|
146
365
|
Meshery supports **automated code generation** from schemas for:
|
|
147
366
|
|
|
148
|
-
* **Go**: Strongly-typed models for backend
|
|
149
|
-
* **TypeScript**: Interfaces and
|
|
150
|
-
* **
|
|
367
|
+
* **Go**: Strongly-typed models for backend → `models/<version>/<package>/`
|
|
368
|
+
* **TypeScript Types**: Interfaces and type definitions → `typescript/generated/<version>/<package>/<Package>.d.ts`
|
|
369
|
+
* **TypeScript Schemas**: OpenAPI schemas as const JS objects → `typescript/generated/<version>/<package>/<Package>Schema.ts`
|
|
370
|
+
* **RTK Query**: Clients generated from OpenAPI for use with Redux → `typescript/rtk/`
|
|
151
371
|
* **JSON/YAML**: Templates with defaults and resolved references.
|
|
152
372
|
|
|
373
|
+
### TypeScript Schema Exports
|
|
374
|
+
|
|
375
|
+
Each construct's OpenAPI schema is exported as a const JavaScript object for runtime use:
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
// Import from main index
|
|
379
|
+
import {
|
|
380
|
+
ModelDefinitionV1Beta1OpenApiSchema,
|
|
381
|
+
ComponentDefinitionV1Beta1OpenApiSchema,
|
|
382
|
+
DesignDefinitionV1Beta1OpenApiSchema,
|
|
383
|
+
} from "@meshery/schemas";
|
|
384
|
+
|
|
385
|
+
// Or import individual schemas directly
|
|
386
|
+
import ModelSchema from "@meshery/schemas/dist/constructs/v1beta1/model/ModelSchema";
|
|
387
|
+
import ComponentSchema from "@meshery/schemas/dist/constructs/v1beta1/component/ComponentSchema";
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### TypeScript Type Namespaces
|
|
391
|
+
|
|
392
|
+
Types are organized by version in namespaces:
|
|
393
|
+
|
|
394
|
+
```typescript
|
|
395
|
+
import { v1beta1, v1alpha1 } from "@meshery/schemas";
|
|
396
|
+
|
|
397
|
+
const component: v1beta1.Component = { /* ... */ };
|
|
398
|
+
const model: v1beta1.Model = { /* ... */ };
|
|
399
|
+
const design: v1beta1.Design = { /* ... */ };
|
|
400
|
+
```
|
|
401
|
+
|
|
153
402
|
---
|
|
154
403
|
|
|
155
404
|
## 🚀 Unified Build: One Command for Everything
|
|
@@ -158,6 +407,7 @@ Use the following command to perform the **entire schema-driven generation workf
|
|
|
158
407
|
|
|
159
408
|
```bash
|
|
160
409
|
make build
|
|
410
|
+
npm run build # Build TypeScript distribution with tsup
|
|
161
411
|
```
|
|
162
412
|
|
|
163
413
|
### 🔧 What `make build` does:
|
|
@@ -170,10 +420,16 @@ make build
|
|
|
170
420
|
|
|
171
421
|
2. **Generates:**
|
|
172
422
|
|
|
173
|
-
* Golang structs
|
|
174
|
-
* TypeScript
|
|
175
|
-
*
|
|
176
|
-
* RTK Query clients
|
|
423
|
+
* Golang structs → `models/`
|
|
424
|
+
* TypeScript type definitions (`.d.ts`) → `typescript/generated/`
|
|
425
|
+
* TypeScript schema exports (`*Schema.ts`) → `typescript/generated/`
|
|
426
|
+
* RTK Query clients → `typescript/rtk/`
|
|
427
|
+
|
|
428
|
+
3. **After `npm run build`:**
|
|
429
|
+
|
|
430
|
+
* Builds distribution files → `dist/`
|
|
431
|
+
* Creates CJS and ESM bundles
|
|
432
|
+
* Generates declaration files
|
|
177
433
|
|
|
178
434
|
> ⚠️ This is the recommended way to stay in sync with schema changes.
|
|
179
435
|
|
|
@@ -233,7 +489,7 @@ generate_schema_models <construct> <schema-version> [<openapi-file>]
|
|
|
233
489
|
|
|
234
490
|
generate_schema_models "capability" "v1alpha1"
|
|
235
491
|
generate_schema_models "category" "v1beta1"
|
|
236
|
-
generate_schema_models "pattern" "v1beta1" "schemas/constructs/v1beta1/design/
|
|
492
|
+
generate_schema_models "pattern" "v1beta1" "schemas/constructs/v1beta1/design/api.yml"
|
|
237
493
|
```
|
|
238
494
|
|
|
239
495
|
This maps to Go packages like:
|
|
@@ -255,7 +511,7 @@ npx @redocly/cli join schemas/base_cloud.yml \
|
|
|
255
511
|
"${v1beta1}/component/${merged_construct}" \
|
|
256
512
|
"${v1beta1}/model/${merged_construct}" \
|
|
257
513
|
... \
|
|
258
|
-
-o
|
|
514
|
+
-o _openapi_build/merged_openapi.yml \
|
|
259
515
|
--prefix-tags-with-info-prop title \
|
|
260
516
|
--prefix-components-with-info-prop title
|
|
261
517
|
```
|
|
@@ -444,19 +700,34 @@ make build
|
|
|
444
700
|
Or validate a single file:
|
|
445
701
|
|
|
446
702
|
```bash
|
|
447
|
-
npx @redocly/cli lint schemas/constructs/v1beta1/pattern/
|
|
703
|
+
npx @redocly/cli lint schemas/constructs/v1beta1/pattern/api.yml
|
|
448
704
|
```
|
|
449
705
|
|
|
450
706
|
---
|
|
451
707
|
|
|
452
708
|
## ✅ Summary
|
|
453
709
|
|
|
454
|
-
| Task
|
|
455
|
-
|
|
|
456
|
-
| Generate everything
|
|
457
|
-
|
|
|
458
|
-
| Generate
|
|
459
|
-
|
|
|
710
|
+
| Task | Command |
|
|
711
|
+
| ---------------------------- | ----------------------- |
|
|
712
|
+
| Generate everything | `make build` |
|
|
713
|
+
| Build TypeScript dist | `npm run build` |
|
|
714
|
+
| Generate Go code only | `make golang-generate` |
|
|
715
|
+
| Generate TS types + schemas | `make generate-ts` |
|
|
716
|
+
| Lint OpenAPI | `npx @redocly/cli lint` |
|
|
717
|
+
|
|
718
|
+
### Importing Schemas
|
|
719
|
+
|
|
720
|
+
```typescript
|
|
721
|
+
// Via namespaces (types)
|
|
722
|
+
import { v1beta1 } from "@meshery/schemas";
|
|
723
|
+
const model: v1beta1.Model = { /* ... */ };
|
|
724
|
+
|
|
725
|
+
// Via schema exports (runtime)
|
|
726
|
+
import { ModelDefinitionV1Beta1OpenApiSchema } from "@meshery/schemas";
|
|
727
|
+
|
|
728
|
+
// Direct schema import
|
|
729
|
+
import ModelSchema from "@meshery/schemas/dist/constructs/v1beta1/model/ModelSchema";
|
|
730
|
+
```
|
|
460
731
|
|
|
461
732
|
---
|
|
462
733
|
|