@zhin.js/runtime 1.0.4 → 1.0.5

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.
@@ -116,10 +116,36 @@ export class ConfigComposer {
116
116
  });
117
117
  }
118
118
  }
119
+ const FRAMEWORK_ROLE_SCHEMA = Object.freeze({
120
+ master: Object.freeze({
121
+ type: ['string', 'number'],
122
+ description: 'Endpoint owner (framework-level master role)',
123
+ }),
124
+ trusted: Object.freeze({
125
+ type: 'array',
126
+ items: Object.freeze({ type: ['string', 'number'] }),
127
+ description: 'Trusted user ID list (framework-level trusted role)',
128
+ }),
129
+ });
130
+ function hasArrayEndpoints(props) {
131
+ const ep = props.endpoints;
132
+ if (!ep || typeof ep !== 'object')
133
+ return false;
134
+ return ep.type === 'array';
135
+ }
119
136
  async function composeNode(node, ownSchemas) {
120
137
  const own = await readOwnSchema(node);
121
138
  ownSchemas.set(node.id, own);
122
139
  const properties = { ...schemaProperties(own) };
140
+ // Adapter plugins (schemas declaring array-typed `endpoints`) get
141
+ // framework-level `master` / `trusted` injected when not already declared.
142
+ if (hasArrayEndpoints(properties)) {
143
+ for (const [key, schema] of Object.entries(FRAMEWORK_ROLE_SCHEMA)) {
144
+ if (!Object.hasOwn(properties, key)) {
145
+ properties[key] = schema;
146
+ }
147
+ }
148
+ }
123
149
  for (const child of node.children) {
124
150
  if (Object.hasOwn(properties, child.instanceKey)) {
125
151
  throw new ConfigSchemaCollisionError(node.id, child.instanceKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/runtime",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Static Plugin graph, generation transaction and HMR Root runtime for Zhin.js",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",