@friggframework/schemas 2.0.0--canary.705.9cfd819.0 → 2.0.0--canary.704.6a606c3.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/README.md +2 -32
- package/index.js +5 -21
- package/middleware/schema-validation.js +1 -2
- package/package.json +3 -6
- package/schemas/api-authorization.schema.json +1 -1
- package/schemas/api-credentials.schema.json +1 -1
- package/schemas/api-entities.schema.json +1 -1
- package/schemas/api-module-definition.schema.json +1 -1
- package/schemas/api-proxy.schema.json +1 -1
- package/schemas/app-definition.schema.json +3 -3
- package/schemas/core-models.schema.json +1 -1
- package/schemas/environment-config.schema.json +1 -1
- package/schemas/integration-definition.schema.json +1 -1
- package/schemas/serverless-config.schema.json +5 -5
- package/schema-ids.js +0 -69
package/README.md
CHANGED
|
@@ -69,31 +69,6 @@ const appSchema = getSchema('app-definition');
|
|
|
69
69
|
console.log('App definition schema:', appSchema);
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
## Schema Identifiers and Hosting
|
|
73
|
-
|
|
74
|
-
Every schema's `$id` is its public URL:
|
|
75
|
-
|
|
76
|
-
```
|
|
77
|
-
https://friggframework.org/schemas/<name>/v<major>.<minor>.json
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
for example `https://friggframework.org/schemas/app-definition/v1.0.json`.
|
|
81
|
-
friggframework.org serves each file at that URL (with
|
|
82
|
-
`Content-Type: application/schema+json` and open CORS), so editors can fetch
|
|
83
|
-
it from a `$schema` reference. The URL is a name, not a dependency: this
|
|
84
|
-
package, `frigg validate` and the runtime resolve every `$id` from the
|
|
85
|
-
installed files and never fetch it.
|
|
86
|
-
|
|
87
|
-
- A version is immutable once a stable release ships it. A backward-compatible
|
|
88
|
-
change gets a new minor version, a breaking change a new major version.
|
|
89
|
-
- `validate()` and `getSchema()` accept a schema name, its `$id`, or the
|
|
90
|
-
unversioned id it had before 2.0.1 (kept as an alias for one release).
|
|
91
|
-
- The website copies live in `website/schemas/` and are committed. After you
|
|
92
|
-
change a schema, run `npm run sync:hosted` here and commit the result;
|
|
93
|
-
`tests/hosted-schemas.test.js` fails while a copy is missing or stale.
|
|
94
|
-
|
|
95
|
-
The rules are in ADR-051, "Hosted schemas" amendment.
|
|
96
|
-
|
|
97
72
|
## Available Schemas
|
|
98
73
|
|
|
99
74
|
### App Definition Schema
|
|
@@ -210,7 +185,7 @@ Defines the structure for Serverless Framework configuration used in AWS deploym
|
|
|
210
185
|
**Example:**
|
|
211
186
|
```javascript
|
|
212
187
|
const serverlessConfig = {
|
|
213
|
-
frameworkVersion: "
|
|
188
|
+
frameworkVersion: "^4.4.0",
|
|
214
189
|
service: "frigg-backend",
|
|
215
190
|
provider: {
|
|
216
191
|
name: "aws",
|
|
@@ -352,12 +327,7 @@ Validates core data models (User, Entity, Credential).
|
|
|
352
327
|
Returns all available schemas as an object.
|
|
353
328
|
|
|
354
329
|
#### `getSchema(schemaName)`
|
|
355
|
-
Returns a specific schema by name
|
|
356
|
-
|
|
357
|
-
#### `parseSchemaId(id)`
|
|
358
|
-
Returns `{ name, version, hostedPath }` for an `$id` on the
|
|
359
|
-
`https://friggframework.org/schemas/<name>/v<x.y>.json` pattern, or `null`.
|
|
360
|
-
`SCHEMA_ID_PATTERN` and `LEGACY_SCHEMA_IDS` are exported too.
|
|
330
|
+
Returns a specific schema by name.
|
|
361
331
|
|
|
362
332
|
### Utility Functions
|
|
363
333
|
|
package/index.js
CHANGED
|
@@ -12,7 +12,6 @@ const path = require('path');
|
|
|
12
12
|
|
|
13
13
|
// Import middleware
|
|
14
14
|
const schemaValidationMiddleware = require('./middleware/schema-validation');
|
|
15
|
-
const schemaIds = require('./schema-ids');
|
|
16
15
|
|
|
17
16
|
// Initialize AJV with formats
|
|
18
17
|
const ajv = new Ajv({
|
|
@@ -46,16 +45,7 @@ schemaFiles.forEach(file => {
|
|
|
46
45
|
const schemaName = file.replace('.schema.json', '');
|
|
47
46
|
|
|
48
47
|
schemas[schemaName] = schemaContent;
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// Schema name for each `$id` and legacy id, so getSchema() also accepts a URL.
|
|
53
|
-
const schemaNamesById = {};
|
|
54
|
-
Object.entries(schemas).forEach(([schemaName, schema]) => {
|
|
55
|
-
schemaNamesById[schema.$id] = schemaName;
|
|
56
|
-
(schemaIds.LEGACY_SCHEMA_IDS[schemaName] || []).forEach(legacyId => {
|
|
57
|
-
schemaNamesById[legacyId] = schemaName;
|
|
58
|
-
});
|
|
48
|
+
ajv.addSchema(schemaContent, schemaName);
|
|
59
49
|
});
|
|
60
50
|
|
|
61
51
|
/**
|
|
@@ -332,16 +322,15 @@ function getSchemas() {
|
|
|
332
322
|
}
|
|
333
323
|
|
|
334
324
|
/**
|
|
335
|
-
* Get a specific schema by name
|
|
336
|
-
* @param {string} schemaName -
|
|
325
|
+
* Get a specific schema by name
|
|
326
|
+
* @param {string} schemaName - Name of the schema to retrieve
|
|
337
327
|
* @returns {object} - Schema object
|
|
338
328
|
*/
|
|
339
329
|
function getSchema(schemaName) {
|
|
340
|
-
|
|
341
|
-
if (!name) {
|
|
330
|
+
if (!schemas[schemaName]) {
|
|
342
331
|
throw new Error(`Schema '${schemaName}' not found. Available schemas: ${Object.keys(schemas).join(', ')}`);
|
|
343
332
|
}
|
|
344
|
-
return schemas[
|
|
333
|
+
return schemas[schemaName];
|
|
345
334
|
}
|
|
346
335
|
|
|
347
336
|
/**
|
|
@@ -400,11 +389,6 @@ module.exports = {
|
|
|
400
389
|
schemas,
|
|
401
390
|
ajv,
|
|
402
391
|
|
|
403
|
-
// Schema identifiers (https://friggframework.org/schemas/<name>/v<x.y>.json)
|
|
404
|
-
SCHEMA_ID_PATTERN: schemaIds.SCHEMA_ID_PATTERN,
|
|
405
|
-
LEGACY_SCHEMA_IDS: schemaIds.LEGACY_SCHEMA_IDS,
|
|
406
|
-
parseSchemaId: schemaIds.parseSchemaId,
|
|
407
|
-
|
|
408
392
|
// Middleware exports
|
|
409
393
|
middleware: schemaValidationMiddleware,
|
|
410
394
|
validateBody: schemaValidationMiddleware.validateBody,
|
|
@@ -9,7 +9,6 @@ const Ajv = require('ajv');
|
|
|
9
9
|
const addFormats = require('ajv-formats');
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
const path = require('path');
|
|
12
|
-
const { addSchemaWithAliases } = require('../schema-ids');
|
|
13
12
|
|
|
14
13
|
// Initialize AJV with formats
|
|
15
14
|
const ajv = new Ajv({
|
|
@@ -34,7 +33,7 @@ schemaFiles.forEach(file => {
|
|
|
34
33
|
if (fs.existsSync(schemaPath)) {
|
|
35
34
|
const schemaContent = JSON.parse(fs.readFileSync(schemaPath, 'utf8'));
|
|
36
35
|
const schemaName = file.replace('.schema.json', '');
|
|
37
|
-
|
|
36
|
+
ajv.addSchema(schemaContent, schemaName);
|
|
38
37
|
}
|
|
39
38
|
});
|
|
40
39
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/schemas",
|
|
3
|
-
"version": "2.0.0--canary.
|
|
3
|
+
"version": "2.0.0--canary.704.6a606c3.0",
|
|
4
4
|
"description": "Canonical JSON Schema definitions for Frigg Framework",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "",
|
|
@@ -19,9 +19,7 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"test": "jest",
|
|
21
21
|
"validate": "node scripts/validate-schemas.js",
|
|
22
|
-
"build": "node scripts/build-schemas.js"
|
|
23
|
-
"sync:hosted": "node scripts/sync-hosted-schemas.js",
|
|
24
|
-
"check:hosted": "node scripts/sync-hosted-schemas.js --check"
|
|
22
|
+
"build": "node scripts/build-schemas.js"
|
|
25
23
|
},
|
|
26
24
|
"keywords": [
|
|
27
25
|
"frigg",
|
|
@@ -41,8 +39,7 @@
|
|
|
41
39
|
"validators/",
|
|
42
40
|
"mocks/",
|
|
43
41
|
"middleware/",
|
|
44
|
-
"schema-ids.js",
|
|
45
42
|
"index.js"
|
|
46
43
|
],
|
|
47
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "6a606c35cd01084a4c498809d312d77e219b2f81"
|
|
48
45
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://friggframework.org/schemas/api-authorization
|
|
3
|
+
"$id": "https://friggframework.org/schemas/api-authorization.json",
|
|
4
4
|
"title": "Frigg Authorization API Schemas",
|
|
5
5
|
"description": "JSON schemas for authorization and authentication API requests and responses",
|
|
6
6
|
"definitions": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://friggframework.org/schemas/api-credentials
|
|
3
|
+
"$id": "https://friggframework.org/schemas/api-credentials.json",
|
|
4
4
|
"title": "Frigg Credentials API Schemas",
|
|
5
5
|
"description": "JSON schemas for credentials API requests and responses",
|
|
6
6
|
"definitions": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://friggframework.org/schemas/api-entities
|
|
3
|
+
"$id": "https://friggframework.org/schemas/api-entities.json",
|
|
4
4
|
"title": "Frigg Entities API Schemas",
|
|
5
5
|
"description": "JSON schemas for entities API requests and responses",
|
|
6
6
|
"definitions": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://friggframework.org/
|
|
3
|
+
"$id": "https://schemas.friggframework.org/api-module-definition.schema.json",
|
|
4
4
|
"title": "Frigg API Module Definition",
|
|
5
5
|
"description": "Schema for defining a Frigg API module including authentication, API configuration, and required methods.",
|
|
6
6
|
"type": "object",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://friggframework.org/schemas/api-proxy
|
|
3
|
+
"$id": "https://friggframework.org/schemas/api-proxy.json",
|
|
4
4
|
"title": "Frigg Proxy API Schemas",
|
|
5
5
|
"description": "JSON schemas for proxy API requests and responses that forward calls to external APIs",
|
|
6
6
|
"definitions": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://friggframework.org/
|
|
3
|
+
"$id": "https://schemas.friggframework.org/app-definition.schema.json",
|
|
4
4
|
"title": "Frigg Application Definition",
|
|
5
5
|
"description": "Schema for defining a Frigg application configuration including integrations, infrastructure, security settings, and deployment options.",
|
|
6
6
|
"type": "object",
|
|
@@ -279,8 +279,8 @@
|
|
|
279
279
|
},
|
|
280
280
|
"management": {
|
|
281
281
|
"type": "string",
|
|
282
|
-
"description": "How to manage the PostgreSQL database",
|
|
283
|
-
"enum": ["discover", "create-new", "existing"],
|
|
282
|
+
"description": "How to manage the PostgreSQL database. 'external' means Frigg provisions and discovers no database (no RDS/Aurora, no VPC requirement): the app connects to any PostgreSQL through the DATABASE_URL environment variable",
|
|
283
|
+
"enum": ["discover", "create-new", "existing", "external"],
|
|
284
284
|
"default": "discover"
|
|
285
285
|
},
|
|
286
286
|
"endpoint": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://friggframework.org/
|
|
3
|
+
"$id": "https://schemas.friggframework.org/core-models.schema.json",
|
|
4
4
|
"title": "Frigg Core Data Models",
|
|
5
5
|
"description": "Schema definitions for core Frigg data models including User, Entity, and Credential.",
|
|
6
6
|
"definitions": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://friggframework.org/
|
|
3
|
+
"$id": "https://schemas.friggframework.org/environment-config.schema.json",
|
|
4
4
|
"title": "Frigg Environment Configuration",
|
|
5
5
|
"description": "Schema for environment variable configuration and validation in Frigg applications.",
|
|
6
6
|
"type": "object",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://friggframework.org/
|
|
3
|
+
"$id": "https://schemas.friggframework.org/integration-definition.schema.json",
|
|
4
4
|
"title": "Frigg Integration Definition",
|
|
5
5
|
"description": "Schema for defining a Frigg integration including configuration, options, and display properties.",
|
|
6
6
|
"type": "object",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://friggframework.org/
|
|
3
|
+
"$id": "https://schemas.friggframework.org/serverless-config.schema.json",
|
|
4
4
|
"title": "Frigg Serverless Configuration",
|
|
5
5
|
"description": "Schema for Serverless Framework configuration used in Frigg applications for AWS deployment.",
|
|
6
6
|
"type": "object",
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"properties": {
|
|
9
9
|
"frameworkVersion": {
|
|
10
10
|
"type": "string",
|
|
11
|
-
"description": "Serverless Framework version constraint",
|
|
12
|
-
"pattern": "^[
|
|
13
|
-
"examples": [">=
|
|
11
|
+
"description": "osls (Serverless Framework v3-compatible) version constraint. Frigg emits ^4.4.0 (ADR-050).",
|
|
12
|
+
"pattern": "^[><=^~]*\\d+(\\.\\d+){0,2}$",
|
|
13
|
+
"examples": ["^4.4.0", ">=4.4.0", "4.4.0"]
|
|
14
14
|
},
|
|
15
15
|
"service": {
|
|
16
16
|
"type": "string",
|
|
@@ -353,7 +353,7 @@
|
|
|
353
353
|
"additionalProperties": false,
|
|
354
354
|
"examples": [
|
|
355
355
|
{
|
|
356
|
-
"frameworkVersion": "
|
|
356
|
+
"frameworkVersion": "^4.4.0",
|
|
357
357
|
"service": "frigg-backend",
|
|
358
358
|
"provider": {
|
|
359
359
|
"name": "aws",
|
package/schema-ids.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Schema identifiers (ADR-051, "Hosted schemas" amendment).
|
|
3
|
-
*
|
|
4
|
-
* Every Frigg JSON Schema has the `$id`
|
|
5
|
-
* https://friggframework.org/schemas/<name>/v<major>.<minor>.json
|
|
6
|
-
* and friggframework.org serves the file at exactly that URL. The `$id` is a
|
|
7
|
-
* name, not a location the runtime reads: validation always resolves it from
|
|
8
|
-
* this package and never fetches it.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const SCHEMA_BASE_URL = 'https://friggframework.org/';
|
|
12
|
-
|
|
13
|
-
const SCHEMA_ID_PATTERN =
|
|
14
|
-
/^https:\/\/friggframework\.org\/schemas\/([a-z0-9]+(?:-[a-z0-9]+)*)\/v(0|[1-9]\d*)\.(0|[1-9]\d*)\.json$/;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Unversioned ids the schemas carried before 2.0.1. They never resolved over
|
|
18
|
-
* HTTP, but code may pass them to `validate()`/`getSchema()` or Ajv, so the
|
|
19
|
-
* package still registers them as aliases of the current schema.
|
|
20
|
-
*
|
|
21
|
-
* @deprecated Remove in the release after 2.0.1.
|
|
22
|
-
*/
|
|
23
|
-
const LEGACY_SCHEMA_IDS = Object.freeze({
|
|
24
|
-
'api-authorization': ['https://friggframework.org/schemas/api-authorization.json'],
|
|
25
|
-
'api-credentials': ['https://friggframework.org/schemas/api-credentials.json'],
|
|
26
|
-
'api-entities': ['https://friggframework.org/schemas/api-entities.json'],
|
|
27
|
-
'api-proxy': ['https://friggframework.org/schemas/api-proxy.json'],
|
|
28
|
-
'api-module-definition': ['https://schemas.friggframework.org/api-module-definition.schema.json'],
|
|
29
|
-
'app-definition': ['https://schemas.friggframework.org/app-definition.schema.json'],
|
|
30
|
-
'core-models': ['https://schemas.friggframework.org/core-models.schema.json'],
|
|
31
|
-
'environment-config': ['https://schemas.friggframework.org/environment-config.schema.json'],
|
|
32
|
-
'integration-definition': ['https://schemas.friggframework.org/integration-definition.schema.json'],
|
|
33
|
-
'serverless-config': ['https://schemas.friggframework.org/serverless-config.schema.json'],
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Parse a schema `$id`.
|
|
38
|
-
* @param {string} id
|
|
39
|
-
* @returns {{ name: string, version: string, hostedPath: string } | null}
|
|
40
|
-
* `hostedPath` is the path under the website root (`schemas/<name>/v1.0.json`).
|
|
41
|
-
*/
|
|
42
|
-
function parseSchemaId(id) {
|
|
43
|
-
const match = typeof id === 'string' ? SCHEMA_ID_PATTERN.exec(id) : null;
|
|
44
|
-
if (!match) return null;
|
|
45
|
-
const [, name, major, minor] = match;
|
|
46
|
-
const version = `${major}.${minor}`;
|
|
47
|
-
return { name, version, hostedPath: `schemas/${name}/v${version}.json` };
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Register a schema with Ajv under its file name, its `$id`, and its legacy ids.
|
|
52
|
-
* @param {import('ajv').default} ajv
|
|
53
|
-
* @param {object} schema - parsed schema (its `$id` registers automatically)
|
|
54
|
-
* @param {string} name - file name without `.schema.json`
|
|
55
|
-
*/
|
|
56
|
-
function addSchemaWithAliases(ajv, schema, name) {
|
|
57
|
-
ajv.addSchema(schema, name);
|
|
58
|
-
for (const legacyId of LEGACY_SCHEMA_IDS[name] || []) {
|
|
59
|
-
ajv.addSchema({ ...schema, $id: legacyId });
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
module.exports = {
|
|
64
|
-
SCHEMA_BASE_URL,
|
|
65
|
-
SCHEMA_ID_PATTERN,
|
|
66
|
-
LEGACY_SCHEMA_IDS,
|
|
67
|
-
parseSchemaId,
|
|
68
|
-
addSchemaWithAliases,
|
|
69
|
-
};
|