Skip to content

Commit cfc1794

Browse files
committed
refactor: rearrange packages, flatten further
Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>
1 parent 667f058 commit cfc1794

File tree

115 files changed

+400
-2031
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+400
-2031
lines changed

.changeset/README.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

.changeset/config.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ v8-compile-cache-0
1010
.vscode
1111

1212
/.iroha
13-
/packages/crypto-*/src/wasm-target
13+
/packages/crypto*/wasm-target
1414

deno.jsonc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"nodeModulesDir": "auto",
33
"workspace": [
4-
"./packages/data-model",
5-
"./packages/client",
4+
"./packages/core",
65
"./packages/crypto",
76
"./packages/crypto-target-node",
87
"./packages/crypto-target-web",
8+
"./packages/client",
99
// Could be enabled for DX (i.e. Deno LSP will recognise and help), but Deno will fail at running
1010
// because of deps in `package.json`. They are specified with `pnpm dlx jsr add ...`, and Deno doesn't handle that.
1111
"./tests/support/iroha-source",
@@ -52,7 +52,7 @@
5252
},
5353
"fmt": {
5454
"include": ["."],
55-
"exclude": ["**/*._generated_.ts"],
55+
"exclude": ["**/*_generated_.ts"],
5656
"semiColons": false,
5757
"lineWidth": 120,
5858
"singleQuote": true
@@ -68,6 +68,7 @@
6868
"@deno/vite-plugin": "npm:@deno/vite-plugin@^1.0.3",
6969
"@std/assert": "jsr:@std/assert@^1.0.11",
7070
"@std/async": "jsr:@std/async@^1.0.10",
71+
"@std/encoding": "jsr:@std/encoding@^1.0.7",
7172
"@std/fmt": "jsr:@std/fmt@^1.0.5",
7273
"@std/toml": "jsr:@std/toml@^1.0.2",
7374
"change-case": "npm:change-case@^5.4.4",

deno.lock

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

etc/codegen.spec.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, test } from 'vitest'
2-
import type { Schema } from '../packages/data-model/src/schema/lib.ts'
3-
import { SCHEMA } from '../packages/data-model/src/schema/lib.ts'
2+
import type { Schema } from '@iroha/core/data-model/schema'
3+
import SCHEMA from '@iroha/core/data-model/schema-json'
44
import {
55
type EmitCode,
66
type EmitsMap,
@@ -49,24 +49,21 @@ const EXTENSION: Schema = {
4949
5050
*/
5151

52-
// function prettierFormat(code: string): Promise<string> {
53-
// return format(code, { parser: 'typescript', ...PRETTIER_OPTIONS })
54-
// }
55-
5652
// convenient for development in watch mode
5753
// works almost as if JavaScript supported comptime codegen
5854
test('codegen snapshots', async () => {
5955
expect(SCHEMA).not.contain.keys(Object.keys(EXTENSION))
6056

6157
const resolver = new Resolver({ ...SCHEMA, ...EXTENSION })
6258

63-
await expect(await formatTS(generateDataModel(resolver, './data-model.prelude.ts'))).toMatchFileSnapshot(
64-
'../packages/data-model/src/generated/data-model._generated_.ts',
59+
await expect(await formatTS(generateDataModel(resolver, './_generated_.prelude.ts'))).toMatchFileSnapshot(
60+
'../packages/core/data-model/_generated_.ts',
6561
)
6662

67-
await expect(await formatTS(generateClientFindAPI(resolver, './find-api.prelude.ts'))).toMatchFileSnapshot(
68-
'../packages/client/src/generated/find-api._generated_.ts',
69-
)
63+
await expect(await formatTS(generateClientFindAPI(resolver, './find-api._generated_.prelude.ts')))
64+
.toMatchFileSnapshot(
65+
'../packages/client/find-api._generated_.ts',
66+
)
7067
})
7168

7269
// test("codegen")

etc/codegen.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { EnumDefinition, NamedStructDefinition, Schema, SchemaTypeDefinition } from '@iroha2/data-model'
1+
import type { EnumDefinition, NamedStructDefinition, Schema, SchemaTypeDefinition } from '@iroha/core/data-model/schema'
22
import { camelCase } from 'change-case'
33
import { deepEqual } from 'fast-equals'
44
import { assert as assert, fail } from '@std/assert'
@@ -58,8 +58,8 @@ export function generateClientFindAPI(resolver: Resolver, libClient: string): st
5858
`/**\n* Convenience method for \`${x.tag}\` query, a variant of {@link dm.QueryBox} enum.\n` +
5959
`* - Predicate type: {@link dm.${predicate}}\n` +
6060
`* - Selector type: {@link dm.${selector}}\n */\n` +
61-
` public ${methodName}<const P extends dm.BuildQueryParams<'${x.tag}'>>(${payloadArg}params?: P): ` +
62-
`client.QueryHandle<dm.GetQueryOutput<'${x.tag}', P>> {` +
61+
` public ${methodName}<const P extends core.BuildQueryParams<'${x.tag}'>>(${payloadArg}params?: P): ` +
62+
`client.QueryHandle<core.GetQueryOutput<'${x.tag}', P>> {` +
6363
`return client.buildQueryHandle(this._executor, '${x.tag}', ${payloadArgValue}, params) }\n`
6464
)
6565
})
@@ -75,14 +75,15 @@ export function generateClientFindAPI(resolver: Resolver, libClient: string): st
7575

7676
return (
7777
`\n/** Convenience method for \`${x.tag}\` query, a variant of {@link dm.SingularQueryBox} enum. */` +
78-
` public ${methodName}(): Promise<dm.GetSingularQueryOutput<'${x.tag}'>> {` +
78+
` public ${methodName}(): Promise<core.GetSingularQueryOutput<'${x.tag}'>> {` +
7979
`return client.executeSingularQuery(this._executor, '${x.tag}') }`
8080
)
8181
})
8282

8383
return [
8484
`import * as client from '${libClient}'`,
85-
`import type * as dm from '@iroha2/data-model'`,
85+
`import type * as core from '@iroha/core'`,
86+
`import type * as dm from '@iroha/core/data-model'`,
8687
`export class FindAPI {`,
8788
` private _executor: client.QueryExecutor`,
8889
` public constructor(executor: client.QueryExecutor) { this._executor = executor; }`,

etc/task-prep-crypto-wasm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async function buildCryptoWasm(opts?: { wasmPack?: boolean }) {
4343
await Deno.mkdir(copyToDir)
4444
const dts = path.join(wasmPackOutDir('node'), `${wasmPackOutName}.d.ts`)
4545
await $`cp ${dts} ${copyToDir}/wasm-pkg.d.ts`
46-
$.logStep('Copied artifacts to @iroha2/crypto* packages')
46+
$.logStep('Copied artifacts to @iroha/crypto* packages')
4747
}
4848

4949
const args = parseArgs(Deno.args, {

0 commit comments

Comments
 (0)