@tiangong-lca/pcr 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/NOTICE.md +5 -0
- package/README.md +107 -2
- package/node_modules/ajv/.runkit_example.js +23 -0
- package/node_modules/ajv/LICENSE +22 -0
- package/node_modules/ajv/README.md +207 -0
- package/node_modules/ajv/dist/2019.d.ts +19 -0
- package/node_modules/ajv/dist/2019.js +61 -0
- package/node_modules/ajv/dist/2019.js.map +1 -0
- package/node_modules/ajv/dist/2020.d.ts +19 -0
- package/node_modules/ajv/dist/2020.js +55 -0
- package/node_modules/ajv/dist/2020.js.map +1 -0
- package/node_modules/ajv/dist/ajv.d.ts +18 -0
- package/node_modules/ajv/dist/ajv.js +50 -0
- package/node_modules/ajv/dist/ajv.js.map +1 -0
- package/node_modules/ajv/dist/compile/codegen/code.d.ts +40 -0
- package/node_modules/ajv/dist/compile/codegen/code.js +156 -0
- package/node_modules/ajv/dist/compile/codegen/code.js.map +1 -0
- package/node_modules/ajv/dist/compile/codegen/index.d.ts +79 -0
- package/node_modules/ajv/dist/compile/codegen/index.js +697 -0
- package/node_modules/ajv/dist/compile/codegen/index.js.map +1 -0
- package/node_modules/ajv/dist/compile/codegen/scope.d.ts +79 -0
- package/node_modules/ajv/dist/compile/codegen/scope.js +143 -0
- package/node_modules/ajv/dist/compile/codegen/scope.js.map +1 -0
- package/node_modules/ajv/dist/compile/errors.d.ts +13 -0
- package/node_modules/ajv/dist/compile/errors.js +123 -0
- package/node_modules/ajv/dist/compile/errors.js.map +1 -0
- package/node_modules/ajv/dist/compile/index.d.ts +80 -0
- package/node_modules/ajv/dist/compile/index.js +242 -0
- package/node_modules/ajv/dist/compile/index.js.map +1 -0
- package/node_modules/ajv/dist/compile/jtd/parse.d.ts +4 -0
- package/node_modules/ajv/dist/compile/jtd/parse.js +350 -0
- package/node_modules/ajv/dist/compile/jtd/parse.js.map +1 -0
- package/node_modules/ajv/dist/compile/jtd/serialize.d.ts +4 -0
- package/node_modules/ajv/dist/compile/jtd/serialize.js +236 -0
- package/node_modules/ajv/dist/compile/jtd/serialize.js.map +1 -0
- package/node_modules/ajv/dist/compile/jtd/types.d.ts +6 -0
- package/node_modules/ajv/dist/compile/jtd/types.js +14 -0
- package/node_modules/ajv/dist/compile/jtd/types.js.map +1 -0
- package/node_modules/ajv/dist/compile/names.d.ts +20 -0
- package/node_modules/ajv/dist/compile/names.js +28 -0
- package/node_modules/ajv/dist/compile/names.js.map +1 -0
- package/node_modules/ajv/dist/compile/ref_error.d.ts +6 -0
- package/node_modules/ajv/dist/compile/ref_error.js +12 -0
- package/node_modules/ajv/dist/compile/ref_error.js.map +1 -0
- package/node_modules/ajv/dist/compile/resolve.d.ts +12 -0
- package/node_modules/ajv/dist/compile/resolve.js +155 -0
- package/node_modules/ajv/dist/compile/resolve.js.map +1 -0
- package/node_modules/ajv/dist/compile/rules.d.ts +28 -0
- package/node_modules/ajv/dist/compile/rules.js +26 -0
- package/node_modules/ajv/dist/compile/rules.js.map +1 -0
- package/node_modules/ajv/dist/compile/util.d.ts +40 -0
- package/node_modules/ajv/dist/compile/util.js +178 -0
- package/node_modules/ajv/dist/compile/util.js.map +1 -0
- package/node_modules/ajv/dist/compile/validate/applicability.d.ts +6 -0
- package/node_modules/ajv/dist/compile/validate/applicability.js +19 -0
- package/node_modules/ajv/dist/compile/validate/applicability.js.map +1 -0
- package/node_modules/ajv/dist/compile/validate/boolSchema.d.ts +4 -0
- package/node_modules/ajv/dist/compile/validate/boolSchema.js +50 -0
- package/node_modules/ajv/dist/compile/validate/boolSchema.js.map +1 -0
- package/node_modules/ajv/dist/compile/validate/dataType.d.ts +17 -0
- package/node_modules/ajv/dist/compile/validate/dataType.js +203 -0
- package/node_modules/ajv/dist/compile/validate/dataType.js.map +1 -0
- package/node_modules/ajv/dist/compile/validate/defaults.d.ts +2 -0
- package/node_modules/ajv/dist/compile/validate/defaults.js +35 -0
- package/node_modules/ajv/dist/compile/validate/defaults.js.map +1 -0
- package/node_modules/ajv/dist/compile/validate/index.d.ts +42 -0
- package/node_modules/ajv/dist/compile/validate/index.js +520 -0
- package/node_modules/ajv/dist/compile/validate/index.js.map +1 -0
- package/node_modules/ajv/dist/compile/validate/keyword.d.ts +8 -0
- package/node_modules/ajv/dist/compile/validate/keyword.js +124 -0
- package/node_modules/ajv/dist/compile/validate/keyword.js.map +1 -0
- package/node_modules/ajv/dist/compile/validate/subschema.d.ts +47 -0
- package/node_modules/ajv/dist/compile/validate/subschema.js +81 -0
- package/node_modules/ajv/dist/compile/validate/subschema.js.map +1 -0
- package/node_modules/ajv/dist/core.d.ts +174 -0
- package/node_modules/ajv/dist/core.js +618 -0
- package/node_modules/ajv/dist/core.js.map +1 -0
- package/node_modules/ajv/dist/jtd.d.ts +47 -0
- package/node_modules/ajv/dist/jtd.js +72 -0
- package/node_modules/ajv/dist/jtd.js.map +1 -0
- package/node_modules/ajv/dist/refs/data.json +13 -0
- package/node_modules/ajv/dist/refs/json-schema-2019-09/index.d.ts +2 -0
- package/node_modules/ajv/dist/refs/json-schema-2019-09/index.js +28 -0
- package/node_modules/ajv/dist/refs/json-schema-2019-09/index.js.map +1 -0
- package/node_modules/ajv/dist/refs/json-schema-2019-09/meta/applicator.json +53 -0
- package/node_modules/ajv/dist/refs/json-schema-2019-09/meta/content.json +17 -0
- package/node_modules/ajv/dist/refs/json-schema-2019-09/meta/core.json +57 -0
- package/node_modules/ajv/dist/refs/json-schema-2019-09/meta/format.json +14 -0
- package/node_modules/ajv/dist/refs/json-schema-2019-09/meta/meta-data.json +37 -0
- package/node_modules/ajv/dist/refs/json-schema-2019-09/meta/validation.json +90 -0
- package/node_modules/ajv/dist/refs/json-schema-2019-09/schema.json +39 -0
- package/node_modules/ajv/dist/refs/json-schema-2020-12/index.d.ts +2 -0
- package/node_modules/ajv/dist/refs/json-schema-2020-12/index.js +30 -0
- package/node_modules/ajv/dist/refs/json-schema-2020-12/index.js.map +1 -0
- package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/applicator.json +48 -0
- package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/content.json +17 -0
- package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/core.json +51 -0
- package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/format-annotation.json +14 -0
- package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/meta-data.json +37 -0
- package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/unevaluated.json +15 -0
- package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.json +90 -0
- package/node_modules/ajv/dist/refs/json-schema-2020-12/schema.json +55 -0
- package/node_modules/ajv/dist/refs/json-schema-draft-06.json +137 -0
- package/node_modules/ajv/dist/refs/json-schema-draft-07.json +151 -0
- package/node_modules/ajv/dist/refs/json-schema-secure.json +88 -0
- package/node_modules/ajv/dist/refs/jtd-schema.d.ts +3 -0
- package/node_modules/ajv/dist/refs/jtd-schema.js +118 -0
- package/node_modules/ajv/dist/refs/jtd-schema.js.map +1 -0
- package/node_modules/ajv/dist/runtime/equal.d.ts +6 -0
- package/node_modules/ajv/dist/runtime/equal.js +7 -0
- package/node_modules/ajv/dist/runtime/equal.js.map +1 -0
- package/node_modules/ajv/dist/runtime/parseJson.d.ts +18 -0
- package/node_modules/ajv/dist/runtime/parseJson.js +185 -0
- package/node_modules/ajv/dist/runtime/parseJson.js.map +1 -0
- package/node_modules/ajv/dist/runtime/quote.d.ts +5 -0
- package/node_modules/ajv/dist/runtime/quote.js +30 -0
- package/node_modules/ajv/dist/runtime/quote.js.map +1 -0
- package/node_modules/ajv/dist/runtime/re2.d.ts +6 -0
- package/node_modules/ajv/dist/runtime/re2.js +6 -0
- package/node_modules/ajv/dist/runtime/re2.js.map +1 -0
- package/node_modules/ajv/dist/runtime/timestamp.d.ts +5 -0
- package/node_modules/ajv/dist/runtime/timestamp.js +42 -0
- package/node_modules/ajv/dist/runtime/timestamp.js.map +1 -0
- package/node_modules/ajv/dist/runtime/ucs2length.d.ts +5 -0
- package/node_modules/ajv/dist/runtime/ucs2length.js +24 -0
- package/node_modules/ajv/dist/runtime/ucs2length.js.map +1 -0
- package/node_modules/ajv/dist/runtime/uri.d.ts +6 -0
- package/node_modules/ajv/dist/runtime/uri.js +6 -0
- package/node_modules/ajv/dist/runtime/uri.js.map +1 -0
- package/node_modules/ajv/dist/runtime/validation_error.d.ts +7 -0
- package/node_modules/ajv/dist/runtime/validation_error.js +11 -0
- package/node_modules/ajv/dist/runtime/validation_error.js.map +1 -0
- package/node_modules/ajv/dist/standalone/index.d.ts +6 -0
- package/node_modules/ajv/dist/standalone/index.js +90 -0
- package/node_modules/ajv/dist/standalone/index.js.map +1 -0
- package/node_modules/ajv/dist/standalone/instance.d.ts +12 -0
- package/node_modules/ajv/dist/standalone/instance.js +35 -0
- package/node_modules/ajv/dist/standalone/instance.js.map +1 -0
- package/node_modules/ajv/dist/types/index.d.ts +183 -0
- package/node_modules/ajv/dist/types/index.js +3 -0
- package/node_modules/ajv/dist/types/index.js.map +1 -0
- package/node_modules/ajv/dist/types/json-schema.d.ts +125 -0
- package/node_modules/ajv/dist/types/json-schema.js +3 -0
- package/node_modules/ajv/dist/types/json-schema.js.map +1 -0
- package/node_modules/ajv/dist/types/jtd-schema.d.ts +174 -0
- package/node_modules/ajv/dist/types/jtd-schema.js +3 -0
- package/node_modules/ajv/dist/types/jtd-schema.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/applicator/additionalItems.d.ts +8 -0
- package/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +49 -0
- package/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.d.ts +6 -0
- package/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +106 -0
- package/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/applicator/allOf.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/applicator/allOf.js +23 -0
- package/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/applicator/anyOf.d.ts +4 -0
- package/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +12 -0
- package/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/applicator/contains.d.ts +7 -0
- package/node_modules/ajv/dist/vocabularies/applicator/contains.js +95 -0
- package/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/applicator/dependencies.d.ts +21 -0
- package/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +85 -0
- package/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.js +11 -0
- package/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/applicator/if.d.ts +6 -0
- package/node_modules/ajv/dist/vocabularies/applicator/if.js +66 -0
- package/node_modules/ajv/dist/vocabularies/applicator/if.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/applicator/index.d.ts +13 -0
- package/node_modules/ajv/dist/vocabularies/applicator/index.js +44 -0
- package/node_modules/ajv/dist/vocabularies/applicator/index.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/applicator/items.d.ts +5 -0
- package/node_modules/ajv/dist/vocabularies/applicator/items.js +52 -0
- package/node_modules/ajv/dist/vocabularies/applicator/items.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/applicator/items2020.d.ts +6 -0
- package/node_modules/ajv/dist/vocabularies/applicator/items2020.js +30 -0
- package/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/applicator/not.d.ts +4 -0
- package/node_modules/ajv/dist/vocabularies/applicator/not.js +26 -0
- package/node_modules/ajv/dist/vocabularies/applicator/not.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/applicator/oneOf.d.ts +6 -0
- package/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +60 -0
- package/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/applicator/patternProperties.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +75 -0
- package/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/applicator/prefixItems.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +12 -0
- package/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/applicator/properties.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/applicator/properties.js +54 -0
- package/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/applicator/propertyNames.d.ts +6 -0
- package/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +38 -0
- package/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/applicator/thenElse.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +13 -0
- package/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/code.d.ts +17 -0
- package/node_modules/ajv/dist/vocabularies/code.js +131 -0
- package/node_modules/ajv/dist/vocabularies/code.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/core/id.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/core/id.js +10 -0
- package/node_modules/ajv/dist/vocabularies/core/id.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/core/index.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/core/index.js +16 -0
- package/node_modules/ajv/dist/vocabularies/core/index.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/core/ref.d.ts +8 -0
- package/node_modules/ajv/dist/vocabularies/core/ref.js +122 -0
- package/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/discriminator/index.d.ts +5 -0
- package/node_modules/ajv/dist/vocabularies/discriminator/index.js +104 -0
- package/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/discriminator/types.d.ts +10 -0
- package/node_modules/ajv/dist/vocabularies/discriminator/types.js +9 -0
- package/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/draft2020.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/draft2020.js +23 -0
- package/node_modules/ajv/dist/vocabularies/draft2020.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/draft7.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/draft7.js +17 -0
- package/node_modules/ajv/dist/vocabularies/draft7.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.d.ts +5 -0
- package/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js +30 -0
- package/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.d.ts +5 -0
- package/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js +51 -0
- package/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/dynamic/index.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/dynamic/index.js +9 -0
- package/node_modules/ajv/dist/vocabularies/dynamic/index.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.js +16 -0
- package/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.js +10 -0
- package/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/errors.d.ts +9 -0
- package/node_modules/ajv/dist/vocabularies/errors.js +3 -0
- package/node_modules/ajv/dist/vocabularies/errors.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/format/format.d.ts +8 -0
- package/node_modules/ajv/dist/vocabularies/format/format.js +92 -0
- package/node_modules/ajv/dist/vocabularies/format/format.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/format/index.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/format/index.js +6 -0
- package/node_modules/ajv/dist/vocabularies/format/index.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/jtd/discriminator.d.ts +6 -0
- package/node_modules/ajv/dist/vocabularies/jtd/discriminator.js +71 -0
- package/node_modules/ajv/dist/vocabularies/jtd/discriminator.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/jtd/elements.d.ts +5 -0
- package/node_modules/ajv/dist/vocabularies/jtd/elements.js +24 -0
- package/node_modules/ajv/dist/vocabularies/jtd/elements.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/jtd/enum.d.ts +6 -0
- package/node_modules/ajv/dist/vocabularies/jtd/enum.js +43 -0
- package/node_modules/ajv/dist/vocabularies/jtd/enum.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/jtd/error.d.ts +9 -0
- package/node_modules/ajv/dist/vocabularies/jtd/error.js +20 -0
- package/node_modules/ajv/dist/vocabularies/jtd/error.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/jtd/index.d.ts +10 -0
- package/node_modules/ajv/dist/vocabularies/jtd/index.js +29 -0
- package/node_modules/ajv/dist/vocabularies/jtd/index.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/jtd/metadata.d.ts +5 -0
- package/node_modules/ajv/dist/vocabularies/jtd/metadata.js +25 -0
- package/node_modules/ajv/dist/vocabularies/jtd/metadata.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/jtd/nullable.d.ts +4 -0
- package/node_modules/ajv/dist/vocabularies/jtd/nullable.js +22 -0
- package/node_modules/ajv/dist/vocabularies/jtd/nullable.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/jtd/optionalProperties.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/jtd/optionalProperties.js +15 -0
- package/node_modules/ajv/dist/vocabularies/jtd/optionalProperties.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/jtd/properties.d.ts +22 -0
- package/node_modules/ajv/dist/vocabularies/jtd/properties.js +149 -0
- package/node_modules/ajv/dist/vocabularies/jtd/properties.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/jtd/ref.d.ts +4 -0
- package/node_modules/ajv/dist/vocabularies/jtd/ref.js +67 -0
- package/node_modules/ajv/dist/vocabularies/jtd/ref.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/jtd/type.d.ts +10 -0
- package/node_modules/ajv/dist/vocabularies/jtd/type.js +69 -0
- package/node_modules/ajv/dist/vocabularies/jtd/type.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/jtd/union.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/jtd/union.js +12 -0
- package/node_modules/ajv/dist/vocabularies/jtd/union.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/jtd/values.d.ts +5 -0
- package/node_modules/ajv/dist/vocabularies/jtd/values.js +51 -0
- package/node_modules/ajv/dist/vocabularies/jtd/values.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/metadata.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/metadata.js +18 -0
- package/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/next.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/next.js +8 -0
- package/node_modules/ajv/dist/vocabularies/next.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/unevaluated/index.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/unevaluated/index.js +7 -0
- package/node_modules/ajv/dist/vocabularies/unevaluated/index.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.d.ts +6 -0
- package/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js +40 -0
- package/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.d.ts +6 -0
- package/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +65 -0
- package/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/validation/const.d.ts +6 -0
- package/node_modules/ajv/dist/vocabularies/validation/const.js +25 -0
- package/node_modules/ajv/dist/vocabularies/validation/const.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/validation/dependentRequired.d.ts +5 -0
- package/node_modules/ajv/dist/vocabularies/validation/dependentRequired.js +12 -0
- package/node_modules/ajv/dist/vocabularies/validation/dependentRequired.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/validation/enum.d.ts +8 -0
- package/node_modules/ajv/dist/vocabularies/validation/enum.js +48 -0
- package/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/validation/index.d.ts +16 -0
- package/node_modules/ajv/dist/vocabularies/validation/index.js +33 -0
- package/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/validation/limitContains.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/validation/limitContains.js +15 -0
- package/node_modules/ajv/dist/vocabularies/validation/limitContains.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/validation/limitItems.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/validation/limitItems.js +24 -0
- package/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/validation/limitLength.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/validation/limitLength.js +27 -0
- package/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/validation/limitNumber.d.ts +11 -0
- package/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +27 -0
- package/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/validation/limitProperties.d.ts +3 -0
- package/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +24 -0
- package/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/validation/multipleOf.d.ts +8 -0
- package/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +26 -0
- package/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/validation/pattern.d.ts +8 -0
- package/node_modules/ajv/dist/vocabularies/validation/pattern.js +33 -0
- package/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/validation/required.d.ts +8 -0
- package/node_modules/ajv/dist/vocabularies/validation/required.js +79 -0
- package/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -0
- package/node_modules/ajv/dist/vocabularies/validation/uniqueItems.d.ts +9 -0
- package/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +64 -0
- package/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +1 -0
- package/node_modules/ajv/lib/2019.ts +81 -0
- package/node_modules/ajv/lib/2020.ts +75 -0
- package/node_modules/ajv/lib/ajv.ts +70 -0
- package/node_modules/ajv/lib/compile/codegen/code.ts +169 -0
- package/node_modules/ajv/lib/compile/codegen/index.ts +852 -0
- package/node_modules/ajv/lib/compile/codegen/scope.ts +215 -0
- package/node_modules/ajv/lib/compile/errors.ts +184 -0
- package/node_modules/ajv/lib/compile/index.ts +324 -0
- package/node_modules/ajv/lib/compile/jtd/parse.ts +411 -0
- package/node_modules/ajv/lib/compile/jtd/serialize.ts +277 -0
- package/node_modules/ajv/lib/compile/jtd/types.ts +16 -0
- package/node_modules/ajv/lib/compile/names.ts +27 -0
- package/node_modules/ajv/lib/compile/ref_error.ts +13 -0
- package/node_modules/ajv/lib/compile/resolve.ts +149 -0
- package/node_modules/ajv/lib/compile/rules.ts +50 -0
- package/node_modules/ajv/lib/compile/util.ts +213 -0
- package/node_modules/ajv/lib/compile/validate/applicability.ts +22 -0
- package/node_modules/ajv/lib/compile/validate/boolSchema.ts +47 -0
- package/node_modules/ajv/lib/compile/validate/dataType.ts +230 -0
- package/node_modules/ajv/lib/compile/validate/defaults.ts +32 -0
- package/node_modules/ajv/lib/compile/validate/index.ts +582 -0
- package/node_modules/ajv/lib/compile/validate/keyword.ts +171 -0
- package/node_modules/ajv/lib/compile/validate/subschema.ts +135 -0
- package/node_modules/ajv/lib/core.ts +892 -0
- package/node_modules/ajv/lib/jtd.ts +132 -0
- package/node_modules/ajv/lib/refs/data.json +13 -0
- package/node_modules/ajv/lib/refs/json-schema-2019-09/index.ts +28 -0
- package/node_modules/ajv/lib/refs/json-schema-2019-09/meta/applicator.json +53 -0
- package/node_modules/ajv/lib/refs/json-schema-2019-09/meta/content.json +17 -0
- package/node_modules/ajv/lib/refs/json-schema-2019-09/meta/core.json +57 -0
- package/node_modules/ajv/lib/refs/json-schema-2019-09/meta/format.json +14 -0
- package/node_modules/ajv/lib/refs/json-schema-2019-09/meta/meta-data.json +37 -0
- package/node_modules/ajv/lib/refs/json-schema-2019-09/meta/validation.json +90 -0
- package/node_modules/ajv/lib/refs/json-schema-2019-09/schema.json +39 -0
- package/node_modules/ajv/lib/refs/json-schema-2020-12/index.ts +30 -0
- package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/applicator.json +48 -0
- package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/content.json +17 -0
- package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/core.json +51 -0
- package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/format-annotation.json +14 -0
- package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/meta-data.json +37 -0
- package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/unevaluated.json +15 -0
- package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/validation.json +90 -0
- package/node_modules/ajv/lib/refs/json-schema-2020-12/schema.json +55 -0
- package/node_modules/ajv/lib/refs/json-schema-draft-06.json +137 -0
- package/node_modules/ajv/lib/refs/json-schema-draft-07.json +151 -0
- package/node_modules/ajv/lib/refs/json-schema-secure.json +88 -0
- package/node_modules/ajv/lib/refs/jtd-schema.ts +130 -0
- package/node_modules/ajv/lib/runtime/equal.ts +7 -0
- package/node_modules/ajv/lib/runtime/parseJson.ts +177 -0
- package/node_modules/ajv/lib/runtime/quote.ts +31 -0
- package/node_modules/ajv/lib/runtime/re2.ts +6 -0
- package/node_modules/ajv/lib/runtime/timestamp.ts +46 -0
- package/node_modules/ajv/lib/runtime/ucs2length.ts +20 -0
- package/node_modules/ajv/lib/runtime/uri.ts +6 -0
- package/node_modules/ajv/lib/runtime/validation_error.ts +13 -0
- package/node_modules/ajv/lib/standalone/index.ts +100 -0
- package/node_modules/ajv/lib/standalone/instance.ts +36 -0
- package/node_modules/ajv/lib/types/index.ts +244 -0
- package/node_modules/ajv/lib/types/json-schema.ts +187 -0
- package/node_modules/ajv/lib/types/jtd-schema.ts +273 -0
- package/node_modules/ajv/lib/vocabularies/applicator/additionalItems.ts +56 -0
- package/node_modules/ajv/lib/vocabularies/applicator/additionalProperties.ts +118 -0
- package/node_modules/ajv/lib/vocabularies/applicator/allOf.ts +22 -0
- package/node_modules/ajv/lib/vocabularies/applicator/anyOf.ts +14 -0
- package/node_modules/ajv/lib/vocabularies/applicator/contains.ts +109 -0
- package/node_modules/ajv/lib/vocabularies/applicator/dependencies.ts +112 -0
- package/node_modules/ajv/lib/vocabularies/applicator/dependentSchemas.ts +11 -0
- package/node_modules/ajv/lib/vocabularies/applicator/if.ts +80 -0
- package/node_modules/ajv/lib/vocabularies/applicator/index.ts +53 -0
- package/node_modules/ajv/lib/vocabularies/applicator/items.ts +59 -0
- package/node_modules/ajv/lib/vocabularies/applicator/items2020.ts +36 -0
- package/node_modules/ajv/lib/vocabularies/applicator/not.ts +38 -0
- package/node_modules/ajv/lib/vocabularies/applicator/oneOf.ts +82 -0
- package/node_modules/ajv/lib/vocabularies/applicator/patternProperties.ts +91 -0
- package/node_modules/ajv/lib/vocabularies/applicator/prefixItems.ts +12 -0
- package/node_modules/ajv/lib/vocabularies/applicator/properties.ts +57 -0
- package/node_modules/ajv/lib/vocabularies/applicator/propertyNames.ts +50 -0
- package/node_modules/ajv/lib/vocabularies/applicator/thenElse.ts +13 -0
- package/node_modules/ajv/lib/vocabularies/code.ts +168 -0
- package/node_modules/ajv/lib/vocabularies/core/id.ts +10 -0
- package/node_modules/ajv/lib/vocabularies/core/index.ts +16 -0
- package/node_modules/ajv/lib/vocabularies/core/ref.ts +129 -0
- package/node_modules/ajv/lib/vocabularies/discriminator/index.ts +113 -0
- package/node_modules/ajv/lib/vocabularies/discriminator/types.ts +12 -0
- package/node_modules/ajv/lib/vocabularies/draft2020.ts +23 -0
- package/node_modules/ajv/lib/vocabularies/draft7.ts +17 -0
- package/node_modules/ajv/lib/vocabularies/dynamic/dynamicAnchor.ts +31 -0
- package/node_modules/ajv/lib/vocabularies/dynamic/dynamicRef.ts +51 -0
- package/node_modules/ajv/lib/vocabularies/dynamic/index.ts +9 -0
- package/node_modules/ajv/lib/vocabularies/dynamic/recursiveAnchor.ts +14 -0
- package/node_modules/ajv/lib/vocabularies/dynamic/recursiveRef.ts +10 -0
- package/node_modules/ajv/lib/vocabularies/errors.ts +18 -0
- package/node_modules/ajv/lib/vocabularies/format/format.ts +120 -0
- package/node_modules/ajv/lib/vocabularies/format/index.ts +6 -0
- package/node_modules/ajv/lib/vocabularies/jtd/discriminator.ts +89 -0
- package/node_modules/ajv/lib/vocabularies/jtd/elements.ts +32 -0
- package/node_modules/ajv/lib/vocabularies/jtd/enum.ts +45 -0
- package/node_modules/ajv/lib/vocabularies/jtd/error.ts +23 -0
- package/node_modules/ajv/lib/vocabularies/jtd/index.ts +37 -0
- package/node_modules/ajv/lib/vocabularies/jtd/metadata.ts +24 -0
- package/node_modules/ajv/lib/vocabularies/jtd/nullable.ts +21 -0
- package/node_modules/ajv/lib/vocabularies/jtd/optionalProperties.ts +15 -0
- package/node_modules/ajv/lib/vocabularies/jtd/properties.ts +184 -0
- package/node_modules/ajv/lib/vocabularies/jtd/ref.ts +76 -0
- package/node_modules/ajv/lib/vocabularies/jtd/type.ts +75 -0
- package/node_modules/ajv/lib/vocabularies/jtd/union.ts +12 -0
- package/node_modules/ajv/lib/vocabularies/jtd/values.ts +58 -0
- package/node_modules/ajv/lib/vocabularies/metadata.ts +17 -0
- package/node_modules/ajv/lib/vocabularies/next.ts +8 -0
- package/node_modules/ajv/lib/vocabularies/unevaluated/index.ts +7 -0
- package/node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedItems.ts +47 -0
- package/node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedProperties.ts +85 -0
- package/node_modules/ajv/lib/vocabularies/validation/const.ts +28 -0
- package/node_modules/ajv/lib/vocabularies/validation/dependentRequired.ts +23 -0
- package/node_modules/ajv/lib/vocabularies/validation/enum.ts +54 -0
- package/node_modules/ajv/lib/vocabularies/validation/index.ts +49 -0
- package/node_modules/ajv/lib/vocabularies/validation/limitContains.ts +16 -0
- package/node_modules/ajv/lib/vocabularies/validation/limitItems.ts +26 -0
- package/node_modules/ajv/lib/vocabularies/validation/limitLength.ts +30 -0
- package/node_modules/ajv/lib/vocabularies/validation/limitNumber.ts +42 -0
- package/node_modules/ajv/lib/vocabularies/validation/limitProperties.ts +26 -0
- package/node_modules/ajv/lib/vocabularies/validation/multipleOf.ts +34 -0
- package/node_modules/ajv/lib/vocabularies/validation/pattern.ts +39 -0
- package/node_modules/ajv/lib/vocabularies/validation/required.ts +98 -0
- package/node_modules/ajv/lib/vocabularies/validation/uniqueItems.ts +79 -0
- package/node_modules/ajv/package.json +126 -0
- package/node_modules/fast-deep-equal/LICENSE +21 -0
- package/node_modules/fast-deep-equal/README.md +96 -0
- package/node_modules/fast-deep-equal/es6/index.d.ts +2 -0
- package/node_modules/fast-deep-equal/es6/index.js +72 -0
- package/node_modules/fast-deep-equal/es6/react.d.ts +2 -0
- package/node_modules/fast-deep-equal/es6/react.js +79 -0
- package/node_modules/fast-deep-equal/index.d.ts +4 -0
- package/node_modules/fast-deep-equal/index.js +46 -0
- package/node_modules/fast-deep-equal/package.json +61 -0
- package/node_modules/fast-deep-equal/react.d.ts +2 -0
- package/node_modules/fast-deep-equal/react.js +53 -0
- package/node_modules/fast-uri/.gitattributes +2 -0
- package/node_modules/fast-uri/.github/dependabot.yml +13 -0
- package/node_modules/fast-uri/.github/workflows/ci.yml +106 -0
- package/node_modules/fast-uri/.github/workflows/lock-threads.yml +19 -0
- package/node_modules/fast-uri/.github/workflows/package-manager-ci.yml +24 -0
- package/node_modules/fast-uri/LICENSE +30 -0
- package/node_modules/fast-uri/README.md +152 -0
- package/node_modules/fast-uri/benchmark/benchmark.mjs +159 -0
- package/node_modules/fast-uri/benchmark/equal.mjs +51 -0
- package/node_modules/fast-uri/benchmark/non-simple-domain.mjs +22 -0
- package/node_modules/fast-uri/benchmark/package.json +17 -0
- package/node_modules/fast-uri/benchmark/string-array-to-hex-stripped.mjs +24 -0
- package/node_modules/fast-uri/benchmark/ws-is-secure.mjs +65 -0
- package/node_modules/fast-uri/eslint.config.js +6 -0
- package/node_modules/fast-uri/index.js +627 -0
- package/node_modules/fast-uri/lib/schemes.js +272 -0
- package/node_modules/fast-uri/lib/utils.js +747 -0
- package/node_modules/fast-uri/package.json +68 -0
- package/node_modules/fast-uri/test/ajv.test.js +43 -0
- package/node_modules/fast-uri/test/component-safe-serialization.test.js +163 -0
- package/node_modules/fast-uri/test/equal.test.js +145 -0
- package/node_modules/fast-uri/test/fixtures/uri-js-parse.json +503 -0
- package/node_modules/fast-uri/test/fixtures/uri-js-serialize.json +120 -0
- package/node_modules/fast-uri/test/ipv6-canonical.test.js +34 -0
- package/node_modules/fast-uri/test/ipv6-validation.test.js +124 -0
- package/node_modules/fast-uri/test/malformed-percent.test.js +77 -0
- package/node_modules/fast-uri/test/malformed-urn.test.js +61 -0
- package/node_modules/fast-uri/test/parse.test.js +327 -0
- package/node_modules/fast-uri/test/query-fragment-normalization.test.js +33 -0
- package/node_modules/fast-uri/test/reserved-path-normalization.test.js +109 -0
- package/node_modules/fast-uri/test/resolve.test.js +87 -0
- package/node_modules/fast-uri/test/rfc-3986.test.js +90 -0
- package/node_modules/fast-uri/test/scheme-validation.test.js +124 -0
- package/node_modules/fast-uri/test/security-normalization.test.js +140 -0
- package/node_modules/fast-uri/test/security.test.js +431 -0
- package/node_modules/fast-uri/test/serialize.test.js +151 -0
- package/node_modules/fast-uri/test/uri-js-compatibility.test.js +33 -0
- package/node_modules/fast-uri/test/uri-js.test.js +912 -0
- package/node_modules/fast-uri/test/urn-full-input.test.js +29 -0
- package/node_modules/fast-uri/test/util.test.js +38 -0
- package/node_modules/fast-uri/test/websocket-query-preservation.test.js +24 -0
- package/node_modules/fast-uri/tsconfig.json +9 -0
- package/node_modules/fast-uri/types/index.d.ts +60 -0
- package/node_modules/fast-uri/types/index.test-d.ts +17 -0
- package/node_modules/json-schema-traverse/.eslintrc.yml +27 -0
- package/node_modules/json-schema-traverse/.github/FUNDING.yml +2 -0
- package/node_modules/json-schema-traverse/.github/workflows/build.yml +28 -0
- package/node_modules/json-schema-traverse/.github/workflows/publish.yml +27 -0
- package/node_modules/json-schema-traverse/LICENSE +21 -0
- package/node_modules/json-schema-traverse/README.md +95 -0
- package/node_modules/json-schema-traverse/index.d.ts +40 -0
- package/node_modules/json-schema-traverse/index.js +93 -0
- package/node_modules/json-schema-traverse/package.json +43 -0
- package/node_modules/json-schema-traverse/spec/.eslintrc.yml +6 -0
- package/node_modules/json-schema-traverse/spec/fixtures/schema.js +125 -0
- package/node_modules/json-schema-traverse/spec/index.spec.js +171 -0
- package/node_modules/require-from-string/index.js +34 -0
- package/node_modules/require-from-string/license +21 -0
- package/node_modules/require-from-string/package.json +28 -0
- package/node_modules/require-from-string/readme.md +56 -0
- package/package.json +33 -4
- package/packages/pcr-core/schemas/agent-review.schema.json +69 -0
- package/packages/pcr-core/schemas/classification-coverage.schema.json +187 -0
- package/packages/pcr-core/schemas/controlled-vocabulary.schema.json +189 -0
- package/packages/pcr-core/schemas/dataset-validation-input.schema.json +7 -0
- package/packages/pcr-core/schemas/feedback-draft-output.schema.json +12 -0
- package/packages/pcr-core/schemas/feedback.schema.json +27 -0
- package/packages/pcr-core/schemas/guidance-output.schema.json +97 -0
- package/packages/pcr-core/schemas/model-validation-input.schema.json +10 -0
- package/packages/pcr-core/schemas/pcr-id-aliases.schema.json +120 -0
- package/packages/pcr-core/schemas/readiness.schema.json +100 -0
- package/packages/pcr-core/schemas/structured-projection.schema.json +269 -0
- package/packages/pcr-core/schemas/validation-output.schema.json +117 -0
- package/packages/pcr-core/src/classification-coverage.mjs +732 -0
- package/packages/pcr-core/src/consumption-calculation.mjs +53 -0
- package/packages/pcr-core/src/consumption-data.mjs +88 -0
- package/packages/pcr-core/src/consumption-guidance.mjs +62 -0
- package/packages/pcr-core/src/consumption-review.mjs +83 -0
- package/packages/pcr-core/src/contracts.mjs +195 -0
- package/packages/pcr-core/src/generated/controlled-vocabulary.mjs +41 -0
- package/packages/pcr-core/src/index.mjs +2101 -0
- package/packages/pcr-core/src/languages.mjs +86 -0
- package/packages/pcr-core/src/offline-library.mjs +121 -0
- package/packages/pcr-core/src/output-semantics.mjs +228 -0
- package/packages/pcr-core/src/pcr-id-aliases.mjs +949 -0
- package/packages/pcr-core/src/projection-completeness.mjs +284 -0
- package/packages/pcr-core/src/projection-integrity.mjs +208 -0
- package/packages/pcr-core/src/read-context.mjs +505 -0
- package/packages/pcr-core/src/schema-validation.mjs +142 -0
- package/packages/pcr-core/src/source-context.mjs +13 -0
- package/packages/pcr-core/src/tidas-inspection.mjs +177 -0
- package/packages/pcr-core/src/yaml-lite.mjs +261 -0
- package/packages/tiangong-pcr-cli/bin/tiangong-pcr.mjs +12 -0
- package/packages/tiangong-pcr-cli/src/commands.mjs +1691 -0
- package/skills/tiangong-pcr/SKILL.md +90 -0
- package/skills/tiangong-pcr/references/cli-usage.md +66 -0
- package/skills/tiangong-pcr/references/feedback-loop.md +16 -0
- package/skills/tiangong-pcr/references/lca-authoring.md +30 -0
- package/skills/tiangong-pcr/references/model-authoring-loop.md +6 -0
- package/skills/tiangong-pcr/references/reviewing-tidas.md +71 -0
- package/skills/tiangong-pcr/references/tidas-authoring.md +45 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ConsumptionError, object, strictNumber } from "./consumption-data.mjs";
|
|
2
|
+
|
|
3
|
+
function text(value, name) {
|
|
4
|
+
if (typeof value !== "string" || !value.trim()) throw new ConsumptionError("PCR_CALCULATION_INPUT", `${name} must state the unit, basis or evidence explicitly.`, { field: name });
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Arithmetic only: the Agent owns physical equivalence, applicability and evidence.
|
|
9
|
+
export function calculate(request) {
|
|
10
|
+
if (!object(request)) throw new ConsumptionError("PCR_CALCULATION_INPUT", "Use a JSON object with operation normalize, convert or balance. See calculate --help.");
|
|
11
|
+
const evidence = text(request.evidence, "evidence");
|
|
12
|
+
const basis = text(request.basis, "basis");
|
|
13
|
+
let result;
|
|
14
|
+
let formula;
|
|
15
|
+
if (request.operation === "normalize") {
|
|
16
|
+
const amount = strictNumber(request.amount, "amount");
|
|
17
|
+
const sourceReference = strictNumber(request.source_reference, "source_reference", { positive: true });
|
|
18
|
+
const targetReference = strictNumber(request.target_reference, "target_reference", { positive: true });
|
|
19
|
+
const unit = text(request.unit, "unit");
|
|
20
|
+
text(request.reference_unit, "reference_unit");
|
|
21
|
+
result = { amount: amount * targetReference / sourceReference, unit, factor: targetReference / sourceReference };
|
|
22
|
+
formula = "amount * target_reference / source_reference; both reference quantities share reference_unit and the stated physical basis";
|
|
23
|
+
} else if (request.operation === "convert") {
|
|
24
|
+
const amount = strictNumber(request.amount, "amount");
|
|
25
|
+
const factor = strictNumber(request.factor, "factor", { positive: true });
|
|
26
|
+
text(request.from_unit, "from_unit");
|
|
27
|
+
const unit = text(request.to_unit, "to_unit");
|
|
28
|
+
result = { amount: amount * factor, unit, factor };
|
|
29
|
+
formula = "amount * factor; factor is explicitly supplied in to_unit / from_unit";
|
|
30
|
+
} else if (request.operation === "balance") {
|
|
31
|
+
const unit = text(request.unit, "unit");
|
|
32
|
+
const sums = {};
|
|
33
|
+
for (const name of ["inputs", "outputs"]) {
|
|
34
|
+
if (!Array.isArray(request[name]) || !request[name].length) throw new ConsumptionError("PCR_CALCULATION_INPUT", `${name} must be a non-empty array of {amount, label} in the declared common unit and basis.`);
|
|
35
|
+
sums[name] = request[name].reduce((sum, item, index) => {
|
|
36
|
+
if (!object(item)) throw new ConsumptionError("PCR_CALCULATION_INPUT", `${name}[${index}] must be an amount/label object.`);
|
|
37
|
+
text(item.label, `${name}[${index}].label`);
|
|
38
|
+
return sum + strictNumber(item.amount, `${name}[${index}].amount`);
|
|
39
|
+
}, 0);
|
|
40
|
+
}
|
|
41
|
+
const accumulation = strictNumber(request.accumulation, "accumulation");
|
|
42
|
+
result = { input_total: sums.inputs, output_total: sums.outputs, accumulation, residual: sums.inputs - sums.outputs - accumulation, unit };
|
|
43
|
+
formula = "sum(inputs) - sum(outputs) - accumulation; positive residual is unaccounted net input";
|
|
44
|
+
} else {
|
|
45
|
+
throw new ConsumptionError("PCR_CALCULATION_OPERATION", "Use operation normalize, convert or balance. No formulas, factors or units are inferred.");
|
|
46
|
+
}
|
|
47
|
+
if (Object.values(result).some((value) => typeof value === "number" && !Number.isFinite(value))) throw new ConsumptionError("PCR_CALCULATION_OVERFLOW", "Calculation produced a non-finite number; rescale or correct the input quantities.");
|
|
48
|
+
return {
|
|
49
|
+
schema_version: 1, calculation_kind: "tiangong-pcr-arithmetic", operation: request.operation,
|
|
50
|
+
request, formula, result, basis, evidence,
|
|
51
|
+
interpretation: "Arithmetic only, using supplied values and JavaScript floating-point precision. Physical applicability, evidence quality, tolerance and anomaly judgment are not evaluated.",
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { readFileSync, statSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
export class ConsumptionError extends Error {
|
|
6
|
+
constructor(code, message, details = {}) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "ConsumptionError";
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.details = details;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const sha256 = (bytes) => `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
|
|
15
|
+
export const object = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
16
|
+
export const pointerToken = (value) => String(value).replaceAll("~", "~0").replaceAll("/", "~1");
|
|
17
|
+
|
|
18
|
+
export function atPointer(value, pointer) {
|
|
19
|
+
if (typeof pointer !== "string" || (pointer !== "" && !pointer.startsWith("/")) || /~(?:[^01]|$)/u.test(pointer)) {
|
|
20
|
+
throw new ConsumptionError("PCR_POINTER_INVALID", "Use an RFC 6901 JSON Pointer, such as /processDataSet/exchanges/exchange/0.");
|
|
21
|
+
}
|
|
22
|
+
if (pointer === "") return value;
|
|
23
|
+
let current = value;
|
|
24
|
+
for (const encoded of pointer.slice(1).split("/")) {
|
|
25
|
+
const key = encoded.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
26
|
+
if (current === null || typeof current !== "object" || !Object.hasOwn(current, key)
|
|
27
|
+
|| (Array.isArray(current) && !/^(0|[1-9]\d*)$/u.test(key))) {
|
|
28
|
+
throw new ConsumptionError("PCR_POINTER_NOT_FOUND", `No value exists at ${pointer}. Inspect the summary or a paged section first.`, { pointer });
|
|
29
|
+
}
|
|
30
|
+
current = current[key];
|
|
31
|
+
}
|
|
32
|
+
return current;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function readJsonDocument(filename, maxBytes = 16 * 1024 * 1024) {
|
|
36
|
+
const file = path.resolve(filename);
|
|
37
|
+
let bytes;
|
|
38
|
+
try {
|
|
39
|
+
const stat = statSync(file);
|
|
40
|
+
if (!stat.isFile() || stat.size > maxBytes) {
|
|
41
|
+
throw new ConsumptionError("PCR_INPUT_SIZE", `Expected a JSON file no larger than ${maxBytes} bytes: ${file}`);
|
|
42
|
+
}
|
|
43
|
+
bytes = readFileSync(file);
|
|
44
|
+
if (bytes.length > maxBytes) throw new ConsumptionError("PCR_INPUT_SIZE", `Input grew beyond ${maxBytes} bytes: ${file}`);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (error instanceof ConsumptionError) throw error;
|
|
47
|
+
throw new ConsumptionError("PCR_INPUT_READ", `Cannot read local JSON file ${file}: ${error.message}`, { file });
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
return { file, sha256: sha256(bytes), bytes: bytes.length, value: JSON.parse(bytes.toString("utf8").replace(/^\uFEFF/u, "")) };
|
|
51
|
+
} catch (error) {
|
|
52
|
+
throw new ConsumptionError("PCR_INPUT_JSON", `Malformed JSON in ${file}: ${error.message}`, { file });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function entriesAt(value, pointer) {
|
|
57
|
+
if (value === undefined || value === null) return [];
|
|
58
|
+
return Array.isArray(value)
|
|
59
|
+
? value.map((item, index) => ({ pointer: `${pointer}/${index}`, value: item }))
|
|
60
|
+
: [{ pointer, value }];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function paginate(items, page = 1, pageSize = 10) {
|
|
64
|
+
if (!Number.isSafeInteger(page) || page < 1 || !Number.isSafeInteger(pageSize) || pageSize < 1 || pageSize > 100) {
|
|
65
|
+
throw new ConsumptionError("PCR_PAGE_INVALID", "Use --page >= 1 and --page-size from 1 to 100.");
|
|
66
|
+
}
|
|
67
|
+
const pages = Math.max(1, Math.ceil(items.length / pageSize));
|
|
68
|
+
if (page > pages) throw new ConsumptionError("PCR_PAGE_RANGE", `Page ${page} exceeds ${pages}; use --page ${pages}.`);
|
|
69
|
+
return {
|
|
70
|
+
items: items.slice((page - 1) * pageSize, page * pageSize),
|
|
71
|
+
pagination: { page, page_size: pageSize, total: items.length, total_pages: pages, has_more: page < pages },
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function preview(value, maxChars = 2400) {
|
|
76
|
+
const json = JSON.stringify(value);
|
|
77
|
+
return json.length <= maxChars ? { value, truncated: false }
|
|
78
|
+
: { excerpt: json.slice(0, maxChars), truncated: true, total_characters: json.length };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function strictNumber(value, name, { positive = false } = {}) {
|
|
82
|
+
if ((typeof value !== "number" && typeof value !== "string")
|
|
83
|
+
|| (typeof value === "string" && !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/u.test(value))
|
|
84
|
+
|| !Number.isFinite(Number(value)) || (positive && Number(value) <= 0)) {
|
|
85
|
+
throw new ConsumptionError("PCR_NUMBER_INVALID", `${name} must be a finite${positive ? " positive" : ""} decimal number. Missing values are not zero.`, { field: name });
|
|
86
|
+
}
|
|
87
|
+
return Number(value);
|
|
88
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { getVerifiedPcrProjection } from "./index.mjs";
|
|
2
|
+
import { ConsumptionError, atPointer, entriesAt, paginate, preview } from "./consumption-data.mjs";
|
|
3
|
+
|
|
4
|
+
const TOPICS = {
|
|
5
|
+
overview: ["product_category_identity", "functional_unit", "boundary_abstraction"],
|
|
6
|
+
"reference-flow": ["functional_unit", "reference_flow_definition"],
|
|
7
|
+
boundary: ["system_boundary/rules", "boundary_abstraction"],
|
|
8
|
+
measurement: ["measurement_rules"],
|
|
9
|
+
inventory: ["process_map", "process_inventory"],
|
|
10
|
+
collection: ["dataset_production/collection_protocols"],
|
|
11
|
+
calculation: ["dataset_production/calculation_rules"],
|
|
12
|
+
allocation: ["allocation_rules"],
|
|
13
|
+
quality: ["data_quality_rules", "dataset_production/data_quality_requirements", "published_dataset_profile"],
|
|
14
|
+
validation: ["validation_rules"],
|
|
15
|
+
sources: ["data_sources"],
|
|
16
|
+
};
|
|
17
|
+
export const GUIDANCE_TOPICS = Object.keys(TOPICS);
|
|
18
|
+
|
|
19
|
+
export function projectionBinding(snapshot) {
|
|
20
|
+
return {
|
|
21
|
+
pcr_id: snapshot.pcr.id,
|
|
22
|
+
version: snapshot.pcr.version,
|
|
23
|
+
projection_sha256: snapshot.structured.projection_metadata.generated_content_sha256,
|
|
24
|
+
markdown_sha256: snapshot.structured.projection_metadata.canonical_markdown.sha256,
|
|
25
|
+
methodology_status: snapshot.readiness.methodology_status,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function pcrEvidence(snapshot, pointer) {
|
|
30
|
+
return { ...projectionBinding(snapshot), pointer };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function selectGuidance({ root, pcrId, topic = "overview", pointer, page = 1, pageSize = 10 }) {
|
|
34
|
+
const snapshot = getVerifiedPcrProjection({ root, pcrId });
|
|
35
|
+
const base = {
|
|
36
|
+
schema_version: 1, guidance_kind: "tiangong-pcr-guidance-selection",
|
|
37
|
+
pcr: projectionBinding(snapshot), readiness: snapshot.readiness,
|
|
38
|
+
source_structured: snapshot.source_structured,
|
|
39
|
+
source_markdown: snapshot.source_structured.replace(/structured\.yaml$/u, "pcr.en-US.md"),
|
|
40
|
+
topics: GUIDANCE_TOPICS,
|
|
41
|
+
citation_note: "Pointers address this verified structured projection. Preserve its hashes; applicability remains an Agent judgment. Explicit rule IDs may persist across revisions; array pointers are snapshot-bound.",
|
|
42
|
+
};
|
|
43
|
+
if (pointer !== undefined) {
|
|
44
|
+
return { ...base, source: pcrEvidence(snapshot, pointer), value: atPointer(snapshot.structured, pointer) };
|
|
45
|
+
}
|
|
46
|
+
if (!Object.hasOwn(TOPICS, topic)) throw new ConsumptionError("PCR_GUIDANCE_TOPIC", `Use --topic ${GUIDANCE_TOPICS.join("|")}.`);
|
|
47
|
+
const entries = [];
|
|
48
|
+
for (const name of TOPICS[topic]) {
|
|
49
|
+
const pointer = `/${name}`;
|
|
50
|
+
let value;
|
|
51
|
+
try { value = atPointer(snapshot.structured, pointer); }
|
|
52
|
+
catch (error) { if (error.code !== "PCR_POINTER_NOT_FOUND") throw error; }
|
|
53
|
+
for (const entry of entriesAt(value, pointer)) {
|
|
54
|
+
entries.push({
|
|
55
|
+
source: pcrEvidence(snapshot, entry.pointer),
|
|
56
|
+
rule_id: entry.value?.rule_id ?? entry.value?.protocol_id ?? entry.value?.row_id ?? entry.value?.id ?? null,
|
|
57
|
+
...preview(entry.value),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return { ...base, topic, ...paginate(entries, page, pageSize) };
|
|
62
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { atPointer } from "./consumption-data.mjs";
|
|
2
|
+
import { getVerifiedPcrProjection } from "./index.mjs";
|
|
3
|
+
import { projectionBinding } from "./consumption-guidance.mjs";
|
|
4
|
+
import { documentIdentity, extractReferences, loadTidasContext } from "./tidas-inspection.mjs";
|
|
5
|
+
import { validateCoreContract } from "./contracts.mjs";
|
|
6
|
+
|
|
7
|
+
const TOPICS = ["scope_and_applicability", "reference_basis", "inventory_and_boundary", "allocation", "data_quality"];
|
|
8
|
+
|
|
9
|
+
export function prepareReview({ root, pcrId, input, related }) {
|
|
10
|
+
const snapshot = getVerifiedPcrProjection({ root, pcrId });
|
|
11
|
+
const context = loadTidasContext({ input, related });
|
|
12
|
+
const unresolved = extractReferences(context).filter((reference) => reference.status !== "resolved");
|
|
13
|
+
return {
|
|
14
|
+
schema_version: 1, report_kind: "tiangong-pcr-agent-review", status: "draft",
|
|
15
|
+
pcr: projectionBinding(snapshot), inputs: context.documents.map(documentIdentity),
|
|
16
|
+
scope: {
|
|
17
|
+
description: `Review of supplied ${context.primary.kind}; the Agent must establish its declared scope and reference basis.`,
|
|
18
|
+
applicability: "Not assessed. Explain product, technology, gate and PCR applicability before drawing conclusions.",
|
|
19
|
+
limitations: [
|
|
20
|
+
"No semantic review or TIDAS schema validation has been performed by this command.",
|
|
21
|
+
`${unresolved.length} reference(s) could not be uniquely resolved in the supplied local inputs; inspect references before claiming omissions.`,
|
|
22
|
+
`${context.ignoredFiles.length} JSON file(s) with no native TIDAS dataset root were ignored by input inspection.`,
|
|
23
|
+
`PCR methodology status: ${snapshot.readiness.methodology_status}; library availability does not promote candidate methodology.`,
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
coverage: TOPICS.map((topic) => ({ topic, status: "not_reviewed", rationale: "Awaiting Agent investigation of applicability and evidence." })),
|
|
27
|
+
findings: [],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function checkReview({ root, pcrId, input, related, report }) {
|
|
32
|
+
const shape = validateCoreContract("agent-review.schema.json", report);
|
|
33
|
+
const issues = [];
|
|
34
|
+
const add = (code, location, message) => issues.push({ code, location, message });
|
|
35
|
+
if (!shape.valid) {
|
|
36
|
+
for (const error of shape.issues ?? shape.errors) add("report_shape", error.instance_path ?? error.instancePath ?? "", error.message);
|
|
37
|
+
} else {
|
|
38
|
+
const snapshot = getVerifiedPcrProjection({ root, pcrId });
|
|
39
|
+
const binding = projectionBinding(snapshot);
|
|
40
|
+
const context = loadTidasContext({ input, related });
|
|
41
|
+
const actual = context.documents.map(documentIdentity);
|
|
42
|
+
const files = new Map(context.documents.map((doc) => [doc.file, doc]));
|
|
43
|
+
const sameBinding = (candidate) => Object.keys(binding).every((key) => candidate[key] === binding[key]);
|
|
44
|
+
if (!sameBinding(report.pcr)) add("pcr_changed", "/pcr", "PCR identity, content hashes or methodology status differ from the selected verified projection.");
|
|
45
|
+
if (report.inputs.length !== actual.length || report.inputs.some((item, index) => Object.keys(actual[index] ?? {}).some((key) => item[key] !== actual[index][key]))) {
|
|
46
|
+
add("inputs_changed", "/inputs", "Input files, identities, order or exact-byte hashes differ. Regenerate the draft bindings and review the changed evidence.");
|
|
47
|
+
}
|
|
48
|
+
if (report.status === "reviewed" && !report.coverage.some((item) => item.status === "reviewed")) add("review_empty", "/coverage", "A reviewed report must name at least one actually reviewed topic; otherwise retain draft status.");
|
|
49
|
+
const ids = new Set();
|
|
50
|
+
for (const [index, finding] of report.findings.entries()) {
|
|
51
|
+
const prefix = `/findings/${index}`;
|
|
52
|
+
if (ids.has(finding.id)) add("duplicate_finding", `${prefix}/id`, "Finding IDs must be unique within this report.");
|
|
53
|
+
ids.add(finding.id);
|
|
54
|
+
for (const [refIndex, reference] of finding.input_refs.entries()) {
|
|
55
|
+
const location = `${prefix}/input_refs/${refIndex}`;
|
|
56
|
+
const doc = files.get(reference.file);
|
|
57
|
+
if (!doc || reference.sha256 !== doc.sha256) add("input_reference_changed", location, "Reference must identify an explicitly supplied input and its current exact-byte hash.");
|
|
58
|
+
else {
|
|
59
|
+
try { atPointer(doc.value, reference.pointer); }
|
|
60
|
+
catch (error) { add("input_pointer", location, error.message); }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
for (const [refIndex, reference] of finding.pcr_refs.entries()) {
|
|
64
|
+
const location = `${prefix}/pcr_refs/${refIndex}`;
|
|
65
|
+
if (!sameBinding(reference)) add("pcr_reference_changed", location, "PCR reference does not match the selected verified projection.");
|
|
66
|
+
else {
|
|
67
|
+
try { atPointer(snapshot.structured, reference.pointer); }
|
|
68
|
+
catch (error) { add("pcr_pointer", location, error.message); }
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
schema_version: 1, check_kind: "tiangong-pcr-review-envelope-check",
|
|
75
|
+
envelope_valid: issues.length === 0, methodology_approval: false,
|
|
76
|
+
report_status: shape.valid ? report.status : null,
|
|
77
|
+
checked: ["report_shape", ...(shape.valid ? ["input_and_pcr_bindings", "finding_reference_locations", "review_status_consistency"] : [])],
|
|
78
|
+
not_checked: ["PCR applicability", "truth of observations or conclusions", "sufficiency of evidence", "coverage completeness", "TIDAS schema validity"],
|
|
79
|
+
issues,
|
|
80
|
+
next_step: issues.length ? "Correct the report or re-review changed evidence, then run review check again."
|
|
81
|
+
: "Have the Agent/user assess the reasoning and remaining scope. Envelope validity does not approve the dataset.",
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
|
|
3
|
+
import { createSchemaRegistry } from "./schema-validation.mjs";
|
|
4
|
+
import {
|
|
5
|
+
readinessSemanticIssues,
|
|
6
|
+
validationReportSemanticIssues,
|
|
7
|
+
} from "./output-semantics.mjs";
|
|
8
|
+
|
|
9
|
+
const CORE_SCHEMA_DEPENDENCY_FILES = ["controlled-vocabulary.schema.json"];
|
|
10
|
+
const CORE_SCHEMA_FILES = [
|
|
11
|
+
"agent-review.schema.json",
|
|
12
|
+
"classification-coverage.schema.json",
|
|
13
|
+
"dataset-validation-input.schema.json",
|
|
14
|
+
"feedback-draft-output.schema.json",
|
|
15
|
+
"feedback.schema.json",
|
|
16
|
+
"guidance-output.schema.json",
|
|
17
|
+
"model-validation-input.schema.json",
|
|
18
|
+
"pcr-id-aliases.schema.json",
|
|
19
|
+
"readiness.schema.json",
|
|
20
|
+
"structured-projection.schema.json",
|
|
21
|
+
"validation-output.schema.json",
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const schemaEntries = CORE_SCHEMA_FILES.map((fileName) => ({
|
|
25
|
+
fileName,
|
|
26
|
+
schema: JSON.parse(readFileSync(new URL(`../schemas/${fileName}`, import.meta.url), "utf8")),
|
|
27
|
+
}));
|
|
28
|
+
const schemaDependencies = CORE_SCHEMA_DEPENDENCY_FILES.map((fileName) =>
|
|
29
|
+
JSON.parse(readFileSync(new URL(`../schemas/${fileName}`, import.meta.url), "utf8")),
|
|
30
|
+
);
|
|
31
|
+
const contractIds = new Map(schemaEntries.map(({ fileName, schema }) => [fileName, schema.$id]));
|
|
32
|
+
const entityKindsByFile = {
|
|
33
|
+
"agent-review.schema.json": "agent_review",
|
|
34
|
+
"classification-coverage.schema.json": "classification_coverage",
|
|
35
|
+
"dataset-validation-input.schema.json": "dataset_validation_input",
|
|
36
|
+
"feedback-draft-output.schema.json": "feedback_draft_output",
|
|
37
|
+
"feedback.schema.json": "feedback_intake",
|
|
38
|
+
"guidance-output.schema.json": "guidance_output",
|
|
39
|
+
"model-validation-input.schema.json": "model_validation_input",
|
|
40
|
+
"pcr-id-aliases.schema.json": "pcr_id_aliases",
|
|
41
|
+
"readiness.schema.json": "readiness",
|
|
42
|
+
"structured-projection.schema.json": "structured_projection",
|
|
43
|
+
"validation-output.schema.json": "validation_report",
|
|
44
|
+
};
|
|
45
|
+
const registry = createSchemaRegistry(
|
|
46
|
+
[...schemaDependencies, ...schemaEntries.map(({ schema }) => schema)],
|
|
47
|
+
Object.fromEntries(
|
|
48
|
+
schemaEntries.map(({ fileName, schema }) => [schema.$id, entityKindsByFile[fileName]]),
|
|
49
|
+
),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const semanticValidators = new Map([
|
|
53
|
+
[contractIds.get("readiness.schema.json"), readinessSemanticIssues],
|
|
54
|
+
[contractIds.get("validation-output.schema.json"), validationReportSemanticIssues],
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
export class CoreContractSemanticError extends Error {
|
|
58
|
+
constructor({
|
|
59
|
+
code = "PCR_SEMANTIC_CONTRACT_INVALID",
|
|
60
|
+
contract,
|
|
61
|
+
entityKind,
|
|
62
|
+
source = null,
|
|
63
|
+
issues,
|
|
64
|
+
}) {
|
|
65
|
+
const location = source ? ` at ${source}` : "";
|
|
66
|
+
const details = issues.map((issue) => `${issue.instance_path}: ${issue.message}`).join("; ");
|
|
67
|
+
super(`${entityKind} semantic contract failed${location}: ${details}`);
|
|
68
|
+
this.name = "CoreContractSemanticError";
|
|
69
|
+
this.code = code;
|
|
70
|
+
this.contract = contract;
|
|
71
|
+
this.entity_kind = entityKind;
|
|
72
|
+
this.schema_id = contract;
|
|
73
|
+
this.source = source;
|
|
74
|
+
this.issues = structuredClone(issues);
|
|
75
|
+
this.errors = structuredClone(issues);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
toJSON() {
|
|
79
|
+
return {
|
|
80
|
+
code: this.code,
|
|
81
|
+
entity_kind: this.entity_kind,
|
|
82
|
+
schema_id: this.schema_id,
|
|
83
|
+
source: this.source,
|
|
84
|
+
errors: structuredClone(this.errors),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export const CORE_SCHEMA_IDS = Object.freeze({
|
|
90
|
+
classificationCoverage: contractIds.get("classification-coverage.schema.json"),
|
|
91
|
+
structured: contractIds.get("structured-projection.schema.json"),
|
|
92
|
+
readiness: contractIds.get("readiness.schema.json"),
|
|
93
|
+
guidance: contractIds.get("guidance-output.schema.json"),
|
|
94
|
+
validationReport: contractIds.get("validation-output.schema.json"),
|
|
95
|
+
feedbackDraft: contractIds.get("feedback-draft-output.schema.json"),
|
|
96
|
+
feedbackIntake: contractIds.get("feedback.schema.json"),
|
|
97
|
+
modelInput: contractIds.get("model-validation-input.schema.json"),
|
|
98
|
+
datasetInput: contractIds.get("dataset-validation-input.schema.json"),
|
|
99
|
+
pcrIdAliases: contractIds.get("pcr-id-aliases.schema.json"),
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
export function assertCoreContract(contract, value, options = {}) {
|
|
103
|
+
const contractId = resolveContractId(contract);
|
|
104
|
+
registry.assert(contractId, value, options);
|
|
105
|
+
const issues = semanticValidators.get(contractId)?.(value) ?? [];
|
|
106
|
+
if (issues.length > 0) {
|
|
107
|
+
throw new CoreContractSemanticError({
|
|
108
|
+
code: options.code,
|
|
109
|
+
contract: contractId,
|
|
110
|
+
entityKind: options.entityKind ?? entityKindsByContract.get(contractId) ?? contractId,
|
|
111
|
+
source: options.source,
|
|
112
|
+
issues,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return value;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function validateCoreContract(contract, value, options = {}) {
|
|
119
|
+
const contractId = resolveContractId(contract);
|
|
120
|
+
const result = registry.validate(contractId, value, options);
|
|
121
|
+
if (!result.valid) {
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
const errors = semanticValidators.get(contractId)?.(value) ?? [];
|
|
125
|
+
if (errors.length === 0) {
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
...result,
|
|
130
|
+
valid: false,
|
|
131
|
+
code: "PCR_SEMANTIC_CONTRACT_INVALID",
|
|
132
|
+
errors,
|
|
133
|
+
issues: errors,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function coreContractId(fileName) {
|
|
138
|
+
return resolveContractId(fileName);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export const validateStructured = (value) =>
|
|
142
|
+
validateCoreContract("structured-projection.schema.json", value);
|
|
143
|
+
export const assertStructured = (value, options = {}) =>
|
|
144
|
+
assertCoreContract("structured-projection.schema.json", value, options);
|
|
145
|
+
export const validateReadiness = (value) => validateCoreContract("readiness.schema.json", value);
|
|
146
|
+
export const assertReadiness = (value, options = {}) =>
|
|
147
|
+
assertCoreContract("readiness.schema.json", value, options);
|
|
148
|
+
export const validateGuidance = (value) => validateCoreContract("guidance-output.schema.json", value);
|
|
149
|
+
export const assertGuidance = (value, options = {}) =>
|
|
150
|
+
assertCoreContract("guidance-output.schema.json", value, options);
|
|
151
|
+
export const validateValidationReport = (value) =>
|
|
152
|
+
validateCoreContract("validation-output.schema.json", value);
|
|
153
|
+
export const assertValidationReport = (value, options = {}) =>
|
|
154
|
+
assertCoreContract("validation-output.schema.json", value, options);
|
|
155
|
+
export const validateFeedbackDraft = (value) =>
|
|
156
|
+
validateCoreContract("feedback-draft-output.schema.json", value);
|
|
157
|
+
export const assertFeedbackDraft = (value, options = {}) =>
|
|
158
|
+
assertCoreContract("feedback-draft-output.schema.json", value, options);
|
|
159
|
+
export const validateFeedbackIntake = (value) =>
|
|
160
|
+
validateCoreContract("feedback.schema.json", value);
|
|
161
|
+
export const assertFeedbackIntake = (value, options = {}) =>
|
|
162
|
+
assertCoreContract("feedback.schema.json", value, options);
|
|
163
|
+
export const validateModelInput = (value) =>
|
|
164
|
+
validateCoreContract("model-validation-input.schema.json", value);
|
|
165
|
+
export const assertModelInput = (value, options = {}) =>
|
|
166
|
+
assertCoreContract("model-validation-input.schema.json", value, options);
|
|
167
|
+
export const validateDatasetInput = (value) =>
|
|
168
|
+
validateCoreContract("dataset-validation-input.schema.json", value);
|
|
169
|
+
export const assertDatasetInput = (value, options = {}) =>
|
|
170
|
+
assertCoreContract("dataset-validation-input.schema.json", value, options);
|
|
171
|
+
export const validateClassificationCoverage = (value) =>
|
|
172
|
+
validateCoreContract("classification-coverage.schema.json", value);
|
|
173
|
+
export const assertClassificationCoverage = (value, options = {}) =>
|
|
174
|
+
assertCoreContract("classification-coverage.schema.json", value, options);
|
|
175
|
+
export const validatePcrIdAliases = (value) =>
|
|
176
|
+
validateCoreContract("pcr-id-aliases.schema.json", value);
|
|
177
|
+
export const assertPcrIdAliases = (value, options = {}) =>
|
|
178
|
+
assertCoreContract("pcr-id-aliases.schema.json", value, options);
|
|
179
|
+
|
|
180
|
+
export const validateStructuredProjection = validateStructured;
|
|
181
|
+
export const assertStructuredProjection = assertStructured;
|
|
182
|
+
export const validateGuidanceOutput = validateGuidance;
|
|
183
|
+
export const assertGuidanceOutput = assertGuidance;
|
|
184
|
+
export const validateModelValidationInput = validateModelInput;
|
|
185
|
+
export const assertModelValidationInput = assertModelInput;
|
|
186
|
+
export const validateDatasetValidationInput = validateDatasetInput;
|
|
187
|
+
export const assertDatasetValidationInput = assertDatasetInput;
|
|
188
|
+
|
|
189
|
+
function resolveContractId(contract) {
|
|
190
|
+
return contractIds.get(contract) ?? contract;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const entityKindsByContract = new Map(
|
|
194
|
+
schemaEntries.map(({ fileName, schema }) => [schema.$id, entityKindsByFile[fileName]]),
|
|
195
|
+
);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Generated by builder/scripts/generate-controlled-vocabulary.mjs.
|
|
2
|
+
// Do not edit this file directly; edit builder/vocab/*.yaml and run npm run vocab:generate.
|
|
3
|
+
|
|
4
|
+
export const AMOUNT_RANGE_ROLE_VALUES = Object.freeze(["qa_guardrail","typical_range","allowed_range","default_estimate","uncertainty_range"]);
|
|
5
|
+
export const AMOUNT_SPECIFICITY_VALUES = Object.freeze(["generic","site_specific","product_specific","route_specific","scenario_specific","technology_specific","not_applicable"]);
|
|
6
|
+
export const AMOUNT_VALUE_MODE_VALUES = Object.freeze(["fixed_value","foreground_record","calculated_value","modelled_estimate","not_applicable"]);
|
|
7
|
+
export const BASIS_KIND_VALUES = Object.freeze(["reference_flow","process_output","n_input","fuel_inventory","transport_service","storage_duration","crop_cycle"]);
|
|
8
|
+
export const CLASSIFICATION_COVERAGE_STATUS_VALUES = Object.freeze(["mapped","unmapped","candidate_suggestion","manual_review","unknown"]);
|
|
9
|
+
export const CLASSIFICATION_MAPPING_RELATION_VALUES = Object.freeze(["exact","broader","narrower","proxy","manual_review"]);
|
|
10
|
+
export const CONTENT_MATURITY_VALUES = Object.freeze(["empty_scaffold","draft_methodology","authored_methodology","reviewed_methodology","published_methodology","deprecated_methodology"]);
|
|
11
|
+
export const EVIDENCE_KIND_VALUES = Object.freeze(["external_source","observed_dataset","method_formula","foreground_data","tiangong_default","collected_record","calculated_from_collection","identity_reference","source_rule","reasoned_estimate"]);
|
|
12
|
+
export const FEEDBACK_CONFIDENCE_VALUES = Object.freeze(["high","medium","low","unknown"]);
|
|
13
|
+
export const FEEDBACK_TYPE_VALUES = Object.freeze(["missing_pcr","classification_mapping_gap","unclear_reference_flow","wrong_or_missing_uuid","process_boundary_issue","inventory_flow_gap","range_evidence_update","unit_or_flow_property_issue","validation_rule_issue","translation_mismatch","source_update"]);
|
|
14
|
+
export const FLOW_DIRECTION_VALUES = Object.freeze(["inputs","outputs"]);
|
|
15
|
+
export const FLOW_TYPE_VALUES = Object.freeze(["product","waste","elementary"]);
|
|
16
|
+
export const PCR_STATUS_VALUES = Object.freeze(["scaffold","candidate","active","published","deprecated"]);
|
|
17
|
+
export const PROCESS_INCLUSION_VALUES = Object.freeze(["required","conditional","optional","excluded_by_default"]);
|
|
18
|
+
export const SOURCE_TYPE_VALUES = Object.freeze(["official_guidance","literature","standard","dataset","method_factor","extension_guidance","handbook"]);
|
|
19
|
+
export const TARGET_ENTITY_VALUES = Object.freeze(["flow","process","lifecyclemodel","dataset"]);
|
|
20
|
+
export const TRANSLATION_STATUS_VALUES = Object.freeze(["not_available","scaffold","scaffold_pending_translation","draft_translation","aligned","reviewed","out_of_sync"]);
|
|
21
|
+
|
|
22
|
+
export const CONTROLLED_VOCABULARY = Object.freeze({
|
|
23
|
+
amount_range_role: AMOUNT_RANGE_ROLE_VALUES,
|
|
24
|
+
amount_specificity: AMOUNT_SPECIFICITY_VALUES,
|
|
25
|
+
amount_value_mode: AMOUNT_VALUE_MODE_VALUES,
|
|
26
|
+
basis_kind: BASIS_KIND_VALUES,
|
|
27
|
+
classification_coverage_status: CLASSIFICATION_COVERAGE_STATUS_VALUES,
|
|
28
|
+
classification_mapping_relation: CLASSIFICATION_MAPPING_RELATION_VALUES,
|
|
29
|
+
content_maturity: CONTENT_MATURITY_VALUES,
|
|
30
|
+
evidence_kind: EVIDENCE_KIND_VALUES,
|
|
31
|
+
feedback_confidence: FEEDBACK_CONFIDENCE_VALUES,
|
|
32
|
+
feedback_type: FEEDBACK_TYPE_VALUES,
|
|
33
|
+
flow_direction: FLOW_DIRECTION_VALUES,
|
|
34
|
+
flow_type: FLOW_TYPE_VALUES,
|
|
35
|
+
pcr_status: PCR_STATUS_VALUES,
|
|
36
|
+
process_inclusion: PROCESS_INCLUSION_VALUES,
|
|
37
|
+
source_type: SOURCE_TYPE_VALUES,
|
|
38
|
+
target_entity: TARGET_ENTITY_VALUES,
|
|
39
|
+
translation_status: TRANSLATION_STATUS_VALUES,
|
|
40
|
+
});
|
|
41
|
+
|