From 51c00af5b2305ed5892b8ffb81e2c4f5a521e394 Mon Sep 17 00:00:00 2001 From: Niraj Kamdar Date: Tue, 2 Aug 2022 15:37:55 +0400 Subject: [PATCH 1/6] fix: remove schema bundler from the validator --- packages/js/manifests/wrap/package.json | 2 +- .../js/manifests/wrap/scripts/generate.ts | 3 ++ .../wrap/scripts/templates/index-ts.mustache | 7 ++- .../scripts/templates/validate-ts.mustache | 54 ++++--------------- .../wrap/src/formats/wrap.info/index.ts | 5 +- .../wrap/src/formats/wrap.info/validate.ts | 48 +++-------------- 6 files changed, 30 insertions(+), 89 deletions(-) diff --git a/packages/js/manifests/wrap/package.json b/packages/js/manifests/wrap/package.json index debe9c6513..654fba179f 100644 --- a/packages/js/manifests/wrap/package.json +++ b/packages/js/manifests/wrap/package.json @@ -17,7 +17,6 @@ }, "dependencies": { "@polywrap/msgpack-js": "0.3.0", - "@polywrap/wrap-manifest-schemas": "0.3.0", "json-schema-ref-parser": "9.0.9", "jsonschema": "1.4.0", "semver": "7.3.5" @@ -28,6 +27,7 @@ "@types/mustache": "4.0.1", "@types/prettier": "2.6.0", "@types/semver": "7.3.8", + "@polywrap/wrap-manifest-schemas": "0.3.0", "jest": "26.6.3", "json-schema-to-typescript": "11.0.1", "mustache": "4.0.1", diff --git a/packages/js/manifests/wrap/scripts/generate.ts b/packages/js/manifests/wrap/scripts/generate.ts index 85f7f27216..4f7d326a65 100644 --- a/packages/js/manifests/wrap/scripts/generate.ts +++ b/packages/js/manifests/wrap/scripts/generate.ts @@ -82,6 +82,9 @@ async function generateFormatTypes() { `/* eslint-disable @typescript-eslint/naming-convention */\n${tsFile}` ); + const schemaOutputPath = path.join(wrapOutputDir, `${wrapVersion}.schema.json`); + os.writeFileSync(schemaOutputPath, JSON.stringify(bundledSchema, null ,2)); + // Add metadata for the root index.ts file to use wrapModules.push({ interface: wrapSchema.id, diff --git a/packages/js/manifests/wrap/scripts/templates/index-ts.mustache b/packages/js/manifests/wrap/scripts/templates/index-ts.mustache index 842e497817..137a6e3f45 100644 --- a/packages/js/manifests/wrap/scripts/templates/index-ts.mustache +++ b/packages/js/manifests/wrap/scripts/templates/index-ts.mustache @@ -12,10 +12,15 @@ import { } from "./{{version}}"; {{/formats}} +{{#formats}} +import schema_{{tsVersion}} from "./{{version}}.schema.json"; +{{/formats}} + export { {{#formats}} WrapManifest_{{tsVersion}}, - WrapAbi_{{tsVersion}}_{{abiTsVersion}} + WrapAbi_{{tsVersion}}_{{abiTsVersion}}, + schema_{{tsVersion}} {{/formats}} }; diff --git a/packages/js/manifests/wrap/scripts/templates/validate-ts.mustache b/packages/js/manifests/wrap/scripts/templates/validate-ts.mustache index 8892ea2a76..5e793dbb86 100644 --- a/packages/js/manifests/wrap/scripts/templates/validate-ts.mustache +++ b/packages/js/manifests/wrap/scripts/templates/validate-ts.mustache @@ -6,13 +6,12 @@ */ import { AnyWrapManifest, - WrapManifestVersions + WrapManifestVersions, + {{#formats}} + schema_{{tsVersion}} + {{/formats}} } from "."; {{#validators.length}}import * as Validators from "../validators";{{/validators.length}} -{{#formats}} -import schema_{{tsVersion}} from "@polywrap/wrap-manifest-schemas/formats/wrap.info/{{version}}.json"; -import abi_schema_{{abiTsVersion}} from "@polywrap/wrap-manifest-schemas/formats/abi/{{abiVersion}}.json"; -{{/formats}} import { Schema, @@ -20,17 +19,12 @@ import { ValidationError, ValidatorResult } from "jsonschema"; -import { resolve, bundle, FileInfo, $Refs } from "json-schema-ref-parser"; -import path from "path"; +import { resolve, $Refs } from "json-schema-ref-parser"; type WrapManifestSchemas = { [key in WrapManifestVersions]: Schema | undefined }; -type WrapAbiSchemas = { - [key in WrapManifestVersions]: Schema | undefined -} - const schemas: WrapManifestSchemas = { // NOTE: Patch fix for backwards compatability "0.1.0": schema_0_1, @@ -39,14 +33,6 @@ const schemas: WrapManifestSchemas = { {{/formats}} }; -const abiSchemas: WrapAbiSchemas = { - // NOTE: Patch fix for backwards compatability - "0.1.0": abi_schema_0_1, - {{#formats}} - "{{version}}": abi_schema_{{abiTsVersion}}, - {{/formats}} -} - {{#validators}} Validator.prototype.{{.}} = Validators.{{.}}; {{/validators}} @@ -65,37 +51,15 @@ export async function validateWrapManifest( extSchema: Schema | undefined = undefined ): Promise { const schema = schemas[manifest.version as WrapManifestVersions]; - const abiSchema = abiSchemas[manifest.version as WrapManifestVersions]; - if (!schema || !abiSchema) { + if (!schema) { throw new Error(`Unrecognized WrapManifest schema version "${manifest.version}"\nmanifest: ${JSON.stringify(manifest, null, 2)}`); } - if (!schema.properties) { - // This should never happen - throw new Error(`WrapManifest schema doesn't contain any properties`) - } - - const abiJsonSchemaRelPath = schema.properties.abi.$ref as string; - - const finalSchema = await bundle(schema as any, { - resolve: { - file: { - read: (file: FileInfo) => { - // If both url is same - if (!path.relative(abiJsonSchemaRelPath, file.url)) { - return abiSchema as any; - } - return file.data; - }, - }, - }, - }); - - const refs: $Refs = await resolve(finalSchema); + const refs: $Refs = await resolve(schema as any); const validator = new Validator(); - validator.addSchema(finalSchema as Schema); + validator.addSchema(schema); const resolveRefs = () => { const unresolvedRef = validator.unresolvedRefs.shift(); @@ -113,7 +77,7 @@ export async function validateWrapManifest( resolveRefs(); - throwIfErrors(validator.validate(manifest, finalSchema as Schema), manifest.version); + throwIfErrors(validator.validate(manifest, schema), manifest.version); if (extSchema) { throwIfErrors(validator.validate(manifest, extSchema), manifest.version); diff --git a/packages/js/manifests/wrap/src/formats/wrap.info/index.ts b/packages/js/manifests/wrap/src/formats/wrap.info/index.ts index 2e4abf0c52..caab9fec66 100644 --- a/packages/js/manifests/wrap/src/formats/wrap.info/index.ts +++ b/packages/js/manifests/wrap/src/formats/wrap.info/index.ts @@ -10,9 +10,12 @@ import { Abi as WrapAbi_0_1_0_1 } from "./0.1"; +import schema_0_1 from "./0.1.schema.json"; + export { WrapManifest_0_1, - WrapAbi_0_1_0_1 + WrapAbi_0_1_0_1, + schema_0_1 }; export enum WrapManifestVersions { diff --git a/packages/js/manifests/wrap/src/formats/wrap.info/validate.ts b/packages/js/manifests/wrap/src/formats/wrap.info/validate.ts index bdecc6c4d5..2b36199019 100644 --- a/packages/js/manifests/wrap/src/formats/wrap.info/validate.ts +++ b/packages/js/manifests/wrap/src/formats/wrap.info/validate.ts @@ -6,11 +6,10 @@ */ import { AnyWrapManifest, - WrapManifestVersions + WrapManifestVersions, + schema_0_1 } from "."; -import schema_0_1 from "@polywrap/wrap-manifest-schemas/formats/wrap.info/0.1.json"; -import abi_schema_0_1 from "@polywrap/wrap-manifest-schemas/formats/abi/0.1.json"; import { Schema, @@ -18,29 +17,18 @@ import { ValidationError, ValidatorResult } from "jsonschema"; -import { resolve, bundle, FileInfo, $Refs } from "json-schema-ref-parser"; -import path from "path"; +import { resolve, $Refs } from "json-schema-ref-parser"; type WrapManifestSchemas = { [key in WrapManifestVersions]: Schema | undefined }; -type WrapAbiSchemas = { - [key in WrapManifestVersions]: Schema | undefined -} - const schemas: WrapManifestSchemas = { // NOTE: Patch fix for backwards compatability "0.1.0": schema_0_1, "0.1": schema_0_1, }; -const abiSchemas: WrapAbiSchemas = { - // NOTE: Patch fix for backwards compatability - "0.1.0": abi_schema_0_1, - "0.1": abi_schema_0_1, -} - function throwIfErrors(result: ValidatorResult, version: string) { if (result.errors.length) { @@ -56,37 +44,15 @@ export async function validateWrapManifest( extSchema: Schema | undefined = undefined ): Promise { const schema = schemas[manifest.version as WrapManifestVersions]; - const abiSchema = abiSchemas[manifest.version as WrapManifestVersions]; - if (!schema || !abiSchema) { + if (!schema) { throw new Error(`Unrecognized WrapManifest schema version "${manifest.version}"\nmanifest: ${JSON.stringify(manifest, null, 2)}`); } - if (!schema.properties) { - // This should never happen - throw new Error(`WrapManifest schema doesn't contain any properties`) - } - - const abiJsonSchemaRelPath = schema.properties.abi.$ref as string; - - const finalSchema = await bundle(schema as any, { - resolve: { - file: { - read: (file: FileInfo) => { - // If both url is same - if (!path.relative(abiJsonSchemaRelPath, file.url)) { - return abiSchema as any; - } - return file.data; - }, - }, - }, - }); - - const refs: $Refs = await resolve(finalSchema); + const refs: $Refs = await resolve(schema as any); const validator = new Validator(); - validator.addSchema(finalSchema as Schema); + validator.addSchema(schema); const resolveRefs = () => { const unresolvedRef = validator.unresolvedRefs.shift(); @@ -104,7 +70,7 @@ export async function validateWrapManifest( resolveRefs(); - throwIfErrors(validator.validate(manifest, finalSchema as Schema), manifest.version); + throwIfErrors(validator.validate(manifest, schema), manifest.version); if (extSchema) { throwIfErrors(validator.validate(manifest, extSchema), manifest.version); From 15f18c41eb61ffd8004fcc8a4892fc1fd21a322c Mon Sep 17 00:00:00 2001 From: Niraj Kamdar Date: Tue, 2 Aug 2022 22:20:33 +0400 Subject: [PATCH 2/6] fix: tsconfig --- .../uri-resolvers/file-system-resolver/tsconfig.build.json | 1 + packages/templates/plugin/typescript/tsconfig.json | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/js/plugins/uri-resolvers/file-system-resolver/tsconfig.build.json b/packages/js/plugins/uri-resolvers/file-system-resolver/tsconfig.build.json index 2dd44d366d..19425c477a 100644 --- a/packages/js/plugins/uri-resolvers/file-system-resolver/tsconfig.build.json +++ b/packages/js/plugins/uri-resolvers/file-system-resolver/tsconfig.build.json @@ -10,6 +10,7 @@ "dom" ], "moduleResolution": "node", + "resolveJsonModule": true, "declaration": true, "preserveSymlinks": true, "preserveWatchOutput": true, diff --git a/packages/templates/plugin/typescript/tsconfig.json b/packages/templates/plugin/typescript/tsconfig.json index a015a98879..561f3475e3 100644 --- a/packages/templates/plugin/typescript/tsconfig.json +++ b/packages/templates/plugin/typescript/tsconfig.json @@ -9,6 +9,7 @@ "dom" ], "moduleResolution": "node", + "resolveJsonModule": true, "declaration": true, "preserveSymlinks": true, "preserveWatchOutput": true, From 207427b246da1422dc8656db411202c295667281 Mon Sep 17 00:00:00 2001 From: dOrgJelli Date: Wed, 3 Aug 2022 20:26:37 -0500 Subject: [PATCH 3/6] add 0.1.schema.json generated file --- .../src/formats/wrap.info/0.1.schema.json | 679 ++++++++++++++++++ 1 file changed, 679 insertions(+) create mode 100644 packages/js/manifests/wrap/src/formats/wrap.info/0.1.schema.json diff --git a/packages/js/manifests/wrap/src/formats/wrap.info/0.1.schema.json b/packages/js/manifests/wrap/src/formats/wrap.info/0.1.schema.json new file mode 100644 index 0000000000..a14436328f --- /dev/null +++ b/packages/js/manifests/wrap/src/formats/wrap.info/0.1.schema.json @@ -0,0 +1,679 @@ +{ + "id": "WrapManifest", + "type": "object", + "additionalProperties": false, + "required": [ + "version", + "name", + "type", + "abi" + ], + "properties": { + "version": { + "description": "WRAP Standard Version", + "type": "string", + "enum": [ + "0.1.0", + "0.1" + ] + }, + "type": { + "description": "Wrapper Package Type", + "type": "string", + "enum": [ + "wasm", + "interface" + ] + }, + "name": { + "description": "Wrapper Name", + "type": "string", + "pattern": "^[a-zA-Z0-9\\-\\_]+$" + }, + "abi": { + "id": "Abi", + "type": "object", + "unevaluatedProperties": false, + "required": [ + "objectTypes", + "enumTypes", + "interfaceTypes", + "importedObjectTypes", + "importedModuleTypes", + "importedEnumTypes", + "importedEnvTypes" + ], + "properties": { + "version": { + "description": "ABI Version", + "type": "string", + "const": "0.1" + }, + "objectTypes": { + "type": "array", + "items": { + "$ref": "#/properties/abi/definitions/objectDefinition" + } + }, + "moduleType": { + "$ref": "#/properties/abi/definitions/moduleDefinition" + }, + "enumTypes": { + "type": "array", + "items": { + "$ref": "#/properties/abi/definitions/enumDefinition" + } + }, + "interfaceTypes": { + "type": "array", + "items": { + "$ref": "#/properties/abi/definitions/interfaceDefinition" + } + }, + "importedObjectTypes": { + "type": "array", + "items": { + "$ref": "#/properties/abi/definitions/importedObjectDefinition" + } + }, + "importedModuleTypes": { + "type": "array", + "items": { + "$ref": "#/properties/abi/definitions/importedModuleDefinition" + } + }, + "importedEnumTypes": { + "type": "array", + "items": { + "$ref": "#/properties/abi/definitions/importedEnumDefinition" + } + }, + "importedEnvTypes": { + "type": "array", + "items": { + "$ref": "#/properties/abi/definitions/importedEnvDefinition" + } + }, + "envType": { + "$ref": "#/properties/abi/definitions/envDefinition" + } + }, + "definitions": { + "objectDefinition": { + "type": "object", + "required": [ + "properties", + "interfaces" + ], + "allOf": [ + { + "$ref": "#/properties/abi/definitions/genericDefinition" + }, + { + "$ref": "#/properties/abi/definitions/withComment" + } + ], + "properties": { + "properties": { + "type": "array", + "items": { + "$ref": "#/properties/abi/definitions/propertyDefinition" + } + }, + "interfaces": { + "type": "array", + "items": { + "$ref": "#/properties/abi/definitions/interfaceImplementedDefinition" + } + } + }, + "unevaluatedProperties": false + }, + "moduleDefinition": { + "type": "object", + "required": [ + "methods", + "imports", + "interfaces" + ], + "allOf": [ + { + "$ref": "#/properties/abi/definitions/genericDefinition" + }, + { + "$ref": "#/properties/abi/definitions/withComment" + } + ], + "properties": { + "methods": { + "type": "array", + "items": [ + { + "$ref": "#/properties/abi/definitions/methodDefinition" + } + ] + }, + "imports": { + "type": "array", + "items": [ + { + "$ref": "#/properties/abi/definitions/importedModuleRef" + } + ] + }, + "interfaces": { + "type": "array", + "items": [ + { + "$ref": "#/properties/abi/definitions/interfaceImplementedDefinition" + } + ] + } + }, + "unevaluatedProperties": false + }, + "interfaceImplementedDefinition": { + "type": "object", + "allOf": [ + { + "$ref": "#/properties/abi/definitions/genericDefinition" + } + ], + "unevaluatedProperties": false + }, + "methodDefinition": { + "type": "object", + "required": [ + "arguments", + "return" + ], + "allOf": [ + { + "$ref": "#/properties/abi/definitions/genericDefinition" + }, + { + "$ref": "#/properties/abi/definitions/withComment" + } + ], + "properties": { + "arguments": { + "type": "array", + "items": [ + { + "$ref": "#/properties/abi/definitions/propertyDefinition" + } + ] + }, + "env": { + "type": "object", + "properties": { + "required": { + "type": "boolean" + } + }, + "unevaluatedProperties": false + }, + "return": { + "$ref": "#/properties/abi/definitions/propertyDefinition" + } + }, + "unevaluatedProperties": false + }, + "envDefinition": { + "type": "object", + "allOf": [ + { + "$ref": "#/properties/abi/definitions/objectDefinition" + } + ] + }, + "enumDefinition": { + "type": "object", + "required": [ + "constants" + ], + "allOf": [ + { + "$ref": "#/properties/abi/definitions/genericDefinition" + }, + { + "$ref": "#/properties/abi/definitions/withComment" + } + ], + "properties": { + "constants": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "unevaluatedProperties": false + }, + "interfaceDefinition": { + "type": "object", + "required": [ + "capabilities" + ], + "allOf": [ + { + "$ref": "#/properties/abi/definitions/genericDefinition" + }, + { + "$ref": "#/properties/abi/definitions/importedDefinition" + } + ], + "properties": { + "capabilities": { + "$ref": "#/properties/abi/definitions/capabilityDefinition" + } + }, + "unevaluatedProperties": false + }, + "capabilityDefinition": { + "type": "object", + "properties": { + "getImplementations": { + "type": "object", + "required": [ + "enabled" + ], + "properties": { + "enabled": { + "type": "boolean" + } + }, + "unevaluatedProperties": false + } + }, + "unevaluatedProperties": false + }, + "importedDefinition": { + "type": "object", + "required": [ + "uri", + "namespace", + "nativeType" + ], + "properties": { + "uri": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "nativeType": { + "type": "string" + } + }, + "unevaluatedProperties": false + }, + "importedObjectDefinition": { + "type": "object", + "allOf": [ + { + "$ref": "#/properties/abi/definitions/objectDefinition" + }, + { + "$ref": "#/properties/abi/definitions/importedDefinition" + }, + { + "$ref": "#/properties/abi/definitions/withComment" + } + ], + "unevaluatedProperties": false + }, + "importedModuleDefinition": { + "type": "object", + "required": [ + "methods" + ], + "allOf": [ + { + "$ref": "#/properties/abi/definitions/genericDefinition" + }, + { + "$ref": "#/properties/abi/definitions/importedDefinition" + }, + { + "$ref": "#/properties/abi/definitions/withComment" + } + ], + "properties": { + "methods": { + "type": "array", + "items": [ + { + "$ref": "#/properties/abi/definitions/methodDefinition" + } + ] + }, + "isInterface": { + "type": [ + "boolean", + "null" + ] + } + }, + "unevaluatedProperties": false + }, + "importedEnumDefinition": { + "type": "object", + "allOf": [ + { + "$ref": "#/properties/abi/definitions/enumDefinition" + }, + { + "$ref": "#/properties/abi/definitions/importedDefinition" + }, + { + "$ref": "#/properties/abi/definitions/withComment" + } + ], + "unevaluatedProperties": false + }, + "importedEnvDefinition": { + "type": "object", + "allOf": [ + { + "$ref": "#/properties/abi/definitions/importedObjectDefinition" + } + ], + "unevaluatedProperties": false + }, + "withKind": { + "type": "object", + "properties": { + "kind": { + "type": "number" + } + }, + "unevaluatedProperties": false, + "required": [ + "kind" + ] + }, + "withComment": { + "type": "object", + "properties": { + "comment": { + "type": "string" + } + }, + "unevaluatedProperties": false + }, + "propertyDefinition": { + "type": "object", + "allOf": [ + { + "$ref": "#/properties/abi/definitions/withComment" + }, + { + "$ref": "#/properties/abi/definitions/anyDefinition" + } + ], + "unevaluatedProperties": false + }, + "genericDefinition": { + "type": "object", + "allOf": [ + { + "$ref": "#/properties/abi/definitions/withKind" + }, + { + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string" + }, + "name": { + "type": [ + "string", + "null" + ] + }, + "required": { + "type": [ + "boolean", + "null" + ] + } + }, + "unevaluatedProperties": false + } + ], + "unevaluatedProperties": false + }, + "anyDefinition": { + "type": "object", + "allOf": [ + { + "$ref": "#/properties/abi/definitions/genericDefinition" + }, + { + "properties": { + "array": { + "anyOf": [ + { + "$ref": "#/properties/abi/definitions/arrayDefinition" + }, + { + "type": "null" + } + ] + }, + "scalar": { + "anyOf": [ + { + "$ref": "#/properties/abi/definitions/scalarDefinition" + }, + { + "type": "null" + } + ] + }, + "map": { + "anyOf": [ + { + "$ref": "#/properties/abi/definitions/mapDefinition" + }, + { + "type": "null" + } + ] + }, + "object": { + "anyOf": [ + { + "$ref": "#/properties/abi/definitions/objectRef" + }, + { + "type": "null" + } + ] + }, + "enum": { + "anyOf": [ + { + "$ref": "#/properties/abi/definitions/enumRef" + }, + { + "type": "null" + } + ] + }, + "unresolvedObjectOrEnum": { + "anyOf": [ + { + "$ref": "#/properties/abi/definitions/unresolvedObjectOrEnumRef" + }, + { + "type": "null" + } + ] + } + }, + "unevaluatedProperties": false + } + ], + "unevaluatedProperties": false + }, + "arrayDefinition": { + "type": "object", + "allOf": [ + { + "$ref": "#/properties/abi/definitions/anyDefinition" + }, + { + "properties": { + "item": { + "$ref": "#/properties/abi/definitions/genericDefinition" + } + }, + "unevaluatedProperties": false + } + ], + "unevaluatedProperties": false, + "required": [ + "item" + ] + }, + "scalarType": { + "type": "string", + "enum": [ + "UInt", + "UInt8", + "UInt16", + "UInt32", + "Int", + "Int8", + "Int16", + "Int32", + "String", + "Boolean", + "Bytes", + "BigInt", + "BigNumber", + "JSON" + ] + }, + "scalarDefinition": { + "type": "object", + "allOf": [ + { + "$ref": "#/properties/abi/definitions/genericDefinition" + } + ], + "properties": { + "type": { + "$ref": "#/properties/abi/definitions/scalarType" + } + }, + "unevaluatedProperties": false, + "required": [ + "type" + ] + }, + "mapKeyType": { + "type": "string", + "enum": [ + "UInt", + "UInt8", + "UInt16", + "UInt32", + "Int", + "Int8", + "Int16", + "Int32", + "String" + ] + }, + "mapKeyDefinition": { + "type": "object", + "allOf": [ + { + "$ref": "#/properties/abi/definitions/anyDefinition" + }, + { + "properties": { + "type": { + "$ref": "#/properties/abi/definitions/mapKeyType" + } + }, + "unevaluatedProperties": false + } + ], + "unevaluatedProperties": false, + "required": [ + "type" + ] + }, + "mapDefinition": { + "type": "object", + "allOf": [ + { + "$ref": "#/properties/abi/definitions/anyDefinition" + }, + { + "$ref": "#/properties/abi/definitions/withComment" + }, + { + "properties": { + "key": { + "$ref": "#/properties/abi/definitions/mapKeyDefinition" + }, + "value": { + "$ref": "#/properties/abi/definitions/genericDefinition" + } + }, + "unevaluatedProperties": false + } + ], + "unevaluatedProperties": false, + "required": [ + "key", + "value" + ] + }, + "objectRef": { + "type": "object", + "allOf": [ + { + "$ref": "#/properties/abi/definitions/genericDefinition" + } + ], + "unevaluatedProperties": false + }, + "enumRef": { + "type": "object", + "allOf": [ + { + "$ref": "#/properties/abi/definitions/genericDefinition" + } + ], + "unevaluatedProperties": false + }, + "unresolvedObjectOrEnumRef": { + "type": "object", + "allOf": [ + { + "$ref": "#/properties/abi/definitions/genericDefinition" + } + ], + "unevaluatedProperties": false + }, + "importedModuleRef": { + "type": "object", + "properties": { + "type": { + "type": "string" + } + }, + "unevaluatedProperties": false + } + } + } + } +} \ No newline at end of file From 58e1a043f32926bbbe7da16a827cb4f41cd2b6da Mon Sep 17 00:00:00 2001 From: dOrgJelli Date: Wed, 3 Aug 2022 20:27:29 -0500 Subject: [PATCH 4/6] package.json dependency ordering --- packages/js/manifests/wrap/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/js/manifests/wrap/package.json b/packages/js/manifests/wrap/package.json index 654fba179f..900fbcc3a5 100644 --- a/packages/js/manifests/wrap/package.json +++ b/packages/js/manifests/wrap/package.json @@ -23,11 +23,11 @@ }, "devDependencies": { "@polywrap/os-js": "0.3.0", + "@polywrap/wrap-manifest-schemas": "0.3.0", "@types/jest": "26.0.8", "@types/mustache": "4.0.1", "@types/prettier": "2.6.0", "@types/semver": "7.3.8", - "@polywrap/wrap-manifest-schemas": "0.3.0", "jest": "26.6.3", "json-schema-to-typescript": "11.0.1", "mustache": "4.0.1", From dbab919cb6862ee2c87abbd9ba6631ece0da664f Mon Sep 17 00:00:00 2001 From: dOrgJelli Date: Wed, 3 Aug 2022 20:36:28 -0500 Subject: [PATCH 5/6] fix ambiguous schema_... imports --- packages/js/manifests/polywrap/scripts/generate.ts | 2 ++ .../polywrap/scripts/templates/validate-ts.mustache | 6 +++--- .../manifests/polywrap/src/formats/polywrap.app/validate.ts | 6 +++--- .../polywrap/src/formats/polywrap.build/validate.ts | 6 +++--- .../polywrap/src/formats/polywrap.deploy/validate.ts | 6 +++--- .../polywrap/src/formats/polywrap.infra/validate.ts | 6 +++--- .../polywrap/src/formats/polywrap.meta/validate.ts | 6 +++--- .../polywrap/src/formats/polywrap.plugin/validate.ts | 6 +++--- .../js/manifests/polywrap/src/formats/polywrap/validate.ts | 6 +++--- .../js/manifests/wrap/scripts/templates/index-ts.mustache | 4 ++-- .../manifests/wrap/scripts/templates/validate-ts.mustache | 6 +++--- packages/js/manifests/wrap/src/formats/wrap.info/index.ts | 4 ++-- .../js/manifests/wrap/src/formats/wrap.info/validate.ts | 6 +++--- 13 files changed, 36 insertions(+), 34 deletions(-) diff --git a/packages/js/manifests/polywrap/scripts/generate.ts b/packages/js/manifests/polywrap/scripts/generate.ts index 499279efae..aa9d228891 100644 --- a/packages/js/manifests/polywrap/scripts/generate.ts +++ b/packages/js/manifests/polywrap/scripts/generate.ts @@ -88,6 +88,7 @@ async function generateFormatTypes() { os.writeFileSync(tsOutputPath, tsSrc); }; + const firstItem = (arr: Array) => arr[0]; const lastItem = (arr: Array) => arr[arr.length - 1]; const versionToTs = (version: string) => version.replace(/\./g, "_").replace(/\-/g, "_"); @@ -137,6 +138,7 @@ async function generateFormatTypes() { const validateContext = { formats: validateFormats, + first: firstItem(validateFormats), latest: lastItem(validateFormats), validators: [] as string[], }; diff --git a/packages/js/manifests/polywrap/scripts/templates/validate-ts.mustache b/packages/js/manifests/polywrap/scripts/templates/validate-ts.mustache index fe5ad36417..8b7a054d01 100644 --- a/packages/js/manifests/polywrap/scripts/templates/validate-ts.mustache +++ b/packages/js/manifests/polywrap/scripts/templates/validate-ts.mustache @@ -10,7 +10,7 @@ import { } from "."; {{#validators.length}}import * as Validators from "../../validators";{{/validators.length}} {{#formats}} -import schema_{{tsVersion}} from "@polywrap/polywrap-manifest-schemas/formats/{{dir}}/{{version}}.json"; +import {{type}}Schema_{{tsVersion}} from "@polywrap/polywrap-manifest-schemas/formats/{{dir}}/{{version}}.json"; {{/formats}} import { @@ -26,9 +26,9 @@ type {{#latest}}{{type}}{{/latest}}Schemas = { const schemas: {{#latest}}{{type}}{{/latest}}Schemas = { // NOTE: Patch fix for backwards compatability - "0.1.0": schema_0_1, + "0.1.0": {{#first}}{{type}}{{/first}}Schema_0_1, {{#formats}} - "{{version}}": schema_{{tsVersion}}, + "{{version}}": {{type}}Schema_{{tsVersion}}, {{/formats}} }; diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.app/validate.ts b/packages/js/manifests/polywrap/src/formats/polywrap.app/validate.ts index d5bb77f948..5fe7ee082e 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap.app/validate.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap.app/validate.ts @@ -9,7 +9,7 @@ import { AppManifestFormats } from "."; -import schema_0_1 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.app/0.1.json"; +import AppManifestSchema_0_1 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.app/0.1.json"; import { Schema, @@ -24,8 +24,8 @@ type AppManifestSchemas = { const schemas: AppManifestSchemas = { // NOTE: Patch fix for backwards compatability - "0.1.0": schema_0_1, - "0.1": schema_0_1, + "0.1.0": AppManifestSchema_0_1, + "0.1": AppManifestSchema_0_1, }; const validator = new Validator(); diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.build/validate.ts b/packages/js/manifests/polywrap/src/formats/polywrap.build/validate.ts index 3ac17e6e98..591172ec7e 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap.build/validate.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap.build/validate.ts @@ -9,7 +9,7 @@ import { BuildManifestFormats } from "."; -import schema_0_1 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.build/0.1.json"; +import BuildManifestSchema_0_1 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.build/0.1.json"; import { Schema, @@ -24,8 +24,8 @@ type BuildManifestSchemas = { const schemas: BuildManifestSchemas = { // NOTE: Patch fix for backwards compatability - "0.1.0": schema_0_1, - "0.1": schema_0_1, + "0.1.0": BuildManifestSchema_0_1, + "0.1": BuildManifestSchema_0_1, }; const validator = new Validator(); diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.deploy/validate.ts b/packages/js/manifests/polywrap/src/formats/polywrap.deploy/validate.ts index 14f21d80d7..6d0befe523 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap.deploy/validate.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap.deploy/validate.ts @@ -9,7 +9,7 @@ import { DeployManifestFormats } from "."; -import schema_0_1 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.deploy/0.1.json"; +import DeployManifestSchema_0_1 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.deploy/0.1.json"; import { Schema, @@ -24,8 +24,8 @@ type DeployManifestSchemas = { const schemas: DeployManifestSchemas = { // NOTE: Patch fix for backwards compatability - "0.1.0": schema_0_1, - "0.1": schema_0_1, + "0.1.0": DeployManifestSchema_0_1, + "0.1": DeployManifestSchema_0_1, }; const validator = new Validator(); diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.infra/validate.ts b/packages/js/manifests/polywrap/src/formats/polywrap.infra/validate.ts index 78471acd72..61593028f1 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap.infra/validate.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap.infra/validate.ts @@ -9,7 +9,7 @@ import { InfraManifestFormats } from "."; -import schema_0_1 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.infra/0.1.json"; +import InfraManifestSchema_0_1 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.infra/0.1.json"; import { Schema, @@ -24,8 +24,8 @@ type InfraManifestSchemas = { const schemas: InfraManifestSchemas = { // NOTE: Patch fix for backwards compatability - "0.1.0": schema_0_1, - "0.1": schema_0_1, + "0.1.0": InfraManifestSchema_0_1, + "0.1": InfraManifestSchema_0_1, }; const validator = new Validator(); diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.meta/validate.ts b/packages/js/manifests/polywrap/src/formats/polywrap.meta/validate.ts index b2747fc71a..09872692d6 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap.meta/validate.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap.meta/validate.ts @@ -9,7 +9,7 @@ import { MetaManifestFormats } from "."; -import schema_0_1 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.meta/0.1.json"; +import MetaManifestSchema_0_1 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.meta/0.1.json"; import { Schema, @@ -24,8 +24,8 @@ type MetaManifestSchemas = { const schemas: MetaManifestSchemas = { // NOTE: Patch fix for backwards compatability - "0.1.0": schema_0_1, - "0.1": schema_0_1, + "0.1.0": MetaManifestSchema_0_1, + "0.1": MetaManifestSchema_0_1, }; const validator = new Validator(); diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.plugin/validate.ts b/packages/js/manifests/polywrap/src/formats/polywrap.plugin/validate.ts index 01aa2845ef..de976b7646 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap.plugin/validate.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap.plugin/validate.ts @@ -9,7 +9,7 @@ import { PluginManifestFormats } from "."; -import schema_0_1 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.plugin/0.1.json"; +import PluginManifestSchema_0_1 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.plugin/0.1.json"; import { Schema, @@ -24,8 +24,8 @@ type PluginManifestSchemas = { const schemas: PluginManifestSchemas = { // NOTE: Patch fix for backwards compatability - "0.1.0": schema_0_1, - "0.1": schema_0_1, + "0.1.0": PluginManifestSchema_0_1, + "0.1": PluginManifestSchema_0_1, }; const validator = new Validator(); diff --git a/packages/js/manifests/polywrap/src/formats/polywrap/validate.ts b/packages/js/manifests/polywrap/src/formats/polywrap/validate.ts index d3dcc56b9c..e6357a2f66 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap/validate.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap/validate.ts @@ -9,7 +9,7 @@ import { PolywrapManifestFormats } from "."; -import schema_0_1 from "@polywrap/polywrap-manifest-schemas/formats/polywrap/0.1.json"; +import PolywrapManifestSchema_0_1 from "@polywrap/polywrap-manifest-schemas/formats/polywrap/0.1.json"; import { Schema, @@ -24,8 +24,8 @@ type PolywrapManifestSchemas = { const schemas: PolywrapManifestSchemas = { // NOTE: Patch fix for backwards compatability - "0.1.0": schema_0_1, - "0.1": schema_0_1, + "0.1.0": PolywrapManifestSchema_0_1, + "0.1": PolywrapManifestSchema_0_1, }; const validator = new Validator(); diff --git a/packages/js/manifests/wrap/scripts/templates/index-ts.mustache b/packages/js/manifests/wrap/scripts/templates/index-ts.mustache index 137a6e3f45..8e4235dd72 100644 --- a/packages/js/manifests/wrap/scripts/templates/index-ts.mustache +++ b/packages/js/manifests/wrap/scripts/templates/index-ts.mustache @@ -13,14 +13,14 @@ import { {{/formats}} {{#formats}} -import schema_{{tsVersion}} from "./{{version}}.schema.json"; +import WrapManifestSchema_{{tsVersion}} from "./{{version}}.schema.json"; {{/formats}} export { {{#formats}} WrapManifest_{{tsVersion}}, WrapAbi_{{tsVersion}}_{{abiTsVersion}}, - schema_{{tsVersion}} + WrapManifestSchema_{{tsVersion}} {{/formats}} }; diff --git a/packages/js/manifests/wrap/scripts/templates/validate-ts.mustache b/packages/js/manifests/wrap/scripts/templates/validate-ts.mustache index 5e793dbb86..3886f66841 100644 --- a/packages/js/manifests/wrap/scripts/templates/validate-ts.mustache +++ b/packages/js/manifests/wrap/scripts/templates/validate-ts.mustache @@ -8,7 +8,7 @@ import { AnyWrapManifest, WrapManifestVersions, {{#formats}} - schema_{{tsVersion}} + WrapManifestSchema_{{tsVersion}} {{/formats}} } from "."; {{#validators.length}}import * as Validators from "../validators";{{/validators.length}} @@ -27,9 +27,9 @@ type WrapManifestSchemas = { const schemas: WrapManifestSchemas = { // NOTE: Patch fix for backwards compatability - "0.1.0": schema_0_1, + "0.1.0": WrapManifestSchema_0_1, {{#formats}} - "{{version}}": schema_{{tsVersion}}, + "{{version}}": WrapManifestSchema_{{tsVersion}}, {{/formats}} }; diff --git a/packages/js/manifests/wrap/src/formats/wrap.info/index.ts b/packages/js/manifests/wrap/src/formats/wrap.info/index.ts index caab9fec66..5bbcae4a72 100644 --- a/packages/js/manifests/wrap/src/formats/wrap.info/index.ts +++ b/packages/js/manifests/wrap/src/formats/wrap.info/index.ts @@ -10,12 +10,12 @@ import { Abi as WrapAbi_0_1_0_1 } from "./0.1"; -import schema_0_1 from "./0.1.schema.json"; +import WrapManifestSchema_0_1 from "./0.1.schema.json"; export { WrapManifest_0_1, WrapAbi_0_1_0_1, - schema_0_1 + WrapManifestSchema_0_1 }; export enum WrapManifestVersions { diff --git a/packages/js/manifests/wrap/src/formats/wrap.info/validate.ts b/packages/js/manifests/wrap/src/formats/wrap.info/validate.ts index 2b36199019..fd90559a99 100644 --- a/packages/js/manifests/wrap/src/formats/wrap.info/validate.ts +++ b/packages/js/manifests/wrap/src/formats/wrap.info/validate.ts @@ -7,7 +7,7 @@ import { AnyWrapManifest, WrapManifestVersions, - schema_0_1 + WrapManifestSchema_0_1 } from "."; @@ -25,8 +25,8 @@ type WrapManifestSchemas = { const schemas: WrapManifestSchemas = { // NOTE: Patch fix for backwards compatability - "0.1.0": schema_0_1, - "0.1": schema_0_1, + "0.1.0": WrapManifestSchema_0_1, + "0.1": WrapManifestSchema_0_1, }; From 3dff6d548ab7919be214d62be2eab41876717ca1 Mon Sep 17 00:00:00 2001 From: dOrgJelli Date: Wed, 3 Aug 2022 20:38:46 -0500 Subject: [PATCH 6/6] remove needless tsconfig addition --- .../uri-resolvers/file-system-resolver/tsconfig.build.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/js/plugins/uri-resolvers/file-system-resolver/tsconfig.build.json b/packages/js/plugins/uri-resolvers/file-system-resolver/tsconfig.build.json index 19425c477a..2dd44d366d 100644 --- a/packages/js/plugins/uri-resolvers/file-system-resolver/tsconfig.build.json +++ b/packages/js/plugins/uri-resolvers/file-system-resolver/tsconfig.build.json @@ -10,7 +10,6 @@ "dom" ], "moduleResolution": "node", - "resolveJsonModule": true, "declaration": true, "preserveSymlinks": true, "preserveWatchOutput": true,