@friggframework/schemas 2.0.0--canary.702.d5e6de1.0 → 2.0.0--canary.666.89f6545.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 -3
- package/index.js +3 -13
- package/package.json +2 -3
- package/schemas/api-module-definition.schema.json +0 -23
- package/schemas/app-definition.schema.json +38 -6
- package/api-module-definition.js +0 -93
package/README.md
CHANGED
|
@@ -172,9 +172,7 @@ Defines the structure for Frigg API modules.
|
|
|
172
172
|
**Key Properties:**
|
|
173
173
|
- `moduleName` (required): Module identifier
|
|
174
174
|
- `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.
|
|
175
|
+
- `requiredAuthMethods` (required): Authentication configuration
|
|
178
176
|
- `env`: Environment variable configuration
|
|
179
177
|
- `config`: Module-specific configuration
|
|
180
178
|
|
package/index.js
CHANGED
|
@@ -16,9 +16,6 @@ const {
|
|
|
16
16
|
applyAppDefinitionDefaults,
|
|
17
17
|
toAppDefinitionSchemaView,
|
|
18
18
|
} = require('./app-definition');
|
|
19
|
-
const {
|
|
20
|
-
toApiModuleDefinitionSchemaView,
|
|
21
|
-
} = require('./api-module-definition');
|
|
22
19
|
|
|
23
20
|
// Initialize AJV with formats
|
|
24
21
|
const ajv = new Ajv({
|
|
@@ -102,18 +99,12 @@ function validateIntegrationDefinition(integrationDefinition) {
|
|
|
102
99
|
}
|
|
103
100
|
|
|
104
101
|
/**
|
|
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
|
|
102
|
+
* Validate API Module Definition
|
|
103
|
+
* @param {object} apiModuleDefinition - API module definition object to validate
|
|
109
104
|
* @returns {object} - Validation result
|
|
110
105
|
*/
|
|
111
106
|
function validateApiModuleDefinition(apiModuleDefinition) {
|
|
112
|
-
|
|
113
|
-
'api-module-definition',
|
|
114
|
-
toApiModuleDefinitionSchemaView(apiModuleDefinition)
|
|
115
|
-
);
|
|
116
|
-
return { ...result, data: apiModuleDefinition };
|
|
107
|
+
return validate('api-module-definition', apiModuleDefinition);
|
|
117
108
|
}
|
|
118
109
|
|
|
119
110
|
/**
|
|
@@ -378,7 +369,6 @@ module.exports = {
|
|
|
378
369
|
validateAppDefinition,
|
|
379
370
|
applyAppDefinitionDefaults,
|
|
380
371
|
toAppDefinitionSchemaView,
|
|
381
|
-
toApiModuleDefinitionSchemaView,
|
|
382
372
|
validateIntegrationDefinition,
|
|
383
373
|
validateApiModuleDefinition,
|
|
384
374
|
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.666.89f6545.0",
|
|
4
4
|
"description": "Canonical JSON Schema definitions for Frigg Framework",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "",
|
|
@@ -40,8 +40,7 @@
|
|
|
40
40
|
"mocks/",
|
|
41
41
|
"middleware/",
|
|
42
42
|
"app-definition.js",
|
|
43
|
-
"api-module-definition.js",
|
|
44
43
|
"index.js"
|
|
45
44
|
],
|
|
46
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "89f6545362623128362b730cb02b286c8308c66e"
|
|
47
46
|
}
|
|
@@ -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
|
|
@@ -95,6 +95,39 @@
|
|
|
95
95
|
},
|
|
96
96
|
"default": []
|
|
97
97
|
},
|
|
98
|
+
"adminScripts": {
|
|
99
|
+
"type": "array",
|
|
100
|
+
"description": "Admin script classes (extending AdminScriptBase from @friggframework/admin-scripts) served under /admin/scripts",
|
|
101
|
+
"items": {
|
|
102
|
+
"description": "Admin script class"
|
|
103
|
+
},
|
|
104
|
+
"default": []
|
|
105
|
+
},
|
|
106
|
+
"reports": {
|
|
107
|
+
"type": "array",
|
|
108
|
+
"description": "Report classes served by the admin report runner",
|
|
109
|
+
"items": {
|
|
110
|
+
"description": "Report class"
|
|
111
|
+
},
|
|
112
|
+
"default": []
|
|
113
|
+
},
|
|
114
|
+
"admin": {
|
|
115
|
+
"type": "object",
|
|
116
|
+
"description": "Admin script and report runner options",
|
|
117
|
+
"properties": {
|
|
118
|
+
"enableScheduling": {
|
|
119
|
+
"type": "boolean",
|
|
120
|
+
"description": "Provision the EventBridge Scheduler group and role so admin scripts and reports can run on a schedule",
|
|
121
|
+
"default": false
|
|
122
|
+
},
|
|
123
|
+
"includeBuiltinReports": {
|
|
124
|
+
"type": "boolean",
|
|
125
|
+
"description": "Serve the built-in reports alongside the app's own reports",
|
|
126
|
+
"default": false
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"additionalProperties": false
|
|
130
|
+
},
|
|
98
131
|
"user": {
|
|
99
132
|
"type": "object",
|
|
100
133
|
"description": "User management and authentication. Read by core when it loads the app definition; an omitted block gets the defaults below (ADR-051).",
|
|
@@ -158,7 +191,7 @@
|
|
|
158
191
|
"properties": {
|
|
159
192
|
"secret": {
|
|
160
193
|
"type": "string",
|
|
161
|
-
"description": "JWT secret key for signature validation (
|
|
194
|
+
"description": "JWT secret key for signature validation, usually `process.env.JWT_SECRET`. Required when authModes.adopterJwt is true; `frigg validate` errors when the key is missing from the definition and warns when its value is empty in the shell that runs it (build and deploy validate before `.env` is loaded)."
|
|
162
195
|
},
|
|
163
196
|
"userIdClaim": {
|
|
164
197
|
"type": "string",
|
|
@@ -177,7 +210,6 @@
|
|
|
177
210
|
"default": "HS256"
|
|
178
211
|
}
|
|
179
212
|
},
|
|
180
|
-
"required": ["secret"],
|
|
181
213
|
"additionalProperties": false
|
|
182
214
|
},
|
|
183
215
|
"fields": {
|
|
@@ -273,8 +305,8 @@
|
|
|
273
305
|
},
|
|
274
306
|
"management": {
|
|
275
307
|
"type": "string",
|
|
276
|
-
"description": "How Frigg gets the Aurora cluster (ignored when managementMode is 'managed' or 'existing'). 'discover' (also when omitted): find one, else create one in the stack. 'managed': create it in the stack. 'use-existing': connect to `endpoint` without creating anything.",
|
|
277
|
-
"enum": ["discover", "managed", "use-existing"]
|
|
308
|
+
"description": "How Frigg gets the Aurora cluster (ignored when managementMode is 'managed' or 'existing'). 'discover' (also when omitted): find one, else create one in the stack. 'managed': create it in the stack. 'use-existing': connect to `endpoint` without creating anything. 'external': Frigg provisions and discovers no database (no RDS/Aurora, no VPC requirement); the app connects to any PostgreSQL through the DATABASE_URL environment variable.",
|
|
309
|
+
"enum": ["discover", "managed", "use-existing", "external"]
|
|
278
310
|
},
|
|
279
311
|
"endpoint": {
|
|
280
312
|
"type": "string",
|
|
@@ -400,8 +432,8 @@
|
|
|
400
432
|
"properties": {
|
|
401
433
|
"fieldLevelEncryptionMethod": {
|
|
402
434
|
"type": "string",
|
|
403
|
-
"description": "Field-level encryption key. 'kms': Frigg creates or discovers a KMS key and sets KMS_KEY_ARN. 'aes': the app supplies AES_KEY_ID and AES_KEY (list both in `environment`). Omitted: no key is provisioned and deployed stages store sensitive fields unencrypted (core logs a warning). Stages dev, test and local never encrypt.",
|
|
404
|
-
"enum": ["kms", "aes"]
|
|
435
|
+
"description": "Field-level encryption key. 'kms': Frigg creates or discovers a KMS key and sets KMS_KEY_ARN. 'aes': the app supplies AES_KEY_ID and AES_KEY (list both in `environment`). 'none': no field-level encryption, chosen explicitly; no key is provisioned and deployed stages store sensitive fields unencrypted. Omitted: no key is provisioned and deployed stages store sensitive fields unencrypted (core logs a warning). Stages dev, test and local never encrypt.",
|
|
436
|
+
"enum": ["kms", "aes", "none"]
|
|
405
437
|
},
|
|
406
438
|
"createResourceIfNoneFound": {
|
|
407
439
|
"type": "boolean",
|
package/api-module-definition.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* API module definition helpers shared by validators and the frigg CLI.
|
|
3
|
-
* Real Definitions carry classes and functions that JSON Schema cannot
|
|
4
|
-
* describe; validators check the serialisable view produced here.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
function isPlainObject(value) {
|
|
8
|
-
if (value === null || typeof value !== 'object') return false;
|
|
9
|
-
const proto = Object.getPrototypeOf(value);
|
|
10
|
-
return proto === Object.prototype || proto === null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Schema descriptor for a JavaScript function (see api-module-definition
|
|
15
|
-
* schema: `{ type: "function", async?: boolean }`).
|
|
16
|
-
*
|
|
17
|
-
* @param {Function} fn
|
|
18
|
-
* @returns {{ type: 'function', async?: boolean }}
|
|
19
|
-
*/
|
|
20
|
-
function toFunctionDescriptor(fn) {
|
|
21
|
-
const descriptor = { type: 'function' };
|
|
22
|
-
if (fn && fn.constructor && fn.constructor.name === 'AsyncFunction') {
|
|
23
|
-
descriptor.async = true;
|
|
24
|
-
}
|
|
25
|
-
return descriptor;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* JSON Schema cannot describe a JavaScript class or function. Validators
|
|
30
|
-
* therefore check this serialisable view: the API class becomes an empty
|
|
31
|
-
* object, functions become `{ type: "function" }` descriptors, and
|
|
32
|
-
* `undefined` env values are dropped (unset `process.env.*` entries).
|
|
33
|
-
*
|
|
34
|
-
* @param {object} definition the `Definition` exported by an API module
|
|
35
|
-
* @returns {object} a view suitable for the api-module-definition schema
|
|
36
|
-
*/
|
|
37
|
-
function toApiModuleDefinitionSchemaView(definition) {
|
|
38
|
-
if (!isPlainObject(definition)) return definition;
|
|
39
|
-
|
|
40
|
-
const view = { ...definition };
|
|
41
|
-
|
|
42
|
-
if (typeof view.API === 'function') {
|
|
43
|
-
view.API = {};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (typeof view.getName === 'function') {
|
|
47
|
-
view.getName = toFunctionDescriptor(view.getName);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (isPlainObject(view.requiredAuthMethods)) {
|
|
51
|
-
const methods = { ...view.requiredAuthMethods };
|
|
52
|
-
for (const [key, value] of Object.entries(methods)) {
|
|
53
|
-
if (typeof value === 'function') {
|
|
54
|
-
methods[key] = toFunctionDescriptor(value);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
view.requiredAuthMethods = methods;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (isPlainObject(view.env)) {
|
|
61
|
-
const env = {};
|
|
62
|
-
for (const [key, value] of Object.entries(view.env)) {
|
|
63
|
-
if (value !== undefined) env[key] = value;
|
|
64
|
-
}
|
|
65
|
-
view.env = env;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (isPlainObject(view.manager)) {
|
|
69
|
-
const manager = { ...view.manager };
|
|
70
|
-
for (const key of ['Entity', 'Credential']) {
|
|
71
|
-
if (typeof manager[key] === 'function') {
|
|
72
|
-
manager[key] = {};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (isPlainObject(manager.methods)) {
|
|
76
|
-
const methods = { ...manager.methods };
|
|
77
|
-
for (const [key, value] of Object.entries(methods)) {
|
|
78
|
-
if (typeof value === 'function') {
|
|
79
|
-
methods[key] = {};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
manager.methods = methods;
|
|
83
|
-
}
|
|
84
|
-
view.manager = manager;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return view;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
module.exports = {
|
|
91
|
-
toApiModuleDefinitionSchemaView,
|
|
92
|
-
toFunctionDescriptor,
|
|
93
|
-
};
|