Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Remove ABI from schema package #1073

Merged
merged 28 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6919583
chore(schema/parse): removed abi - not building yet
cbrzn Jul 23, 2022
1073f25
chore(schema/parse): abi definition removed from schema package
cbrzn Jul 25, 2022
6c6bf3f
Merge branch 'origin-dev' into chore/remove-abi-from-schema-parse
cbrzn Jul 25, 2022
dffb9dc
chore(schema/bind): updated with wrap abi
cbrzn Jul 25, 2022
8d251ec
chore(schema/compose): updated with wrap abi
cbrzn Jul 25, 2022
a78da19
chore(schema): fix lint on schema & compose packages
cbrzn Jul 25, 2022
61e156e
chore(cli): remove schema parse dependency from cli
cbrzn Jul 25, 2022
515d235
fix: use undefined instead of null
Niraj-Kamdar Jul 28, 2022
ec18988
wip: refactor schema-parse
Niraj-Kamdar Jul 28, 2022
6a2ee3f
chore: fix typing
Niraj-Kamdar Jul 28, 2022
1761989
wip: schema parse tests
Niraj-Kamdar Jul 28, 2022
35d6d1e
fix(schema-parse): replace Abi with WrapAbi from Wrap Manifest
Niraj-Kamdar Jul 29, 2022
64beb2d
fix(schema-compose): tests
Niraj-Kamdar Jul 29, 2022
809674a
fix(schema-bind): tests
Niraj-Kamdar Jul 29, 2022
5c6b45d
fix(cli): issue
Niraj-Kamdar Jul 29, 2022
57f9f5c
fix(schema-bind): map length binding
Niraj-Kamdar Jul 29, 2022
ce6028f
Merge branch 'origin-dev' into chore/remove-abi-from-schema-parse
Niraj-Kamdar Jul 29, 2022
715352c
fix(schema-bind): msgpack map length bindings
Niraj-Kamdar Jul 30, 2022
bb2a88c
fix: circular deps
Niraj-Kamdar Jul 30, 2022
06442fd
Merge remote-tracking branch 'upstream/origin-dev' into chore/remove-…
Niraj-Kamdar Aug 1, 2022
9f992dd
fix(schema-bind): imported-env issue
Niraj-Kamdar Aug 1, 2022
c8c0bda
Update packages/schema/parse/src/__tests__/transforms.spec.ts
Niraj-Kamdar Aug 1, 2022
c7663df
chore: fixed conflicts
cbrzn Aug 8, 2022
5cf775b
merge origin-dev
dOrgJelli Aug 12, 2022
8930f83
add schema-parse dep to cli
dOrgJelli Aug 12, 2022
c619ebe
improve schema-parse import patterns
dOrgJelli Aug 12, 2022
d56f252
make generation template future proof
dOrgJelli Aug 12, 2022
5a6000c
lint fix
dOrgJelli Aug 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"clean": "npx rimraf ./**/node_modules ./**/yarn.lock ./**/build ./**/coverage ./**/.polywrap",
"dependencies:install": "cd dependencies && yarn",
"preinstall": "yarn dependencies:install",
"build": "yarn build:core && yarn link:interface:deps && yarn build:interfaces && yarn build:plugins && yarn build:client && yarn build:test-env && yarn build:cli",
"build": "yarn build:core && yarn build:interfaces && yarn build:plugins && yarn build:client && yarn build:test-env && yarn build:cli",
"build:core": "lerna run build --no-private --ignore @polywrap/*-plugin-js --ignore polywrap --ignore @polywrap/client-js --ignore @polywrap/react --ignore @polywrap/test-env-js --ignore @polywrap/*-interface",
"build:interfaces": "lerna run build --scope @polywrap/*-interface --concurrency 1",
"build:plugins": "lerna run build --scope @polywrap/*-plugin-js --concurrency 1",
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/__tests__/e2e/deploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,13 @@ describe("e2e tests for deploy command", () => {
input: {
uri: "wrap://fs/./build"
},
result: "wrap://ipfs/QmTVbK7oZr4km4AnRuzJpm1r68G7nGzaXFvQHWdwnu8hmv"
result: "wrap://ipfs/QmPDJ9GMgqx1iScNpZh2MerK27YFNKayY5fBoGXfPWWEqm"
},
{
id: "ipfs_deploy.from_deploy",
name: "from_deploy",
input: {
uri: "wrap://ipfs/QmTVbK7oZr4km4AnRuzJpm1r68G7nGzaXFvQHWdwnu8hmv",
uri: "wrap://ipfs/QmPDJ9GMgqx1iScNpZh2MerK27YFNKayY5fBoGXfPWWEqm",
config: {
domainName: "test1.eth",
provider: "http://localhost:8545",
Expand All @@ -226,7 +226,7 @@ describe("e2e tests for deploy command", () => {
id: "ipfs_deploy.from_deploy2",
name: "from_deploy2",
input: {
uri: "wrap://ipfs/QmTVbK7oZr4km4AnRuzJpm1r68G7nGzaXFvQHWdwnu8hmv",
uri: "wrap://ipfs/QmPDJ9GMgqx1iScNpZh2MerK27YFNKayY5fBoGXfPWWEqm",
config: {
domainName: "test2.eth",
provider: "http://localhost:8545",
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/lib/Compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { msgpackEncode } from "@polywrap/msgpack-js";
import { WasmWrapper } from "@polywrap/client-js";
import { WrapImports } from "@polywrap/client-js/build/wasm/types";
import { AsyncWasmInstance } from "@polywrap/asyncify-js";
import { Abi } from "@polywrap/schema-parse";
import { ComposerOutput } from "@polywrap/schema-compose";
import {
normalizePath,
Expand Down Expand Up @@ -358,7 +357,7 @@ export class Compiler {

const manifest = await project.getManifest();

const abi: Abi = {
const abi: WrapAbi = {
...state.composerOutput.abi,
};

Expand Down
14 changes: 6 additions & 8 deletions packages/cli/src/lib/SchemaComposer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ export class SchemaComposer {
}
: undefined;

const schemaFile = getSchemaFile(schemaNamedPath);
if (!schemaFile) {
throw Error(`Schema cannot be loaded at path: ${schemaNamedPath}`);
}

const options: ComposerOptions = {
schemas: [],
schema: schemaFile,
resolvers: {
external: (uri: string) =>
this._fetchExternalSchema(uri, import_redirects),
Expand All @@ -58,13 +63,6 @@ export class SchemaComposer {
output,
};

const schemaFile = getSchemaFile(schemaNamedPath);
if (!schemaFile) {
throw Error(`Schema cannot be loaded at path: ${schemaNamedPath}`);
}

options.schemas.push(schemaFile);

this._composerOutput = await composeSchema(options);
return this._composerOutput;
}
Expand Down
112 changes: 60 additions & 52 deletions packages/cli/src/lib/docgen/docusaurus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "../utils";

import {
Abi,
WrapAbi,
transformAbi,
addFirstLast,
toPrefixedGraphQLType,
Expand Down Expand Up @@ -64,7 +64,7 @@ export const generateBinding: GenerateBindingFn = (
}

// generate object types
if (abi.objectTypes.length > 0) {
if (abi.objectTypes && abi.objectTypes.length > 0) {
const objectContext = {
objectTypes: abi.objectTypes,
};
Expand All @@ -76,7 +76,7 @@ export const generateBinding: GenerateBindingFn = (
}

// generate enum types
if (abi.enumTypes.length > 0) {
if (abi.enumTypes && abi.enumTypes.length > 0) {
const enumContext = {
enumTypes: abi.enumTypes,
};
Expand All @@ -98,73 +98,81 @@ export const generateBinding: GenerateBindingFn = (
if (options.config?.["imports"]) {
// TODO: for imported modules, module.type contains the namespace. Should it?
// generate imported modules
for (const module of abi.importedModuleTypes) {
const moduleType = module.type.split("_")[1];
const moduleContext = {
...module,
type: moduleType,
imported: { namespace: module.namespace },
};
renderTemplate(
"./templates/docusaurus-module.mustache",
moduleContext,
`${module.namespace}_${moduleType.toLowerCase()}.md`
);
}

// generated imported object types
const importedObjects = arrangeByNamespace(abi.importedObjectTypes);
for (const [namespace, objectTypes] of Object.entries(importedObjects)) {
if (objectTypes.length > 0) {
const objectContext = {
objectTypes,
imported: { namespace },
if (abi.importedModuleTypes) {
for (const module of abi.importedModuleTypes) {
const moduleType = module.type.split("_")[1];
const moduleContext = {
...module,
type: moduleType,
imported: { namespace: module.namespace },
};
renderTemplate(
"./templates/docusaurus-objects.mustache",
objectContext,
`${namespace}_objects.md`
"./templates/docusaurus-module.mustache",
moduleContext,
`${module.namespace}_${moduleType.toLowerCase()}.md`
);
}
}

// generated imported object types
if (abi.importedObjectTypes) {
const importedObjects = arrangeByNamespace(abi.importedObjectTypes);
for (const [namespace, objectTypes] of Object.entries(importedObjects)) {
if (objectTypes.length > 0) {
const objectContext = {
objectTypes,
imported: { namespace },
};
renderTemplate(
"./templates/docusaurus-objects.mustache",
objectContext,
`${namespace}_objects.md`
);
}
}
}

// generate imported enum types
const importedEnums = arrangeByNamespace(abi.importedEnumTypes);
for (const [namespace, enumTypes] of Object.entries(importedEnums)) {
if (enumTypes.length > 0) {
const enumContext = {
enumTypes,
imported: { namespace },
};
renderTemplate(
"./templates/docusaurus-enums.mustache",
enumContext,
`${namespace}_enums.md`
);
if (abi.importedEnumTypes) {
const importedEnums = arrangeByNamespace(abi.importedEnumTypes);
for (const [namespace, enumTypes] of Object.entries(importedEnums)) {
if (enumTypes.length > 0) {
const enumContext = {
enumTypes,
imported: { namespace },
};
renderTemplate(
"./templates/docusaurus-enums.mustache",
enumContext,
`${namespace}_enums.md`
);
}
}
}

// generate imported env types
const importedEnvs = arrangeByNamespace(abi.importedEnvTypes);
for (const [namespace, envType] of Object.entries(importedEnvs)) {
if (envType) {
const envContext = {
envType,
imported: { namespace },
};
renderTemplate(
"./templates/docusaurus-env.mustache",
envContext,
`${namespace}_env.md`
);
if (abi.importedEnvTypes) {
const importedEnvs = arrangeByNamespace(abi.importedEnvTypes);
for (const [namespace, envType] of Object.entries(importedEnvs)) {
if (envType) {
const envContext = {
envType,
imported: { namespace },
};
renderTemplate(
"./templates/docusaurus-env.mustache",
envContext,
`${namespace}_env.md`
);
}
}
}
}

return result;
};

function applyTransforms(abi: Abi): Abi {
function applyTransforms(abi: WrapAbi): WrapAbi {
const transforms = [
extendType(Functions),
extendType(TypeScript.Functions),
Expand Down
108 changes: 58 additions & 50 deletions packages/cli/src/lib/docgen/jsdoc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import {
} from "../utils";

import {
Abi,
transformAbi,
addFirstLast,
toPrefixedGraphQLType,
extendType,
methodParentPointers,
ImportedDefinition,
ModuleDefinition,
WrapAbi,
} from "@polywrap/schema-parse";
import {
BindOptions,
Expand Down Expand Up @@ -67,12 +67,12 @@ export const generateBinding: GenerateBindingFn = (
}

// generate object types
if (abi.objectTypes.length > 0) {
if (abi.objectTypes && abi.objectTypes.length > 0) {
renderTemplate("./templates/jsdoc-objects.mustache", abi, "objects.js");
}

// generate enum types
if (abi.enumTypes.length > 0) {
if (abi.enumTypes && abi.enumTypes.length > 0) {
renderTemplate("./templates/jsdoc-enums.mustache", abi, "enums.js");
}

Expand All @@ -87,71 +87,79 @@ export const generateBinding: GenerateBindingFn = (
if (options.config?.["imports"]) {
// TODO: for imported modules, module.type contains the namespace. Should it?
// generate imported modules
for (const module of abi.importedModuleTypes) {
const moduleContext = {
...module,
imported: { namespace: module.namespace },
};
renderTemplate(
"./templates/jsdoc-module.mustache",
moduleContext,
`${module.type}.js`
);
}

// generated imported object types
const importedObjects = sortByNamespace(abi.importedObjectTypes);
for (const [namespace, objectTypes] of Object.entries(importedObjects)) {
if (objectTypes.length > 0) {
const objectContext = {
objectTypes,
imported: { namespace },
if (abi.importedModuleTypes) {
for (const module of abi.importedModuleTypes) {
const moduleContext = {
...module,
imported: { namespace: module.namespace },
};
renderTemplate(
"./templates/jsdoc-objects.mustache",
objectContext,
`${namespace}_objects.js`
"./templates/jsdoc-module.mustache",
moduleContext,
`${module.type}.js`
);
}
}

// generated imported object types
if (abi.importedObjectTypes) {
const importedObjects = sortByNamespace(abi.importedObjectTypes);
for (const [namespace, objectTypes] of Object.entries(importedObjects)) {
if (objectTypes.length > 0) {
const objectContext = {
objectTypes,
imported: { namespace },
};
renderTemplate(
"./templates/jsdoc-objects.mustache",
objectContext,
`${namespace}_objects.js`
);
}
}
}

// generate imported enum types
const importedEnums = sortByNamespace(abi.importedEnumTypes);
for (const [namespace, enumTypes] of Object.entries(importedEnums)) {
if (enumTypes.length > 0) {
const enumContext = {
enumTypes,
imported: { namespace },
};
renderTemplate(
"./templates/jsdoc-enums.mustache",
enumContext,
`${namespace}_enums.js`
);
if (abi.importedEnumTypes) {
const importedEnums = sortByNamespace(abi.importedEnumTypes);
for (const [namespace, enumTypes] of Object.entries(importedEnums)) {
if (enumTypes.length > 0) {
const enumContext = {
enumTypes,
imported: { namespace },
};
renderTemplate(
"./templates/jsdoc-enums.mustache",
enumContext,
`${namespace}_enums.js`
);
}
}
}

// generate imported env types
const importedEnvs = arrangeByNamespace(abi.importedEnvTypes);
for (const [namespace, envType] of Object.entries(importedEnvs)) {
if (envType) {
const envContext = {
envType,
imported: { namespace },
};
renderTemplate(
"./templates/jsdoc-env.mustache",
envContext,
`${namespace}_env.js`
);
if (abi.importedEnvTypes) {
const importedEnvs = arrangeByNamespace(abi.importedEnvTypes);
for (const [namespace, envType] of Object.entries(importedEnvs)) {
if (envType) {
const envContext = {
envType,
imported: { namespace },
};
renderTemplate(
"./templates/jsdoc-env.mustache",
envContext,
`${namespace}_env.js`
);
}
}
}
}

return result;
};

function applyTransforms(abi: Abi): Abi {
function applyTransforms(abi: WrapAbi): WrapAbi {
const transforms = [
extendType(Functions),
extendType(TypeScript.Functions),
Expand Down
Loading