@friggframework/schemas 2.0.0--canary.702.ef0dc8c.0 → 2.0.0--canary.710.7cfcf12.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 +1 -29
- package/index.js +4 -26
- package/package.json +2 -4
- package/schemas/api-module-definition.schema.json +0 -23
- package/schemas/app-definition.schema.json +163 -533
- package/api-module-definition.js +0 -93
- package/app-definition.js +0 -113
package/README.md
CHANGED
|
@@ -41,32 +41,6 @@ if (result.valid) {
|
|
|
41
41
|
}
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
### Integration classes and defaults (ADR-051)
|
|
45
|
-
|
|
46
|
-
Apps list integration classes, which JSON Schema cannot describe.
|
|
47
|
-
`validateAppDefinition` validates a view of the definition in which each
|
|
48
|
-
class in `integrations`, `adminScripts` and `reports` is replaced by
|
|
49
|
-
`{ Definition }`; `frigg validate` checks the classes themselves.
|
|
50
|
-
|
|
51
|
-
```javascript
|
|
52
|
-
const { applyAppDefinitionDefaults } = require('@friggframework/schemas');
|
|
53
|
-
// or, without loading Ajv:
|
|
54
|
-
// require('@friggframework/schemas/app-definition').applyAppDefinitionDefaults
|
|
55
|
-
|
|
56
|
-
const definition = applyAppDefinitionDefaults(require('./index').Definition);
|
|
57
|
-
definition.user.individualUserRequired; // true (schema default)
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
`applyAppDefinitionDefaults` returns a copy with every `default` declared in
|
|
61
|
-
the app-definition schema applied (only inside blocks the app sets, plus
|
|
62
|
-
blocks that have a default themselves, such as `user`). core's
|
|
63
|
-
`loadAppDefinition` and devtools' `createFriggInfrastructure` call it, so a
|
|
64
|
-
schema default is the runtime default. A schema default must equal what the
|
|
65
|
-
code does when the key is absent; the contract test in
|
|
66
|
-
`packages/devtools/infrastructure/app-definition-schema-contract.test.js`
|
|
67
|
-
checks this for the infrastructure builders. Keys nothing reads are marked
|
|
68
|
-
`"deprecated": true`.
|
|
69
|
-
|
|
70
44
|
### Advanced Validation
|
|
71
45
|
|
|
72
46
|
```javascript
|
|
@@ -172,9 +146,7 @@ Defines the structure for Frigg API modules.
|
|
|
172
146
|
**Key Properties:**
|
|
173
147
|
- `moduleName` (required): Module identifier
|
|
174
148
|
- `getName` (required): Function returning module name
|
|
175
|
-
- `requiredAuthMethods` (required): Authentication configuration
|
|
176
|
-
- `modelName`: Entity/credential model name used by the Module runtime
|
|
177
|
-
- Real Definitions (classes/functions) are accepted by `validateApiModuleDefinition` via a schema view.
|
|
149
|
+
- `requiredAuthMethods` (required): Authentication configuration
|
|
178
150
|
- `env`: Environment variable configuration
|
|
179
151
|
- `config`: Module-specific configuration
|
|
180
152
|
|
package/index.js
CHANGED
|
@@ -12,13 +12,6 @@ const path = require('path');
|
|
|
12
12
|
|
|
13
13
|
// Import middleware
|
|
14
14
|
const schemaValidationMiddleware = require('./middleware/schema-validation');
|
|
15
|
-
const {
|
|
16
|
-
applyAppDefinitionDefaults,
|
|
17
|
-
toAppDefinitionSchemaView,
|
|
18
|
-
} = require('./app-definition');
|
|
19
|
-
const {
|
|
20
|
-
toApiModuleDefinitionSchemaView,
|
|
21
|
-
} = require('./api-module-definition');
|
|
22
15
|
|
|
23
16
|
// Initialize AJV with formats
|
|
24
17
|
const ajv = new Ajv({
|
|
@@ -83,13 +76,7 @@ function validate(schemaName, data) {
|
|
|
83
76
|
* @returns {object} - Validation result
|
|
84
77
|
*/
|
|
85
78
|
function validateAppDefinition(appDefinition) {
|
|
86
|
-
|
|
87
|
-
// validate the serialisable view and return the original definition.
|
|
88
|
-
const result = validate(
|
|
89
|
-
'app-definition',
|
|
90
|
-
toAppDefinitionSchemaView(appDefinition)
|
|
91
|
-
);
|
|
92
|
-
return { ...result, data: appDefinition };
|
|
79
|
+
return validate('app-definition', appDefinition);
|
|
93
80
|
}
|
|
94
81
|
|
|
95
82
|
/**
|
|
@@ -102,18 +89,12 @@ function validateIntegrationDefinition(integrationDefinition) {
|
|
|
102
89
|
}
|
|
103
90
|
|
|
104
91
|
/**
|
|
105
|
-
* Validate API Module Definition
|
|
106
|
-
*
|
|
107
|
-
* view and return the original definition (same pattern as validateAppDefinition).
|
|
108
|
-
* @param {object} apiModuleDefinition - API module definition object to validate
|
|
92
|
+
* Validate API Module Definition
|
|
93
|
+
* @param {object} apiModuleDefinition - API module definition object to validate
|
|
109
94
|
* @returns {object} - Validation result
|
|
110
95
|
*/
|
|
111
96
|
function validateApiModuleDefinition(apiModuleDefinition) {
|
|
112
|
-
|
|
113
|
-
'api-module-definition',
|
|
114
|
-
toApiModuleDefinitionSchemaView(apiModuleDefinition)
|
|
115
|
-
);
|
|
116
|
-
return { ...result, data: apiModuleDefinition };
|
|
97
|
+
return validate('api-module-definition', apiModuleDefinition);
|
|
117
98
|
}
|
|
118
99
|
|
|
119
100
|
/**
|
|
@@ -376,9 +357,6 @@ module.exports = {
|
|
|
376
357
|
// Validation functions
|
|
377
358
|
validate,
|
|
378
359
|
validateAppDefinition,
|
|
379
|
-
applyAppDefinitionDefaults,
|
|
380
|
-
toAppDefinitionSchemaView,
|
|
381
|
-
toApiModuleDefinitionSchemaView,
|
|
382
360
|
validateIntegrationDefinition,
|
|
383
361
|
validateApiModuleDefinition,
|
|
384
362
|
validateServerlessConfig,
|
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.710.7cfcf12.0",
|
|
4
4
|
"description": "Canonical JSON Schema definitions for Frigg Framework",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "",
|
|
@@ -39,9 +39,7 @@
|
|
|
39
39
|
"validators/",
|
|
40
40
|
"mocks/",
|
|
41
41
|
"middleware/",
|
|
42
|
-
"app-definition.js",
|
|
43
|
-
"api-module-definition.js",
|
|
44
42
|
"index.js"
|
|
45
43
|
],
|
|
46
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "7cfcf1267a412053163b99b7f9a123f7e4e1bde3"
|
|
47
45
|
}
|
|
@@ -27,13 +27,6 @@
|
|
|
27
27
|
"minLength": 1,
|
|
28
28
|
"maxLength": 100
|
|
29
29
|
},
|
|
30
|
-
"modelName": {
|
|
31
|
-
"type": "string",
|
|
32
|
-
"description": "Entity/credential model name used by the Module runtime (e.g. 'Fathom'). Distinct from moduleName, which is the package identifier.",
|
|
33
|
-
"pattern": "^[a-zA-Z][a-zA-Z0-9_]*$",
|
|
34
|
-
"minLength": 1,
|
|
35
|
-
"maxLength": 100
|
|
36
|
-
},
|
|
37
30
|
"requiredAuthMethods": {
|
|
38
31
|
"type": "object",
|
|
39
32
|
"description": "Required authentication methods and configuration",
|
|
@@ -97,22 +90,6 @@
|
|
|
97
90
|
"type": {"type": "string", "enum": ["function"]},
|
|
98
91
|
"async": {"type": "boolean", "default": true}
|
|
99
92
|
}
|
|
100
|
-
},
|
|
101
|
-
"getAuthorizationRequirements": {
|
|
102
|
-
"type": "object",
|
|
103
|
-
"description": "Method that returns the authorization requirements (type, jsonSchema/uiSchema) for non-OAuth flows such as API key",
|
|
104
|
-
"properties": {
|
|
105
|
-
"type": {"type": "string", "enum": ["function"]},
|
|
106
|
-
"async": {"type": "boolean", "default": true}
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
"setAuthParams": {
|
|
110
|
-
"type": "object",
|
|
111
|
-
"description": "Method that applies authorization parameters (e.g. API key) to the API instance",
|
|
112
|
-
"properties": {
|
|
113
|
-
"type": {"type": "string", "enum": ["function"]},
|
|
114
|
-
"async": {"type": "boolean", "default": true}
|
|
115
|
-
}
|
|
116
93
|
}
|
|
117
94
|
},
|
|
118
95
|
"additionalProperties": false
|