@friggframework/schemas 2.0.0--canary.705.f070722.0 → 2.0.0--canary.726.131e2b3.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 CHANGED
@@ -95,31 +95,6 @@ const appSchema = getSchema('app-definition');
95
95
  console.log('App definition schema:', appSchema);
96
96
  ```
97
97
 
98
- ## Schema Identifiers and Hosting
99
-
100
- Every schema's `$id` is its public URL:
101
-
102
- ```
103
- https://friggframework.org/schemas/<name>/v<major>.<minor>.json
104
- ```
105
-
106
- for example `https://friggframework.org/schemas/app-definition/v1.0.json`.
107
- friggframework.org serves each file at that URL (with
108
- `Content-Type: application/schema+json` and open CORS), so editors can fetch
109
- it from a `$schema` reference. The URL is a name, not a dependency: this
110
- package, `frigg validate` and the runtime resolve every `$id` from the
111
- installed files and never fetch it.
112
-
113
- - A version is immutable once a stable release ships it. A backward-compatible
114
- change gets a new minor version, a breaking change a new major version.
115
- - `validate()` and `getSchema()` accept a schema name, its `$id`, or the
116
- unversioned id it had before 2.0.1 (kept as an alias for one release).
117
- - The website copies live in `website/schemas/` and are committed. After you
118
- change a schema, run `npm run sync:hosted` here and commit the result;
119
- `tests/hosted-schemas.test.js` fails while a copy is missing or stale.
120
-
121
- The rules are in ADR-051, "Hosted schemas" amendment.
122
-
123
98
  ## Available Schemas
124
99
 
125
100
  ### App Definition Schema
@@ -378,12 +353,7 @@ Validates core data models (User, Entity, Credential).
378
353
  Returns all available schemas as an object.
379
354
 
380
355
  #### `getSchema(schemaName)`
381
- Returns a specific schema by name (`app-definition`), by `$id`, or by its legacy unversioned id.
382
-
383
- #### `parseSchemaId(id)`
384
- Returns `{ name, version, hostedPath }` for an `$id` on the
385
- `https://friggframework.org/schemas/<name>/v<x.y>.json` pattern, or `null`.
386
- `SCHEMA_ID_PATTERN` and `LEGACY_SCHEMA_IDS` are exported too.
356
+ Returns a specific schema by name.
387
357
 
388
358
  ### Utility Functions
389
359
 
package/index.js CHANGED
@@ -16,7 +16,6 @@ const {
16
16
  applyAppDefinitionDefaults,
17
17
  toAppDefinitionSchemaView,
18
18
  } = require('./app-definition');
19
- const schemaIds = require('./schema-ids');
20
19
 
21
20
  // Initialize AJV with formats
22
21
  const ajv = new Ajv({
@@ -50,16 +49,7 @@ schemaFiles.forEach(file => {
50
49
  const schemaName = file.replace('.schema.json', '');
51
50
 
52
51
  schemas[schemaName] = schemaContent;
53
- schemaIds.addSchemaWithAliases(ajv, schemaContent, schemaName);
54
- });
55
-
56
- // Schema name for each `$id` and legacy id, so getSchema() also accepts a URL.
57
- const schemaNamesById = {};
58
- Object.entries(schemas).forEach(([schemaName, schema]) => {
59
- schemaNamesById[schema.$id] = schemaName;
60
- (schemaIds.LEGACY_SCHEMA_IDS[schemaName] || []).forEach(legacyId => {
61
- schemaNamesById[legacyId] = schemaName;
62
- });
52
+ ajv.addSchema(schemaContent, schemaName);
63
53
  });
64
54
 
65
55
  /**
@@ -342,16 +332,15 @@ function getSchemas() {
342
332
  }
343
333
 
344
334
  /**
345
- * Get a specific schema by name or `$id`
346
- * @param {string} schemaName - Schema name (`app-definition`), its `$id`, or a legacy unversioned id
335
+ * Get a specific schema by name
336
+ * @param {string} schemaName - Name of the schema to retrieve
347
337
  * @returns {object} - Schema object
348
338
  */
349
339
  function getSchema(schemaName) {
350
- const name = schemas[schemaName] ? schemaName : schemaNamesById[schemaName];
351
- if (!name) {
340
+ if (!schemas[schemaName]) {
352
341
  throw new Error(`Schema '${schemaName}' not found. Available schemas: ${Object.keys(schemas).join(', ')}`);
353
342
  }
354
- return schemas[name];
343
+ return schemas[schemaName];
355
344
  }
356
345
 
357
346
  /**
@@ -412,11 +401,6 @@ module.exports = {
412
401
  schemas,
413
402
  ajv,
414
403
 
415
- // Schema identifiers (https://friggframework.org/schemas/<name>/v<x.y>.json)
416
- SCHEMA_ID_PATTERN: schemaIds.SCHEMA_ID_PATTERN,
417
- LEGACY_SCHEMA_IDS: schemaIds.LEGACY_SCHEMA_IDS,
418
- parseSchemaId: schemaIds.parseSchemaId,
419
-
420
404
  // Middleware exports
421
405
  middleware: schemaValidationMiddleware,
422
406
  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
- addSchemaWithAliases(ajv, schemaContent, schemaName);
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.705.f070722.0",
3
+ "version": "2.0.0--canary.726.131e2b3.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",
@@ -42,8 +40,7 @@
42
40
  "mocks/",
43
41
  "middleware/",
44
42
  "app-definition.js",
45
- "schema-ids.js",
46
43
  "index.js"
47
44
  ],
48
- "gitHead": "f070722ad939d3221446e24653352373a5f4e0f6"
45
+ "gitHead": "131e2b30f186de52170e32a5fa6948e568445593"
49
46
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://friggframework.org/schemas/api-authorization/v1.0.json",
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/v1.0.json",
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/v1.0.json",
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/schemas/api-module-definition/v1.0.json",
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/v1.0.json",
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/schemas/app-definition/v1.0.json",
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",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://friggframework.org/schemas/core-models/v1.0.json",
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/schemas/environment-config/v1.0.json",
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/schemas/integration-definition/v1.0.json",
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/schemas/serverless-config/v1.0.json",
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",
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
- };