Skip to content

Commit

Permalink
Merge branch 'main' into disable-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
yoozo committed Oct 30, 2024
2 parents 33ad32c + 93ba438 commit 3a39e78
Show file tree
Hide file tree
Showing 49 changed files with 502 additions and 224 deletions.
3 changes: 3 additions & 0 deletions .yarn/versions/0a6cfead.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
undecided:
- "@subql/cli"
- "@subql/common-substrate"
3 changes: 3 additions & 0 deletions .yarn/versions/61b6fc48.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
undecided:
- "@subql/node-core"
- "@subql/types-core"
Empty file added .yarn/versions/6fdfdb04.yml
Empty file.
Empty file added .yarn/versions/936dc023.yml
Empty file.
3 changes: 3 additions & 0 deletions .yarn/versions/b4e981f5.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
undecided:
- "@subql/common"
- "@subql/testing"
2 changes: 2 additions & 0 deletions .yarn/versions/cb885b36.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
undecided:
- "@subql/node"
2 changes: 2 additions & 0 deletions .yarn/versions/d11aeeaf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
undecided:
- "@subql/node-core"
4 changes: 4 additions & 0 deletions .yarn/versions/d2b1da3c.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
undecided:
- "@subql/cli"
- "@subql/node"
- "@subql/node-core"
Empty file added .yarn/versions/dc0e431b.yml
Empty file.
8 changes: 7 additions & 1 deletion packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [5.3.0] - 2024-10-21
### Changed
- Improve codegen error messages (#2567)
- Update codegen to match changes to store interface making options.limit required on getByField(s) methods (#2567)

## [5.2.8] - 2024-09-25
### Changed
- Bump common, Added manifest support for query-subgraph.
Expand Down Expand Up @@ -682,7 +687,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- support subcommand codegen
- support subcommand init

[Unreleased]: https://github.com/subquery/subql/compare/cli/5.2.8...HEAD
[Unreleased]: https://github.com/subquery/subql/compare/cli/5.3.0...HEAD
[5.3.0]: https://github.com/subquery/subql/compare/cli/5.2.8...cli/5.3.0
[5.2.8]: https://github.com/subquery/subql/compare/cli/5.2.7...cli/5.2.8
[5.2.7]: https://github.com/subquery/subql/compare/cli/5.2.6...cli/5.2.7
[5.2.6]: https://github.com/subquery/subql/compare/cli/5.2.4...cli/5.2.6
Expand Down
32 changes: 16 additions & 16 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ $ npm install -g @subql/cli
$ subql COMMAND
running command...
$ subql (--version)
@subql/cli/5.2.7-0 linux-x64 node-v18.20.4
@subql/cli/5.2.9-0 linux-x64 node-v18.20.4
$ subql --help [COMMAND]
USAGE
$ subql COMMAND
Expand Down Expand Up @@ -71,7 +71,7 @@ DESCRIPTION
Build this SubQuery project code
```

_See code: [lib/commands/build/index.js](https://github.com/packages/cli/blob/v5.2.7-0/lib/commands/build/index.js)_
_See code: [lib/commands/build/index.js](https://github.com/packages/cli/blob/v5.2.9-0/lib/commands/build/index.js)_

## `subql codegen`

Expand All @@ -89,7 +89,7 @@ DESCRIPTION
Generate schemas for graph node
```

_See code: [lib/commands/codegen/index.js](https://github.com/packages/cli/blob/v5.2.7-0/lib/commands/codegen/index.js)_
_See code: [lib/commands/codegen/index.js](https://github.com/packages/cli/blob/v5.2.9-0/lib/commands/codegen/index.js)_

## `subql codegen:generate`

Expand All @@ -112,7 +112,7 @@ DESCRIPTION
Generate Project.yaml and mapping functions based on provided ABI
```

_See code: [lib/commands/codegen/generate.js](https://github.com/packages/cli/blob/v5.2.7-0/lib/commands/codegen/generate.js)_
_See code: [lib/commands/codegen/generate.js](https://github.com/packages/cli/blob/v5.2.9-0/lib/commands/codegen/generate.js)_

## `subql deployment`

Expand Down Expand Up @@ -161,7 +161,7 @@ DESCRIPTION
Deploy to hosted service
```

_See code: [lib/commands/deployment/index.js](https://github.com/packages/cli/blob/v5.2.7-0/lib/commands/deployment/index.js)_
_See code: [lib/commands/deployment/index.js](https://github.com/packages/cli/blob/v5.2.9-0/lib/commands/deployment/index.js)_

## `subql deployment:delete`

Expand All @@ -180,7 +180,7 @@ DESCRIPTION
Delete Deployment
```

_See code: [lib/commands/deployment/delete.js](https://github.com/packages/cli/blob/v5.2.7-0/lib/commands/deployment/delete.js)_
_See code: [lib/commands/deployment/delete.js](https://github.com/packages/cli/blob/v5.2.9-0/lib/commands/deployment/delete.js)_

## `subql deployment:deploy`

Expand Down Expand Up @@ -225,7 +225,7 @@ DESCRIPTION
Deployment to hosted service
```

_See code: [lib/commands/deployment/deploy.js](https://github.com/packages/cli/blob/v5.2.7-0/lib/commands/deployment/deploy.js)_
_See code: [lib/commands/deployment/deploy.js](https://github.com/packages/cli/blob/v5.2.9-0/lib/commands/deployment/deploy.js)_

## `subql deployment:promote`

Expand All @@ -244,7 +244,7 @@ DESCRIPTION
Promote Deployment
```

_See code: [lib/commands/deployment/promote.js](https://github.com/packages/cli/blob/v5.2.7-0/lib/commands/deployment/promote.js)_
_See code: [lib/commands/deployment/promote.js](https://github.com/packages/cli/blob/v5.2.9-0/lib/commands/deployment/promote.js)_

## `subql init [PROJECTNAME]`

Expand All @@ -268,7 +268,7 @@ DESCRIPTION
Initialize a scaffold subquery project
```

_See code: [lib/commands/init.js](https://github.com/packages/cli/blob/v5.2.7-0/lib/commands/init.js)_
_See code: [lib/commands/init.js](https://github.com/packages/cli/blob/v5.2.9-0/lib/commands/init.js)_

## `subql migrate`

Expand All @@ -287,7 +287,7 @@ DESCRIPTION
Schema subgraph project to subquery project
```

_See code: [lib/commands/migrate.js](https://github.com/packages/cli/blob/v5.2.7-0/lib/commands/migrate.js)_
_See code: [lib/commands/migrate.js](https://github.com/packages/cli/blob/v5.2.9-0/lib/commands/migrate.js)_

## `subql multi-chain:add`

Expand All @@ -306,7 +306,7 @@ DESCRIPTION
Add new chain manifest to multi-chain configuration
```

_See code: [lib/commands/multi-chain/add.js](https://github.com/packages/cli/blob/v5.2.7-0/lib/commands/multi-chain/add.js)_
_See code: [lib/commands/multi-chain/add.js](https://github.com/packages/cli/blob/v5.2.9-0/lib/commands/multi-chain/add.js)_

## `subql multi-chain:deploy`

Expand Down Expand Up @@ -352,7 +352,7 @@ DESCRIPTION
Multi-chain deployment to hosted service
```

_See code: [lib/commands/multi-chain/deploy.js](https://github.com/packages/cli/blob/v5.2.7-0/lib/commands/multi-chain/deploy.js)_
_See code: [lib/commands/multi-chain/deploy.js](https://github.com/packages/cli/blob/v5.2.9-0/lib/commands/multi-chain/deploy.js)_

## `subql project`

Expand All @@ -377,7 +377,7 @@ DESCRIPTION
Create/Delete project
```

_See code: [lib/commands/project/index.js](https://github.com/packages/cli/blob/v5.2.7-0/lib/commands/project/index.js)_
_See code: [lib/commands/project/index.js](https://github.com/packages/cli/blob/v5.2.9-0/lib/commands/project/index.js)_

## `subql project:create-project`

Expand All @@ -401,7 +401,7 @@ DESCRIPTION
Create Project on Hosted Service
```

_See code: [lib/commands/project/create-project.js](https://github.com/packages/cli/blob/v5.2.7-0/lib/commands/project/create-project.js)_
_See code: [lib/commands/project/create-project.js](https://github.com/packages/cli/blob/v5.2.9-0/lib/commands/project/create-project.js)_

## `subql project:delete-project`

Expand All @@ -419,7 +419,7 @@ DESCRIPTION
Delete Project on Hosted Service
```

_See code: [lib/commands/project/delete-project.js](https://github.com/packages/cli/blob/v5.2.7-0/lib/commands/project/delete-project.js)_
_See code: [lib/commands/project/delete-project.js](https://github.com/packages/cli/blob/v5.2.9-0/lib/commands/project/delete-project.js)_

## `subql publish`

Expand All @@ -438,6 +438,6 @@ DESCRIPTION
Upload this SubQuery project to IPFS
```

_See code: [lib/commands/publish.js](https://github.com/packages/cli/blob/v5.2.7-0/lib/commands/publish.js)_
_See code: [lib/commands/publish.js](https://github.com/packages/cli/blob/v5.2.9-0/lib/commands/publish.js)_

<!-- commandsstop -->
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@subql/cli",
"description": "cli for subquery",
"version": "5.2.8",
"version": "5.3.0",
"author": "Ian He",
"bin": {
"subql": "./bin/run"
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/src/controller/codegen-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export async function generateJsonInterfaces(projectPath: string, schema: string
await renderTemplate(INTERFACE_TEMPLATE_PATH, path.join(typesDir, `interfaces.ts`), interfaceTemplate);
exportTypes.interfaces = true;
} catch (e) {
throw new Error(`When render json interfaces having problems.`);
throw new Error(`Codegen failed for json interface.`, {cause: e});
}
}
}
Expand All @@ -116,7 +116,7 @@ export async function generateEnums(projectPath: string, schema: string): Promis
await renderTemplate(ENUM_TEMPLATE_PATH, path.join(typesDir, `enums.ts`), enumsTemplate);
exportTypes.enums = true;
} catch (e) {
throw new Error(`When render enums having problems.`);
throw new Error(`Codegen failed for enums.`, {cause: e});
}
}
}
Expand Down Expand Up @@ -262,7 +262,7 @@ export async function codegen(projectPath: string, fileNames: string[] = [DEFAUL
},
});
} catch (e) {
throw new Error(`When render index in types having problems.`);
throw new Error(`Codegen failed for indexes.`, {cause: e});
}
console.log(`* Types index generated !`);
}
Expand Down Expand Up @@ -322,7 +322,7 @@ export async function generateModels(projectPath: string, schema: string): Promi
);
} catch (e) {
console.error(e);
throw new Error(`When render entity ${className} to schema having problems.`);
throw new Error(`Codegen failed for entity ${className}.`, {cause: e});
}
console.log(`* Schema ${className} generated !`);
}
Expand All @@ -339,7 +339,7 @@ export async function generateModels(projectPath: string, schema: string): Promi
});
exportTypes.models = true;
} catch (e) {
throw new Error(`When render index in models having problems.`);
throw new Error(`Failed to codgen for model indexes.`, {cause: e});
}
console.log(`* Models index generated !`);
}
Expand Down
38 changes: 21 additions & 17 deletions packages/cli/src/template/model.ts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {Entity, FunctionPropertyNames, FieldsExpression, GetOptions } from "@subql/types-core";
import assert from 'assert';
<%if (props.importJsonInterfaces.length !== 0) { %>
import {<% props.importJsonInterfaces.forEach(function(interface){ %>
import { <% props.importJsonInterfaces.forEach(function(interface){ %>
<%= interface %>,
<% }); %>} from '../interfaces';
<% } %>
Expand All @@ -11,7 +11,7 @@ import {<% props.importEnums.forEach(function(e){ %>
<%= e %>,
<% }); %>} from '../enums';<% } %>

export type <%= props.className %>Props = Omit<<%=props.className %>, NonNullable<FunctionPropertyNames<<%=props.className %>>>| '_name'>;
export type <%= props.className %>Props = Omit<<%=props.className %>, NonNullable<FunctionPropertyNames<<%=props.className %>>> | '_name'>;

export class <%= props.className %> implements Entity {

Expand All @@ -30,18 +30,18 @@ export class <%= props.className %> implements Entity {
return '<%=props.entityName %>';
}

async save(): Promise<void>{
async save(): Promise<void> {
let id = this.id;
assert(id !== null, "Cannot save <%=props.className %> entity without an ID");
await store.set('<%=props.entityName %>', id.toString(), this);
}

static async remove(id:string): Promise<void>{
static async remove(id: string): Promise<void> {
assert(id !== null, "Cannot remove <%=props.className %> entity without an ID");
await store.remove('<%=props.entityName %>', id.toString());
}

static async get(id:string): Promise<<%=props.className %> | undefined>{
static async get(id: string): Promise<<%=props.className %> | undefined> {
assert((id !== null && id !== undefined), "Cannot get <%=props.className %> entity without an ID");
const record = await store.get('<%=props.entityName %>', id.toString());
if (record) {
Expand All @@ -51,26 +51,30 @@ export class <%= props.className %> implements Entity {
}
}
<% props.indexedFields.forEach(function(field){ %>
static async getBy<%=helper.upperFirst(field.name) %>(<%=field.name %>: <%=field.type %>): Promise<<%=props.className %><%=field.unique ? '' : '[]' %> | undefined>{
<% if (field.unique) {%>
const record = await store.getOneByField('<%=props.entityName %>', '<%=field.name %>', <%=field.name %>);
if (record) {
return this.create(record as <%= props.className %>Props);
} else {
return;
}
<% } else { %>const records = await store.getByField('<%=props.entityName %>', '<%=field.name %>', <%=field.name %>);
return records.map(record => this.create(record as <%= props.className %>Props));<% }%>
<% if (field.unique) {%>
static async getBy<%=helper.upperFirst(field.name) %>(<%=field.name %>: <%=field.type %>): Promise<<%=props.className %> | undefined> {
const record = await store.getOneByField('<%=props.entityName %>', '<%=field.name %>', <%=field.name %>);
if (record) {
return this.create(record as <%= props.className %>Props);
} else {
return;
}
}
<% } else { %>static async getBy<%=helper.upperFirst(field.name) %>(<%=field.name %>: <%=field.type %>, options: GetOptions<<%=props.className %>>): Promise<<%=props.className %>[]> {
const records = await store.getByField<<%=props.className %>>('<%=props.entityName %>', '<%=field.name %>', <%=field.name %>, options);
return records.map(record => this.create(record as <%= props.className %>Props));
}
<% }%>
<% }); %>

/**
* Gets entities matching the specified filters and options.
*
* ⚠️ This function will first search cache data followed by DB data. Please consider this when using order and offset options.⚠️
* */
static async getByFields(filter: FieldsExpression<<%= props.className %>Props>[], options?: GetOptions<<%= props.className %>Props>): Promise<<%=props.className %>[]> {
const records = await store.getByFields('<%=props.entityName %>', filter, options);
static async getByFields(filter: FieldsExpression<<%= props.className %>Props>[], options: GetOptions<<%= props.className %>Props>): Promise<<%=props.className %>[]> {
const records = await store.getByFields<<%=props.className %>>('<%=props.entityName %>', filter, options);
return records.map(record => this.create(record as <%= props.className %>Props));
}

Expand Down
7 changes: 6 additions & 1 deletion packages/common-substrate/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [4.3.2] - 2024-10-23
### Changed
- Bump version with `@subql/common`

## [4.3.1] - 2024-09-25
### Changed
- Bump common, Added manifest support for query-subgraph.
Expand Down Expand Up @@ -189,7 +193,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- init commit

[Unreleased]: https://github.com/subquery/subql/compare/common-substrate/4.3.1...HEAD
[Unreleased]: https://github.com/subquery/subql/compare/common-substrate/4.3.2...HEAD
[4.3.2]: https://github.com/subquery/subql/compare/common-substrate/4.3.1...common-substrate/4.3.2
[4.3.1]: https://github.com/subquery/subql/compare/common-substrate/4.3.0...common-substrate/4.3.1
[4.3.0]: https://github.com/subquery/subql/compare/common-substrate/4.2.0...common-substrate/4.3.0
[4.2.0]: https://github.com/subquery/subql/compare/common-substrate/4.1.1...common-substrate/4.2.0
Expand Down
2 changes: 1 addition & 1 deletion packages/common-substrate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@subql/common-substrate",
"version": "4.3.1",
"version": "4.3.2",
"description": "",
"scripts": {
"build": "rm -rf dist && tsc -b",
Expand Down
7 changes: 6 additions & 1 deletion packages/common/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [5.1.4] - 2024-10-23
### Fixed
- Bump version `@subql/types-core`

## [5.1.3] - 2024-09-25
### Added
- `Runner.query` support `@subql/query-subgraph` option
Expand Down Expand Up @@ -415,7 +419,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- init commit

[Unreleased]: https://github.com/subquery/subql/compare/common/5.1.3...HEAD
[Unreleased]: https://github.com/subquery/subql/compare/common/5.1.4...HEAD
[5.1.4]: https://github.com/subquery/subql/compare/common/5.1.3...common/5.1.4
[5.1.3]: https://github.com/subquery/subql/compare/common/5.1.2...common/5.1.3
[5.1.2]: https://github.com/subquery/subql/compare/common/5.1.1...common/5.1.2
[5.1.1]: https://github.com/subquery/subql/compare/common/5.1.0...common/5.1.1
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@subql/common",
"version": "5.1.3",
"version": "5.1.4",
"description": "",
"scripts": {
"build": "rm -rf dist && tsc -b",
Expand Down
Loading

0 comments on commit 3a39e78

Please sign in to comment.