openxiangda-contracts 2.0.0-alpha.91 → 2.0.0-alpha.94
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/dist/native-compiler/compiler.d.ts.map +1 -1
- package/dist/native-compiler/compiler.js +28 -10
- package/dist/native-compiler/compiler.js.map +1 -1
- package/dist/native-compiler/data-field.d.ts +5 -0
- package/dist/native-compiler/data-field.d.ts.map +1 -1
- package/dist/native-compiler/data-field.js +7 -0
- package/dist/native-compiler/data-field.js.map +1 -1
- package/dist/native-compiler/data-surface.js +2 -5
- package/dist/native-compiler/data-surface.js.map +1 -1
- package/dist/native-compiler/index.cjs +4 -4
- package/dist/native-compiler/index.js +4 -4
- package/dist/native-version.d.ts +1 -0
- package/dist/native-version.d.ts.map +1 -1
- package/dist/native-version.js +1 -0
- package/dist/native-version.js.map +1 -1
- package/dist/native.d.ts +4 -0
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js.map +1 -1
- package/dist/schemas.d.ts +248 -8
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +41 -4
- package/dist/schemas.js.map +1 -1
- package/dist/types.d.ts +24 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +11 -0
- package/dist/validation.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../src/native-compiler/compiler.ts"],"names":[],"mappings":"AAOA,OAAO,EAEL,KAAK,kCAAkC,IAAI,uCAAuC,EACnF,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../src/native-compiler/compiler.ts"],"names":[],"mappings":"AAOA,OAAO,EAEL,KAAK,kCAAkC,IAAI,uCAAuC,EACnF,MAAM,aAAa,CAAC;AAwBrB,QAAA,MAAM,iBAAiB,mDAAmD,CAAC;A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CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAG3C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAY5C;AAED,wBAAgB,qCAAqC,CACnD,KAAK,EAAE,gCAAgC,GACtC,iCAAiC,CA6InC;AAED;;;GAGG;AACH,wBAAgB,qCAAqC,CACnD,MAAM,EAAE,UAAU,GACjB,uCAAuC,EAAE,CA4Q3C;AAED,MAAM,WAAW,wBAAwB;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,KAAK,EAAE;IACtD,SAAS,EAAE,UAAU,EAAE,CAAC;IACxB,YAAY,EAAE,UAAU,EAAE,CAAC;IAC3B,aAAa,EAAE,UAAU,EAAE,CAAC;CAC7B,GAAG,wBAAwB,EAAE,CAyI7B"}
|
|
@@ -2,7 +2,7 @@ import { projectNativeDataResourceViewV2 } from './data-surface.js';
|
|
|
2
2
|
import * as crypto from 'crypto';
|
|
3
3
|
import { OPENXIANGDA_COMPILER_CONTRACT_VERSION as OPENXIANGDA_V2_COMPILER_CONTRACT_VERSION, PLATFORM_CAPABILITY_CONTRACT_VERSIONS as OPENXIANGDA_V2_PLATFORM_CAPABILITY_CONTRACT_VERSIONS, } from '../native-version.js';
|
|
4
4
|
import { canonicalJson, sha256Digest as sha256Canonical } from '../canonical.js';
|
|
5
|
-
import { NativeDataFieldContractV2Error, parseNativeDataFieldsV2, parseNativeDataResourceInvariantsV2, validateNativeDataResourceReferencesV2, } from './data-field.js';
|
|
5
|
+
import { NativeDataFieldContractV2Error, nativeFieldRequiresCreateInputV2, parseNativeDataFieldsV2, parseNativeDataResourceInvariantsV2, validateNativeDataResourceReferencesV2, } from './data-field.js';
|
|
6
6
|
import { validateNativeDataResourceSurfaceV2 } from './data-surface.js';
|
|
7
7
|
import { nativeScopeSourceGrantPathSupportedV2, nativeScopeSourceSubjectPathSupportedV2, resolveNativeScopeSourceFieldPathV2, } from './scope-source-field-path.js';
|
|
8
8
|
import { NativeDataPolicyExpressionV2Error, nativeDataPolicyExpressionLeavesV2, nativeDataPolicyExpressionToCnfV2, } from './data-policy-expression.js';
|
|
@@ -1176,7 +1176,7 @@ function compileOperations(config) {
|
|
|
1176
1176
|
}
|
|
1177
1177
|
const code = stableCode(operation.code, `${pointer}/code`);
|
|
1178
1178
|
validateBackendOperationAi(operation.ai, pointer, code, method, declaredResourceCodes);
|
|
1179
|
-
const platformAccess = validateOperationPlatformAccess(operation.platformAccess, `${pointer}/platformAccess`, declaredResources, declaredWorkflowCodes);
|
|
1179
|
+
const platformAccess = validateOperationPlatformAccess(operation.platformAccess, `${pointer}/platformAccess`, declaredResources, declaredWorkflowCodes, new Set(config.authz.roles.map((role) => String(role.code))));
|
|
1180
1180
|
return {
|
|
1181
1181
|
code,
|
|
1182
1182
|
method,
|
|
@@ -1193,15 +1193,27 @@ function compileOperations(config) {
|
|
|
1193
1193
|
};
|
|
1194
1194
|
}), (item) => item.code);
|
|
1195
1195
|
}
|
|
1196
|
-
function validateOperationPlatformAccess(value, pointer, declaredResources, declaredWorkflowCodes) {
|
|
1196
|
+
function validateOperationPlatformAccess(value, pointer, declaredResources, declaredWorkflowCodes, declaredRoleCodes) {
|
|
1197
1197
|
if (value === undefined)
|
|
1198
1198
|
return null;
|
|
1199
1199
|
const access = object(value, pointer);
|
|
1200
|
-
exactKeys(access, ['directory', 'managedFiles', 'managedFileCopies', 'notification', 'workflow'], pointer, true);
|
|
1200
|
+
exactKeys(access, ['directory', 'managedFiles', 'managedFileCopies', 'notification', 'workflow', 'roleAssertions'], pointer, true);
|
|
1201
1201
|
if (Object.keys(access).length === 0) {
|
|
1202
1202
|
fail('NATIVE_OPERATION_PLATFORM_ACCESS_EMPTY', pointer);
|
|
1203
1203
|
}
|
|
1204
1204
|
const result = {};
|
|
1205
|
+
if (access.roleAssertions !== undefined) {
|
|
1206
|
+
const assertions = object(access.roleAssertions, `${pointer}/roleAssertions`);
|
|
1207
|
+
exactKeys(assertions, ['roleCodes'], `${pointer}/roleAssertions`);
|
|
1208
|
+
const codes = uniqueStrings(assertions.roleCodes, `${pointer}/roleAssertions/roleCodes`, 20);
|
|
1209
|
+
if (!codes.length)
|
|
1210
|
+
fail('NATIVE_OPERATION_ROLE_ASSERTIONS_REQUIRED', `${pointer}/roleAssertions/roleCodes`);
|
|
1211
|
+
codes.forEach((code, index) => {
|
|
1212
|
+
if (!declaredRoleCodes.has(code))
|
|
1213
|
+
fail('NATIVE_ROLE_REFERENCE_MISSING', `${pointer}/roleAssertions/roleCodes/${index}`);
|
|
1214
|
+
});
|
|
1215
|
+
result.roleAssertions = { roleCodes: uniqueSorted(codes) };
|
|
1216
|
+
}
|
|
1205
1217
|
if (access.directory !== undefined) {
|
|
1206
1218
|
const directory = object(access.directory, `${pointer}/directory`);
|
|
1207
1219
|
exactKeys(directory, ['mode', 'fields'], `${pointer}/directory`);
|
|
@@ -1646,15 +1658,21 @@ function validateAnonymousPublicAccess(value, config, pointer) {
|
|
|
1646
1658
|
const nativeCreate = String(resourceSurface.mutationOwner || 'native') === 'native' &&
|
|
1647
1659
|
resourceSurface.generated?.create !== false;
|
|
1648
1660
|
const requiredCreateFields = resource.schema.fields
|
|
1649
|
-
.filter((field) => field.
|
|
1650
|
-
String(field.type || '') !== 'serial-number' &&
|
|
1651
|
-
resourceSurfaceFields[field.code]?.system !== true)
|
|
1661
|
+
.filter((field) => nativeFieldRequiresCreateInputV2(field, resourceSurfaceFields[field.code]))
|
|
1652
1662
|
.map((field) => String(field.code));
|
|
1653
|
-
if (operations.includes('create') &&
|
|
1654
|
-
(!nativeCreate ||
|
|
1655
|
-
requiredCreateFields.some((field) => !fields.includes(field) || !requiredFields.includes(field)))) {
|
|
1663
|
+
if (operations.includes('create') && !nativeCreate) {
|
|
1656
1664
|
fail('NATIVE_PUBLIC_CREATE_FIELDS_INCOMPLETE', `${policyPointer}/fields`);
|
|
1657
1665
|
}
|
|
1666
|
+
if (operations.includes('create')) {
|
|
1667
|
+
for (const fieldCode of requiredCreateFields) {
|
|
1668
|
+
const missingSet = !fields.includes(fieldCode)
|
|
1669
|
+
? 'fields'
|
|
1670
|
+
: !requiredFields.includes(fieldCode) ? 'requiredFields' : null;
|
|
1671
|
+
if (missingSet) {
|
|
1672
|
+
fail('NATIVE_PUBLIC_CREATE_FIELDS_INCOMPLETE', `${policyPointer}/${missingSet}`, { resourceCode, fieldCode });
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1658
1676
|
if (Object.prototype.hasOwnProperty.call(policy, 'draft')) {
|
|
1659
1677
|
const draft = object(policy.draft, `${policyPointer}/draft`);
|
|
1660
1678
|
exactKeys(draft, ['enabled', 'inactivityTtlSeconds', 'maxBytes'], `${policyPointer}/draft`);
|