Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true

permissions:
id-token: write

jobs:
test-and-publish:
name: Test & Publish
Expand Down Expand Up @@ -74,4 +77,5 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
TAG: ${{ inputs.tag }}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"eslint-plugin-unicorn": "^57.0.0",
"globals": "^14.0.0",
"prettier": "^3.5.1",
"typescript": "^5.5.3"
"typescript": "^5.5.3",
"typescript-eslint": "^8.29.0"
},
"pnpm": {
"overrides": {
Expand Down
6 changes: 6 additions & 0 deletions packages/fetch/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 2
}
41 changes: 41 additions & 0 deletions packages/fetch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# NFDomains Fetch SDK

> [!CAUTION]
> This module is not intended to be used
> Please see the [@txnlab/nfd-sdk](https://www.npmjs.com/package/@txnlab/nfd-sdk)
> for more information

Fetch submodule for the NFD SDK

## Versioning

This module is for advanced integrators

Once we reach v1.0.0 with all planned features, breaking changes will only be introduced via major version bumps following semantic versioning.

## Installation

```bash
# npm
npm install @txnlab/nfd-fetch

# yarn
yarn add @txnlab/nfd-fetch

# pnpm
pnpm add @txnlab/nfd-fetch
```

## Quick Start

```typescript
import { client } from '@txnlab/nfd-fetch'
// TODO:
```

## Usage Examples (TODO)


## License

MIT License
30 changes: 30 additions & 0 deletions packages/fetch/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import tseslint from 'typescript-eslint'
import baseConfig from '../../eslint.config.js'

export default tseslint.config(
...baseConfig,
{
// Source files
files: ['src/**/*.ts'],
languageOptions: {
parserOptions: {
project: './tsconfig.lib.json',
},
},
plugins: {
'@typescript-eslint': tseslint.plugin,
},
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
},
},
{
// Config files and scripts
files: ['*.config.ts', 'scripts/**/*.ts'],
languageOptions: {
parserOptions: {
project: './tsconfig.test.json',
},
},
},
)
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { defineConfig } from '@hey-api/openapi-ts'

export default defineConfig({
input: './src/api/openapi3.yaml',
input: './src/openapi3.yaml',
output: {
format: 'prettier',
lint: 'eslint',
path: './src/api',
path: './src',
},
plugins: ['@hey-api/client-fetch'],
})
92 changes: 92 additions & 0 deletions packages/fetch/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"name": "@txnlab/nfd-fetch",
"version": "0.0.1",
"description": "Fetch library for NFDomains (NFD)",
"type": "module",
"main": "./lib/index.js",
"module": "./lib/index.js",
"types": "./lib/index.d.ts",
"exports": {
".": {
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
},
"./client": {
"types": "./lib/client.gen.d.ts",
"default": "./lib/client.gen.js"
},
"./sdk": {
"types": "./lib/sdk.gen.d.ts",
"default": "./lib/sdk.gen.js"
},
"./package.json": "./package.json"
},
"files": [
"lib",
"src",
"README.md"
],
"keywords": [
"algorand",
"nfd",
"nfdomains",
"blockchain",
"domains",
"fetch",
"rpc"
],
"author": "TxnLab Inc.",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/TxnLab/nfd-sdk.git",
"directory": "packages/fetch"
},
"bugs": {
"url": "https://github.com/TxnLab/nfd-sdk/issues"
},
"homepage": "https://github.com/TxnLab/nfd-sdk/packages/fetch#readme",
"publishConfig": {
"access": "public",
"provenance": true
},
"engines": {
"node": ">=22",
"pnpm": ">=9"
},
"scripts": {
"build": "vite build && tsc-alias -p tsconfig.lib.json && publint --strict",
"test": "vitest run",
"test:watch": "vitest",
"test:ui": "vitest --ui",
"test:coverage": "vitest run --coverage",
"lint": "eslint \"**/*.{js,jsx,ts,tsx}\"",
"format": "prettier --write .",
"typecheck": "tsc --noEmit",
"fetch:openapi": "tsx scripts/fetch-openapi.ts",
"generate": "openapi-ts"
},
"dependencies": {
"@hey-api/client-fetch": "^0.8.1",
"algosdk": "^3.2.0",
"crypto-js": "^4.2.0"
},
"devDependencies": {
"@hey-api/openapi-ts": "^0.64.5",
"@types/node": "^22.13.9",
"@types/node-fetch": "^2.6.12",
"@vitest/coverage-v8": "^3.0.7",
"@vitest/ui": "^3.0.7",
"dotenv": "^16.4.7",
"glob": "^11.0.1",
"publint": "^0.3.6",
"tsc-alias": "^1.8.13",
"tsx": "^4.19.3",
"type-fest": "^4.37.0",
"vite": "^6.2.0",
"vite-bundle-analyzer": "^0.18.1",
"vite-plugin-dts": "^4.5.0",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^3.0.7"
}
}
File renamed without changes.
4 changes: 4 additions & 0 deletions packages/fetch/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file is auto-generated by @hey-api/openapi-ts
export * from './client.gen.js'
export * from './types.gen.js'
export * from './sdk.gen.js'
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions packages/fetch/tests/client.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'

import { client } from '../src'

describe('@txnlab/nfd-fetch', () => {
it('should have a client instance', () => {
expect(client).toBeDefined()
})
})
7 changes: 7 additions & 0 deletions packages/fetch/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"include": ["./src/**/*.ts"],
"references": [
{"path": "./tsconfig.lib.json"},
{"path": "./tsconfig.test.json"}
]
}
20 changes: 20 additions & 0 deletions packages/fetch/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"include": ["src/**/*.ts"],
"exclude": [
"node_modules",
"lib"
],
"compilerOptions": {
"strict": true,
"ignoreDeprecations": "5.0",
"allowJs": true,
"skipLibCheck": true,
"isolatedModules": true,
"moduleResolution": "node",
"module": "esnext",
"target": "esnext",
"sourceMap": true,
"declaration": true,
"outDir": "./lib"
},
}
14 changes: 14 additions & 0 deletions packages/fetch/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"composite": true,
"paths": {
"@txnlab/nfd-fetch": ["./src/index.ts"]
}
},
"include": [
"tests/*",
"scripts/*",
"*.config.ts"
],
}
53 changes: 53 additions & 0 deletions packages/fetch/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { dirname, extname, relative, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

import { glob } from 'glob';
import { defineConfig } from 'vite'
import { analyzer } from 'vite-bundle-analyzer';
import dts from 'vite-plugin-dts'

const __dirname = dirname(fileURLToPath(import.meta.url));

export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, 'src/index.ts'),
formats: ['es'],
},
outDir: 'lib',
rollupOptions: {
external: [
'algosdk',
'@algorandfoundation/algokit-utils',
'@hey-api/client-fetch',
'crypto-js',
],
input: Object.fromEntries(
glob
.sync('src/**/*.ts')
.map((file) => {
return [
relative(
'src',
file.slice(0, file.length - extname(file).length),
),
fileURLToPath(new URL(file, import.meta.url)),
];
}),
),
output: {
compact: false,
preserveModules: true,
entryFileNames: '[name].js',
},
},
sourcemap: true,
minify: false,
copyPublicDir: false,
emptyOutDir: true,
},
plugins: [
process.env.ANALYZE ? analyzer() : undefined,
dts({ tsconfigPath: './tsconfig.lib.json' }),
],
})
28 changes: 28 additions & 0 deletions packages/fetch/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { resolve } from 'path'

import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
globals: true,
environment: 'node',
include: ['**/*.{test,spec}.{ts,tsx}'],
exclude: ['**/node_modules/**', '**/dist/**'],
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/*.config.*',
'**/scripts/**',
'**/tests/utils/**',
],
},
},
resolve: {
alias: {
'@': resolve(__dirname, './src'),
},
},
})
10 changes: 5 additions & 5 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/TxnLab/nfd-sdk.git"
"url": "git+https://github.com/TxnLab/nfd-sdk.git",
"directory": "packages/sdk"
},
"bugs": {
"url": "https://github.com/TxnLab/nfd-sdk/issues"
Expand All @@ -57,17 +58,16 @@
"lint": "eslint \"**/*.{js,jsx,ts,tsx}\"",
"format": "prettier --write .",
"typecheck": "tsc --noEmit",
"fetch:openapi": "tsx scripts/fetch-openapi.ts",
"fetch:arc56": "tsx scripts/fetch-arc56.ts",
"postfetch:arc56": "tsx scripts/clean-arc56.ts",
"fetch:specs": "pnpm fetch:openapi && pnpm fetch:arc56",
"fetch:specs": "pnpm fetch:arc56",
"generate:clients": "algokit generate client src/contracts/minimal/ --language typescript --output src/contracts/{contract_name}Client.ts",
"generate:openapi": "openapi-ts",
"generate": "pnpm fetch:specs && pnpm generate:clients && pnpm generate:openapi"
"generate": "pnpm fetch:specs && pnpm generate:clients"
},
"dependencies": {
"@algorandfoundation/algokit-utils": "^8.2.2",
"@hey-api/client-fetch": "^0.8.1",
"@txnlab/nfd-fetch": "workspace:*",
"algosdk": "^3.2.0",
"crypto-js": "^4.2.0"
},
Expand Down
3 changes: 1 addition & 2 deletions packages/sdk/src/api-client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { client } from './api/client.gen'
import { nfdGetLookup, nfdGetNfd, nfdSearchV2 } from './api/sdk.gen'
import { client, nfdGetLookup, nfdGetNfd, nfdSearchV2 } from '@txnlab/nfd-fetch'
import { NfdApiBaseUrl, NfdRegistryId } from './constants'
import { chunkArray } from './utils/internal/array'

Expand Down
3 changes: 0 additions & 3 deletions packages/sdk/src/api/index.ts

This file was deleted.

Loading