mirror of
https://github.com/pezkuwichain/pezkuwi-api.git
synced 2026-11-03 23:01:07 +00:00
Move to @pezkuwi/dev 0.86 (eslint 10 toolchain)
- @pezkuwi/dev, dev-test, dev-ts ^0.86.3; disable directives renamed for the new rule names, or removed where the rule no longer reports - rethrown errors carry the original as `cause` (13 sites) - optional chains where a guard expression tested the same value - Init: the registry cache settles with the creator's own promise, dropping the entry in finally(), instead of re-wrapping it - Combinator: a typed call instead of `Function` - checkTypes.manual: synchronous checks run outside Promise.all - sortValues, createTypeUnsafe: initial values that were never read - typegen util: load docs.js for its side effect (it registers the `docs` Handlebars partial) now that its types are re-exported type-only - MockProvider keeps its Header assertion: the package's own build does not load api-augment, so createType returns a plain Codec there - Decorate keeps `delete queue[i]`: the hole marks a fired queue and later indexes must not shift
This commit is contained in:
1 parent
8c9af013b5
commit
60e0f73ffa
166 files changed
+2757
-3731
No files matched your search
@@ -64,7 +64,7 @@ function entrySignature (lookup: PortableRegistry, allDefs: Record<string, Modul
|
||||
|
||||
throw new Error(`Expected Plain or Map type, found ${storageEntry.type.type}`);
|
||||
} catch (error) {
|
||||
throw new Error(`entrySignature: Cannot create signature for query ${section}.${storageEntry.name.toString()}:: ${(error as Error).message}`);
|
||||
throw new Error(`entrySignature: Cannot create signature for query ${section}.${storageEntry.name.toString()}:: ${(error as Error).message}`, { cause: error });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ function tsResultGetter (registry: Registry, definitions: Record<string, ModuleT
|
||||
|
||||
/** @internal */
|
||||
function tsResult (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
|
||||
const [okDef, errorDef] = (def.sub as TypeDef[]);
|
||||
const [okDef, errorDef] = def.sub as TypeDef[];
|
||||
const inner = [
|
||||
tsResultGetter(registry, definitions, def.name, 'Err', errorDef, imports),
|
||||
tsResultGetter(registry, definitions, def.name, 'Ok', okDef, imports)
|
||||
|
||||
@@ -8,7 +8,7 @@ export type ExtraTypes = Record<string, Record<string, {
|
||||
types: Record<string, any>;
|
||||
}>>;
|
||||
|
||||
export function getDeprecationNotice<T extends { isDeprecated: boolean; asDeprecated: { note: Text; since: Option<Text> }}> (deprecationInfo: T, name: string, label?: string): string {
|
||||
export function getDeprecationNotice<T extends { isDeprecated: boolean; asDeprecated: { note: Text; since: Option<Text> } }> (deprecationInfo: T, name: string, label?: string): string {
|
||||
let deprecationNotice = '@deprecated';
|
||||
|
||||
if (deprecationInfo.isDeprecated) {
|
||||
|
||||
@@ -122,8 +122,8 @@ function docsVecToMarkdown (docLines: Vec<Text>, indent = 0): string {
|
||||
? `${md}\n\n` // empty line
|
||||
: /^[*-]/.test(docLine.trimStart()) && !md.endsWith('\n\n')
|
||||
? `${md}\n\n${docLine}` // line calling for a preceding linebreak
|
||||
: `${md} ${docLine.replace(/^#{1,3} /, '#### ')} `
|
||||
, '')
|
||||
: `${md} ${docLine.replace(/^#{1,3} /, '#### ')} `,
|
||||
'')
|
||||
.replace(/#### <weight>/g, '<weight>')
|
||||
.replace(/<weight>(.|\n)*?<\/weight>/g, '')
|
||||
.replace(/#### Weight:/g, 'Weight:');
|
||||
@@ -166,7 +166,6 @@ function renderPage (page: Page): string {
|
||||
.filter((key) => !['link', 'name'].includes(key))
|
||||
.forEach((bullet) => {
|
||||
md += `\n- **${bullet}**: ${
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
item[bullet] instanceof Vec
|
||||
? docsVecToMarkdown(item[bullet], 2).toString()
|
||||
: item[bullet]
|
||||
@@ -232,7 +231,6 @@ function addRpc (_runtimeDesc: string, rpcMethods?: string[]): string {
|
||||
}
|
||||
|
||||
const args = method.params.map(({ isOptional, name, type }: DefinitionRpcParam): string => {
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
||||
return name + (isOptional ? '?' : '') + ': `' + type + '`';
|
||||
}).join(', ');
|
||||
const type = '`' + method.type + '`';
|
||||
@@ -311,7 +309,6 @@ function runtimeSections (registry: Registry) {
|
||||
.sort(([a], [b]) => a.localeCompare(b))
|
||||
.forEach(([methodName, { description, params, type }]): void => {
|
||||
const args = params.map(({ name, type }): string => {
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
||||
return name + ': `' + type + '`';
|
||||
}).join(', ');
|
||||
|
||||
@@ -356,7 +353,7 @@ function addLegacyRuntime (_runtimeDesc: string, _registry: Registry, apis?: Api
|
||||
const apiHash = blake2AsHex(apiName, 64);
|
||||
const api = apis.find(([hash]) => hash === apiHash);
|
||||
|
||||
if (!api || api[1] !== version) {
|
||||
if (api?.[1] !== version) {
|
||||
return;
|
||||
}
|
||||
} else if (index) {
|
||||
@@ -373,7 +370,6 @@ function addLegacyRuntime (_runtimeDesc: string, _registry: Registry, apis?: Api
|
||||
.sort(([a], [b]) => a.localeCompare(b))
|
||||
.forEach(([methodName, { description, params, type }]): void => {
|
||||
const args = params.map(({ name, type }): string => {
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
||||
return name + ': `' + type + '`';
|
||||
}).join(', ');
|
||||
|
||||
@@ -629,9 +625,9 @@ function extractDeriveExample (tags: Spec[]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (line.source.indexOf('```') !== -1 && !inCodeBlock.found) {
|
||||
if (line.source.includes('```') && !inCodeBlock.found) {
|
||||
inCodeBlock.found = true;
|
||||
} else if (line.source.indexOf('```') !== -1 && inCodeBlock.found) {
|
||||
} else if (line.source.includes('```') && inCodeBlock.found) {
|
||||
inCodeBlock.done = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ export function exportInterface (lookupIndex = -1, name = '', base: string, body
|
||||
}
|
||||
|
||||
function singleParamNotation (registry: Registry, wrapper: string, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean): string {
|
||||
const sub = (typeDef.sub as TypeDef);
|
||||
const sub = typeDef.sub as TypeDef;
|
||||
const lookupName = rebrandTypeName(sub.lookupName || '');
|
||||
|
||||
setImports(definitions, imports, [wrapper, lookupName]);
|
||||
@@ -148,7 +148,7 @@ function singleParamNotation (registry: Registry, wrapper: string, typeDef: Type
|
||||
}
|
||||
|
||||
function dualParamsNotation (registry: Registry, wrapper: string, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean): string {
|
||||
const [a, b] = (typeDef.sub as TypeDef[]);
|
||||
const [a, b] = typeDef.sub as TypeDef[];
|
||||
const aLookupName = rebrandTypeName(a.lookupName || '');
|
||||
const bLookupName = rebrandTypeName(b.lookupName || '');
|
||||
|
||||
@@ -254,7 +254,7 @@ const formatters: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef, def
|
||||
},
|
||||
|
||||
[TypeDefInfo.VecFixed]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
const sub = (typeDef.sub as TypeDef);
|
||||
const sub = typeDef.sub as TypeDef;
|
||||
|
||||
if (sub.type === 'u8') {
|
||||
// Use lookupName if available (e.g., PezspCoreCryptoAccountId32) instead of generic U8aFixed
|
||||
@@ -318,7 +318,6 @@ export function isInlineStruct (type: string): boolean {
|
||||
* Correctly format a given type
|
||||
*/
|
||||
/** @internal */
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
export function formatType (registry: Registry, definitions: Record<string, ModuleTypes>, type: AnyString | TypeDef, imports: TypeImports, withShortcut = false): string {
|
||||
let typeDef: TypeDef;
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
// Copyright 2017-2026 @pezkuwi/typegen authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// docs.js exports only types, but registers the `docs` Handlebars partial
|
||||
// when loaded; the type-only re-export below does not load it.
|
||||
import './docs.js';
|
||||
|
||||
export * from './assert.js';
|
||||
export * from './derived.js';
|
||||
export * from './docs.js';
|
||||
export type * from './docs.js';
|
||||
export * from './file.js';
|
||||
export * from './formatting.js';
|
||||
export * from './imports.js';
|
||||
|
||||
Reference in new issue
Block a user