From f40cc382fd0d1a094d749dafecfb7d7b25761b41 Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:48:00 -0700 Subject: [PATCH 01/20] did-mailto tsconfig.json uses moduleResolution and module NodeNext to fix attw error --- packages/did-mailto/src/index.js | 14 +++++++------- packages/did-mailto/test/did-mailto.spec.js | 2 +- packages/did-mailto/tsconfig.json | 4 +++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/did-mailto/src/index.js b/packages/did-mailto/src/index.js index a09623243..3a77d2a4b 100644 --- a/packages/did-mailto/src/index.js +++ b/packages/did-mailto/src/index.js @@ -1,8 +1,8 @@ /** * create a did:mailto from an email address * - * @param {import("./types").EmailAddress} email - * @returns {import("./types").DidMailto} + * @param {import("./types.js").EmailAddress} email + * @returns {import("./types.js").DidMailto} */ export function fromEmail(email) { const { domain, local } = parseEmail(email) @@ -13,8 +13,8 @@ export function fromEmail(email) { } /** - * @param {import("./types").DidMailto} did - * @returns {import("./types").EmailAddress} + * @param {import("./types.js").DidMailto} did + * @returns {import("./types.js").EmailAddress} */ export function toEmail(did) { const parts = did.split(':') @@ -30,11 +30,11 @@ export function toEmail(did) { * This is not meant to be a general RFC5322 (et al) email address validator, which would be more expensive. * * @param {string} input - * @returns {import("./types").EmailAddress} + * @returns {import("./types.js").EmailAddress} */ export function email(input) { const { domain, local } = parseEmail(input) - /** @type {import("./types").EmailAddress} */ + /** @type {import("./types.js").EmailAddress} */ const emailAddress = `${local}@${domain}` return emailAddress } @@ -43,7 +43,7 @@ export function email(input) { * parse a did mailto from a string * * @param {string} input - * @returns {import("./types").DidMailto} + * @returns {import("./types.js").DidMailto} */ export function fromString(input) { const colonParts = input.split(':') diff --git a/packages/did-mailto/test/did-mailto.spec.js b/packages/did-mailto/test/did-mailto.spec.js index b21747803..6a1cc6fc5 100644 --- a/packages/did-mailto/test/did-mailto.spec.js +++ b/packages/did-mailto/test/did-mailto.spec.js @@ -7,7 +7,7 @@ describe('did-mailto', () => { /** * @param {typeof didMailto} didMailto - * @param {import("./test-types").TestAdder} test + * @param {import("./test-types.js").TestAdder} test */ function testDidMailto(didMailto, test) { test('module is an object', async () => { diff --git a/packages/did-mailto/tsconfig.json b/packages/did-mailto/tsconfig.json index ab5d5d625..5d3671bd9 100644 --- a/packages/did-mailto/tsconfig.json +++ b/packages/did-mailto/tsconfig.json @@ -1,7 +1,9 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "outDir": "dist" + "outDir": "dist", + "moduleResolution": "NodeNext", + "module": "NodeNext" }, "include": ["src", "test"], "exclude": ["**/node_modules/**", "dist"], From f7acf635708c31ae72801cf37cf97359f4dbae99 Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:59:04 -0700 Subject: [PATCH 02/20] capabilities package builds with module/moduleResolution NodeNext to make attw check pass --- packages/capabilities/src/filecoin.js | 14 +++++++------- packages/capabilities/tsconfig.json | 4 +++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/capabilities/src/filecoin.js b/packages/capabilities/src/filecoin.js index 4945ea8fa..7306ccc20 100644 --- a/packages/capabilities/src/filecoin.js +++ b/packages/capabilities/src/filecoin.js @@ -47,7 +47,7 @@ export const filecoinQueue = capability({ /** * CID of the piece. */ - piece: /** @type {import('./types').PieceLinkSchema} */ (PIECE_LINK), + piece: /** @type {import('./types.js').PieceLinkSchema} */ (PIECE_LINK), }), derives: (claim, from) => { return ( @@ -79,7 +79,7 @@ export const filecoinAdd = capability({ * * @see https://github.com/filecoin-project/FIPs/pull/758/files */ - piece: /** @type {import('./types').PieceLinkSchema} */ (PIECE_LINK), + piece: /** @type {import('./types.js').PieceLinkSchema} */ (PIECE_LINK), }), derives: (claim, from) => { return ( @@ -105,7 +105,7 @@ export const aggregateQueue = capability({ /** * CID of the piece. */ - piece: /** @type {import('./types').PieceLinkSchema} */ (PIECE_LINK), + piece: /** @type {import('./types.js').PieceLinkSchema} */ (PIECE_LINK), /** * Grouping for the piece to be aggregated */ @@ -137,7 +137,7 @@ export const aggregateAdd = capability({ * * @see https://github.com/filecoin-project/FIPs/pull/758/files */ - piece: /** @type {import('./types').PieceLinkSchema} */ (PIECE_LINK), + piece: /** @type {import('./types.js').PieceLinkSchema} */ (PIECE_LINK), /** * Storefront requesting piece to be aggregated */ @@ -178,7 +178,7 @@ export const dealQueue = capability({ * Commitment proof for the aggregate being offered. * https://github.com/filecoin-project/go-state-types/blob/1e6cf0d47cdda75383ef036fc2725d1cf51dbde8/abi/piece.go#L47-L50 */ - aggregate: /** @type {import('./types').PieceLinkSchema} */ (PIECE_LINK), + aggregate: /** @type {import('./types.js').PieceLinkSchema} */ (PIECE_LINK), /** * Storefront requesting deal */ @@ -222,7 +222,7 @@ export const dealAdd = capability({ * @see https://github.com/filecoin-project/go-state-types/blob/1e6cf0d47cdda75383ef036fc2725d1cf51dbde8/abi/piece.go#L47-L50 * @see https://github.com/filecoin-project/FIPs/pull/758/files */ - aggregate: /** @type {import('./types').PieceLinkSchema} */ (PIECE_LINK), + aggregate: /** @type {import('./types.js').PieceLinkSchema} */ (PIECE_LINK), /** * Storefront requesting deal */ @@ -259,7 +259,7 @@ export const chainTrackerInfo = capability({ * * @see https://github.com/filecoin-project/FIPs/pull/758/files */ - piece: /** @type {import('./types').PieceLinkSchema} */ (PIECE_LINK), + piece: /** @type {import('./types.js').PieceLinkSchema} */ (PIECE_LINK), }), derives: (claim, from) => { return ( diff --git a/packages/capabilities/tsconfig.json b/packages/capabilities/tsconfig.json index 565f5779d..41f9d7b5e 100644 --- a/packages/capabilities/tsconfig.json +++ b/packages/capabilities/tsconfig.json @@ -2,7 +2,9 @@ "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "dist", - "emitDeclarationOnly": true + "emitDeclarationOnly": true, + "module": "NodeNext", + "moduleResolution": "NodeNext" }, "include": ["src", "test", "package.json"], "exclude": ["**/node_modules/**"] From 7a95162f3a00b936451d8419bcf8dd34375b0a83 Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 11:24:05 -0700 Subject: [PATCH 03/20] packages/access-client uses tsconfig module/moduleResolution of NodeNext to fix attw errors --- packages/access-client/package.json | 16 +-- packages/access-client/src/agent-data.js | 26 ++-- packages/access-client/src/agent.js | 30 ++--- packages/access-client/src/crypto/aes-key.js | 2 +- .../access-client/src/crypto/p256-ecdh.js | 2 +- packages/access-client/src/drivers/conf.js | 2 +- .../access-client/src/drivers/indexeddb.js | 2 +- packages/access-client/src/drivers/memory.js | 2 +- packages/access-client/src/encoding.js | 6 +- .../access-client/src/stores/store-conf.js | 2 +- .../src/stores/store-indexeddb.js | 2 +- .../access-client/src/stores/store-memory.js | 2 +- packages/access-client/tsconfig.json | 3 +- pnpm-lock.yaml | 117 ++++++++++++------ 14 files changed, 126 insertions(+), 88 deletions(-) diff --git a/packages/access-client/package.json b/packages/access-client/package.json index 450cd2e04..d7148d87e 100644 --- a/packages/access-client/package.json +++ b/packages/access-client/package.json @@ -24,12 +24,12 @@ "rc": "npm version prerelease --preid rc" }, "exports": { - ".": "./src/index.js", - "./agent": "./src/agent.js", - "./drivers/*": "./src/drivers/*.js", - "./stores/*": "./src/stores/*.js", - "./types": "./src/types.js", - "./encoding": "./src/encoding.js" + ".": "./dist/src/index.js", + "./agent": "./dist/src/agent.js", + "./drivers/*": "./dist/src/drivers/*.js", + "./stores/*": "./dist/src/stores/*.js", + "./types": "./dist/src/types.js", + "./encoding": "./dist/src/encoding.js" }, "typesVersions": { "*": { @@ -67,9 +67,9 @@ "@web3-storage/capabilities": "workspace:^", "@web3-storage/did-mailto": "workspace:^", "bigint-mod-arith": "^3.1.2", - "conf": "10.2.0", + "conf": "11.0.2", "multiformats": "^12.1.2", - "one-webcrypto": "^1.0.3", + "one-webcrypto": "git://github.com/web3-storage/one-webcrypto", "p-defer": "^4.0.0", "type-fest": "^3.3.0", "uint8arrays": "^4.0.6" diff --git a/packages/access-client/src/agent-data.js b/packages/access-client/src/agent-data.js index 23a726792..f2d5a8783 100644 --- a/packages/access-client/src/agent-data.js +++ b/packages/access-client/src/agent-data.js @@ -6,16 +6,16 @@ import { CID } from 'multiformats' import { Access } from '@web3-storage/capabilities' import { isExpired } from './delegations.js' -/** @typedef {import('./types').AgentDataModel} AgentDataModel */ +/** @typedef {import('./types.js').AgentDataModel} AgentDataModel */ /** @implements {AgentDataModel} */ export class AgentData { - /** @type {(data: import('./types').AgentDataExport) => Promise | void} */ + /** @type {(data: import('./types.js').AgentDataExport) => Promise | void} */ #save /** - * @param {import('./types').AgentDataModel} data - * @param {import('./types').AgentDataOptions} [options] + * @param {import('./types.js').AgentDataModel} data + * @param {import('./types.js').AgentDataOptions} [options] */ constructor(data, options = {}) { this.meta = data.meta @@ -30,8 +30,8 @@ export class AgentData { /** * Create a new AgentData instance from the passed initialization data. * - * @param {Partial} [init] - * @param {import('./types').AgentDataOptions} [options] + * @param {Partial} [init] + * @param {import('./types.js').AgentDataOptions} [options] */ static async create(init = {}, options = {}) { const agentData = new AgentData( @@ -53,11 +53,11 @@ export class AgentData { /** * Instantiate AgentData from previously exported data. * - * @param {import('./types').AgentDataExport} raw - * @param {import('./types').AgentDataOptions} [options] + * @param {import('./types.js').AgentDataExport} raw + * @param {import('./types.js').AgentDataOptions} [options] */ static fromExport(raw, options) { - /** @type {import('./types').AgentDataModel['delegations']} */ + /** @type {import('./types.js').AgentDataModel['delegations']} */ const dels = new Map() for (const [key, value] of raw.delegations) { @@ -89,7 +89,7 @@ export class AgentData { * Export data in a format safe to pass to `structuredClone()`. */ export() { - /** @type {import('./types').AgentDataExport} */ + /** @type {import('./types.js').AgentDataExport} */ const raw = { meta: this.meta, principal: this.principal.toArchive(), @@ -112,7 +112,7 @@ export class AgentData { /** * @deprecated * @param {import('@ucanto/interface').DID} did - * @param {import('./types').SpaceMeta} meta + * @param {import('./types.js').SpaceMeta} meta * @param {import('@ucanto/interface').Delegation} [proof] */ async addSpace(did, meta, proof) { @@ -131,7 +131,7 @@ export class AgentData { /** * @param {import('@ucanto/interface').Delegation} delegation - * @param {import('./types').DelegationMeta} [meta] + * @param {import('./types.js').DelegationMeta} [meta] */ async addDelegation(delegation, meta) { this.delegations.set(delegation.cid.toString(), { @@ -162,7 +162,7 @@ const isSessionCapability = (cap) => cap.can === Access.session.can * Is the given delegation a session proof? * * @param {Ucanto.Delegation} delegation - * @returns {delegation is Ucanto.Delegation<[import('./types').AccessSession]>} + * @returns {delegation is Ucanto.Delegation<[import('./types.js').AccessSession]>} */ export const isSessionProof = (delegation) => delegation.capabilities.some((cap) => isSessionCapability(cap)) diff --git a/packages/access-client/src/agent.js b/packages/access-client/src/agent.js index 3968e1314..78f8da02b 100644 --- a/packages/access-client/src/agent.js +++ b/packages/access-client/src/agent.js @@ -39,7 +39,7 @@ const PRINCIPAL = DID.parse('did:web:web3.storage') const agentToData = new WeakMap() /** - * @typedef {import('./types').Service} Service + * @typedef {import('./types.js').Service} Service * @typedef {import('@ucanto/interface').Receipt} Receipt */ @@ -87,12 +87,12 @@ export function connection(options = {}) { * @template {Record} [S=Service] */ export class Agent { - /** @type {import('./agent-data').AgentData} */ + /** @type {import('./agent-data.js').AgentData} */ #data /** - * @param {import('./agent-data').AgentData} data - Agent data - * @param {import('./types').AgentOptions} [options] + * @param {import('./agent-data.js').AgentData} data - Agent data + * @param {import('./types.js').AgentOptions} [options] */ constructor(data, options = {}) { /** @type { Client.Channel & { url?: URL } | undefined } */ @@ -112,8 +112,8 @@ export class Agent { * Create a new Agent instance, optionally with the passed initialization data. * * @template {Record} [R=Service] - * @param {Partial} [init] - * @param {import('./types').AgentOptions & import('./types').AgentDataOptions} [options] + * @param {Partial} [init] + * @param {import('./types.js').AgentOptions & import('./types.js').AgentDataOptions} [options] */ static async create(init, options = {}) { const data = await AgentData.create(init, options) @@ -124,8 +124,8 @@ export class Agent { * Instantiate an Agent from pre-exported agent data. * * @template {Record} [R=Service] - * @param {import('./types').AgentDataExport} raw - * @param {import('./types').AgentOptions & import('./types').AgentDataOptions} [options] + * @param {import('./types.js').AgentDataExport} raw + * @param {import('./types.js').AgentOptions & import('./types.js').AgentDataOptions} [options] */ static from(raw, options = {}) { const data = AgentData.fromExport(raw, options) @@ -171,7 +171,7 @@ export class Agent { */ #delegations(caps) { const _caps = new Set(caps) - /** @type {Array<{ delegation: Ucanto.Delegation, meta: import('./types').DelegationMeta }>} */ + /** @type {Array<{ delegation: Ucanto.Delegation, meta: import('./types.js').DelegationMeta }>} */ const values = [] for (const [, value] of this.#data.delegations) { // check expiration @@ -320,7 +320,7 @@ export class Agent { expiration: Infinity, }) - /** @type {import('./types').SpaceMeta} */ + /** @type {import('./types.js').SpaceMeta} */ const meta = { isRegistered: false } // eslint-disable-next-line eqeqeq if (name != undefined) { @@ -345,7 +345,7 @@ export class Agent { * @param {Ucanto.Delegation} delegation */ async importSpaceFromDelegation(delegation) { - const meta = /** @type {import('./types').SpaceMeta} */ ( + const meta = /** @type {import('./types.js').SpaceMeta} */ ( delegation.facts[0]?.space ?? { isRegistered: false } ) // @ts-ignore @@ -434,7 +434,7 @@ export class Agent { /** * - * @param {import('./types').DelegationOptions} options + * @param {import('./types.js').DelegationOptions} options */ async delegate(options) { const space = this.currentSpaceWithMeta() @@ -501,7 +501,7 @@ export class Agent { * @template {Ucanto.URI} R * @template {Ucanto.Caveats} C * @param {Ucanto.TheCapabilityParser>} cap - * @param {import('./types').InvokeOptions>>} options + * @param {import('./types.js').InvokeOptions>>} options * @returns {Promise, S>>} */ async invokeAndExecute(cap, options) { @@ -554,7 +554,7 @@ export class Agent { * @template {Ucanto.TheCapabilityParser>} CAP * @template {Ucanto.Caveats} [C={}] * @param {CAP} cap - * @param {import('./types').InvokeOptions} options + * @param {import('./types.js').InvokeOptions} options */ async invoke(cap, options) { const space = options.with || this.currentSpace() @@ -614,7 +614,7 @@ export class Agent { throw inv.out.error } - return /** @type {import('./types').SpaceInfoResult} */ (inv.out.ok) + return /** @type {import('./types.js').SpaceInfoResult} */ (inv.out.ok) } } diff --git a/packages/access-client/src/crypto/aes-key.js b/packages/access-client/src/crypto/aes-key.js index 4d7252bfa..d68310664 100644 --- a/packages/access-client/src/crypto/aes-key.js +++ b/packages/access-client/src/crypto/aes-key.js @@ -3,7 +3,7 @@ import * as uint8arrays from 'uint8arrays' import { randomIV } from './encoding.js' /** - * @typedef {import('./types').EncryptionKeypair} EncryptionKeypair + * @typedef {import('./types.js').EncryptionKeypair} EncryptionKeypair * @implements {EncryptionKeypair} */ export class AesKey { diff --git a/packages/access-client/src/crypto/p256-ecdh.js b/packages/access-client/src/crypto/p256-ecdh.js index f4f826c82..52edc0ff6 100644 --- a/packages/access-client/src/crypto/p256-ecdh.js +++ b/packages/access-client/src/crypto/p256-ecdh.js @@ -48,7 +48,7 @@ export async function pubkeyBytesFromDID(did) { } /** - * @typedef {import('./types').KeyExchangeKeypair} SharedKey + * @typedef {import('./types.js').KeyExchangeKeypair} SharedKey * @implements {SharedKey} */ export class EcdhKeypair { diff --git a/packages/access-client/src/drivers/conf.js b/packages/access-client/src/drivers/conf.js index 2921d6bdd..ddf27bc10 100644 --- a/packages/access-client/src/drivers/conf.js +++ b/packages/access-client/src/drivers/conf.js @@ -3,7 +3,7 @@ import * as JSON from '../utils/json.js' /** * @template T - * @typedef {import('./types').Driver} Driver + * @typedef {import('./types.js').Driver} Driver */ /** diff --git a/packages/access-client/src/drivers/indexeddb.js b/packages/access-client/src/drivers/indexeddb.js index 58b41d7c8..2a77a0d8d 100644 --- a/packages/access-client/src/drivers/indexeddb.js +++ b/packages/access-client/src/drivers/indexeddb.js @@ -2,7 +2,7 @@ import defer from 'p-defer' /** * @template T - * @typedef {import('./types').Driver} Driver + * @typedef {import('./types.js').Driver} Driver */ const STORE_NAME = 'AccessStore' diff --git a/packages/access-client/src/drivers/memory.js b/packages/access-client/src/drivers/memory.js index 19e9d7657..9b89f185c 100644 --- a/packages/access-client/src/drivers/memory.js +++ b/packages/access-client/src/drivers/memory.js @@ -1,6 +1,6 @@ /** * @template T - * @typedef {import('./types').Driver} Driver + * @typedef {import('./types.js').Driver} Driver */ /** diff --git a/packages/access-client/src/encoding.js b/packages/access-client/src/encoding.js index 1b7586a91..8acc8cc0f 100644 --- a/packages/access-client/src/encoding.js +++ b/packages/access-client/src/encoding.js @@ -66,7 +66,7 @@ export function delegationsToBytes(delegations) { * Decode bytes into Delegations * * @template {Types.Capabilities} [T=Types.Capabilities] - * @param {import('./types').BytesDelegation} bytes + * @param {import('./types.js').BytesDelegation} bytes */ export function bytesToDelegations(bytes) { if (!(bytes instanceof Uint8Array) || bytes.length === 0) { @@ -122,7 +122,7 @@ export function delegationToString(delegation, encoding) { * Decode string into {@link Types.Delegation Delegation} * * @template {Types.Capabilities} [T=Types.Capabilities] - * @param {import('./types').EncodedDelegation} raw + * @param {import('./types.js').EncodedDelegation} raw * @param {import('uint8arrays/to-string').SupportedEncodings} [encoding] */ export function stringToDelegations(raw, encoding = 'base64url') { @@ -135,7 +135,7 @@ export function stringToDelegations(raw, encoding = 'base64url') { * Decode string into a {@link Types.Delegation Delegation} * * @template {Types.Capabilities} [T=Types.Capabilities] - * @param {import('./types').EncodedDelegation} raw + * @param {import('./types.js').EncodedDelegation} raw * @param {import('uint8arrays/to-string').SupportedEncodings} [encoding] */ export function stringToDelegation(raw, encoding) { diff --git a/packages/access-client/src/stores/store-conf.js b/packages/access-client/src/stores/store-conf.js index 5244b06aa..b0d91b218 100644 --- a/packages/access-client/src/stores/store-conf.js +++ b/packages/access-client/src/stores/store-conf.js @@ -9,6 +9,6 @@ import { ConfDriver } from '../drivers/conf.js' * import { StoreConf } from '@web3-storage/access/stores/store-conf' * ``` * - * @extends {ConfDriver} + * @extends {ConfDriver} */ export class StoreConf extends ConfDriver {} diff --git a/packages/access-client/src/stores/store-indexeddb.js b/packages/access-client/src/stores/store-indexeddb.js index 362fa8165..68071efc1 100644 --- a/packages/access-client/src/stores/store-indexeddb.js +++ b/packages/access-client/src/stores/store-indexeddb.js @@ -9,6 +9,6 @@ import { IndexedDBDriver } from '../drivers/indexeddb.js' * import { StoreIndexedDB } from '@web3-storage/access/stores/store-indexeddb' * ``` * - * @extends {IndexedDBDriver} + * @extends {IndexedDBDriver} */ export class StoreIndexedDB extends IndexedDBDriver {} diff --git a/packages/access-client/src/stores/store-memory.js b/packages/access-client/src/stores/store-memory.js index cff7a5579..e9b40df55 100644 --- a/packages/access-client/src/stores/store-memory.js +++ b/packages/access-client/src/stores/store-memory.js @@ -9,6 +9,6 @@ import { MemoryDriver } from '../drivers/memory.js' * import { StoreMemory } from '@web3-storage/access/stores/store-memory' * ``` * - * @extends {MemoryDriver} + * @extends {MemoryDriver} */ export class StoreMemory extends MemoryDriver {} diff --git a/packages/access-client/tsconfig.json b/packages/access-client/tsconfig.json index e3b39cb5c..b94f18019 100644 --- a/packages/access-client/tsconfig.json +++ b/packages/access-client/tsconfig.json @@ -3,7 +3,8 @@ "compilerOptions": { "outDir": "dist", "lib": ["ESNext", "DOM"], - "emitDeclarationOnly": true + "module": "NodeNext", + "moduleResolution": "NodeNext" }, "include": ["src", "scripts", "test", "package.json"], "exclude": ["**/node_modules/**"], diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 12a91392e..081f62d05 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.0' +lockfileVersion: '6.1' settings: autoInstallPeers: true @@ -73,14 +73,14 @@ importers: specifier: ^3.1.2 version: 3.3.1 conf: - specifier: 10.2.0 - version: 10.2.0 + specifier: 11.0.2 + version: 11.0.2 multiformats: specifier: ^12.1.2 version: 12.1.2 one-webcrypto: - specifier: ^1.0.3 - version: 1.0.3 + specifier: git://github.com/web3-storage/one-webcrypto + version: github.com/web3-storage/one-webcrypto/5148cd14d5489a8ac4cd38223870e02db15a2382 p-defer: specifier: ^4.0.0 version: 4.0.0 @@ -3278,7 +3278,7 @@ packages: '@typescript-eslint/parser': 5.62.0(eslint@8.50.0)(typescript@5.2.2) '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/type-utils': 5.62.0(eslint@8.50.0)(typescript@5.2.2) - '@typescript-eslint/utils': 5.62.0(eslint@8.50.0)(typescript@4.9.5) + '@typescript-eslint/utils': 5.62.0(eslint@8.50.0)(typescript@5.2.2) debug: 4.3.4(supports-color@8.1.1) eslint: 8.50.0 graphemer: 1.4.0 @@ -3411,7 +3411,7 @@ packages: optional: true dependencies: '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.2.2) - '@typescript-eslint/utils': 5.62.0(eslint@8.50.0)(typescript@4.9.5) + '@typescript-eslint/utils': 5.62.0(eslint@8.50.0)(typescript@5.2.2) debug: 4.3.4(supports-color@8.1.1) eslint: 8.50.0 tsutils: 3.21.0(typescript@5.2.2) @@ -3486,6 +3486,26 @@ packages: - typescript dev: true + /@typescript-eslint/utils@5.62.0(eslint@8.50.0)(typescript@5.2.2): + resolution: {integrity: sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + dependencies: + '@eslint-community/eslint-utils': 4.4.0(eslint@8.50.0) + '@types/json-schema': 7.0.13 + '@types/semver': 7.5.3 + '@typescript-eslint/scope-manager': 5.62.0 + '@typescript-eslint/types': 5.62.0 + '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.2.2) + eslint: 8.50.0 + eslint-scope: 5.1.1 + semver: 7.5.4 + transitivePeerDependencies: + - supports-color + - typescript + dev: true + /@typescript-eslint/utils@5.62.0(eslint@8.51.0)(typescript@5.2.2): resolution: {integrity: sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -4080,9 +4100,11 @@ packages: engines: {node: '>= 4.0.0'} dev: true - /atomically@1.7.0: - resolution: {integrity: sha512-Xcz9l0z7y9yQ9rdDaxlmaI4uJHf/T8g9hOEzJcsEqX2SjCj4J20uK7+ldkDHMbpJDK76wF7xEIgxc/vSlsfw5w==} - engines: {node: '>=10.12.0'} + /atomically@2.0.2: + resolution: {integrity: sha512-Xfmb4q5QV7uqTlVdMSTtO5eF4DCHfNOdaPyKlbFShkzeNP+3lj3yjjcbdjSmEY4+pDBKJ9g26aP+ImTe88UHoQ==} + dependencies: + stubborn-fs: 1.2.5 + when-exit: 2.1.1 dev: false /autoprefixer@10.4.16(postcss@8.4.31): @@ -4727,19 +4749,17 @@ packages: /concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} - /conf@10.2.0: - resolution: {integrity: sha512-8fLl9F04EJqjSqH+QjITQfJF8BrOVaYr1jewVgSRAEWePfxT0sku4w2hrGQ60BC/TNLGQ2pgxNlTbWQmMPFvXg==} - engines: {node: '>=12'} + /conf@11.0.2: + resolution: {integrity: sha512-jjyhlQ0ew/iwmtwsS2RaB6s8DBifcE2GYBEaw2SJDUY/slJJbNfY4GlDVzOs/ff8cM/Wua5CikqXgbFl5eu85A==} + engines: {node: '>=14.16'} dependencies: ajv: 8.12.0 ajv-formats: 2.1.1(ajv@8.12.0) - atomically: 1.7.0 - debounce-fn: 4.0.0 - dot-prop: 6.0.1 - env-paths: 2.2.1 - json-schema-typed: 7.0.3 - onetime: 5.1.2 - pkg-up: 3.1.0 + atomically: 2.0.2 + debounce-fn: 5.1.2 + dot-prop: 7.2.0 + env-paths: 3.0.0 + json-schema-typed: 8.0.1 semver: 7.5.4 dev: false @@ -5100,11 +5120,11 @@ packages: resolution: {integrity: sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==} dev: true - /debounce-fn@4.0.0: - resolution: {integrity: sha512-8pYCQiL9Xdcg0UPSD3d+0KMlOjp+KGU5EPwYddgzQ7DATsg4fuUDjQtsYLmWjnk2obnNHgV3vE2Y4jejSOJVBQ==} - engines: {node: '>=10'} + /debounce-fn@5.1.2: + resolution: {integrity: sha512-Sr4SdOZ4vw6eQDvPYNxHogvrxmCIld/VenC5JbNrFwMiwd7lY/Z18ZFfo+EWNG4DD9nFlAujWAo/wGuOPHmy5A==} + engines: {node: '>=12'} dependencies: - mimic-fn: 3.1.0 + mimic-fn: 4.0.0 dev: false /debug@2.6.9: @@ -5411,11 +5431,11 @@ packages: is-obj: 2.0.0 dev: true - /dot-prop@6.0.1: - resolution: {integrity: sha512-tE7ztYzXHIeyvc7N+hR3oi7FIbf/NIjVP9hmAt3yMXzrQ072/fpjGLx2GxNxGxUl5V73MEqYzioOMoVhGMJ5cA==} - engines: {node: '>=10'} + /dot-prop@7.2.0: + resolution: {integrity: sha512-Ol/IPXUARn9CSbkrdV4VJo7uCy1I3VuSiWCaFSg+8BdUOzF9n3jefIpcgAydvUZbTdEBZs2vEiTiS9m61ssiDA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} dependencies: - is-obj: 2.0.0 + type-fest: 2.19.0 dev: false /duplexer3@0.1.5: @@ -5499,9 +5519,9 @@ packages: engines: {node: '>=0.12'} dev: true - /env-paths@2.2.1: - resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==} - engines: {node: '>=6'} + /env-paths@3.0.0: + resolution: {integrity: sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} dev: false /err-code@3.0.1: @@ -6592,6 +6612,7 @@ packages: engines: {node: '>=6'} dependencies: locate-path: 3.0.0 + dev: true /find-up@4.1.0: resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} @@ -7771,6 +7792,7 @@ packages: /is-obj@2.0.0: resolution: {integrity: sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==} engines: {node: '>=8'} + dev: true /is-path-cwd@2.2.0: resolution: {integrity: sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==} @@ -8175,8 +8197,8 @@ packages: /json-schema-traverse@1.0.0: resolution: {integrity: sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==} - /json-schema-typed@7.0.3: - resolution: {integrity: sha512-7DE8mpG+/fVw+dTpjbxnx47TaMnDfOI1jwft9g1VybltZCduyRQPJPvc+zzKY9WPHxhPWczyFuYa6I8Mw4iU5A==} + /json-schema-typed@8.0.1: + resolution: {integrity: sha512-XQmWYj2Sm4kn4WeTYvmpKEbyPsL7nBsb647c7pMe6l02/yx2+Jfc4dT6UZkEXnIUb5LhD55r2HPsJ1milQ4rDg==} dev: false /json-stable-stringify-without-jsonify@1.0.1: @@ -8370,6 +8392,7 @@ packages: dependencies: p-locate: 3.0.0 path-exists: 3.0.0 + dev: true /locate-path@5.0.0: resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} @@ -8655,16 +8678,11 @@ packages: /mimic-fn@2.1.0: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} engines: {node: '>=6'} - - /mimic-fn@3.1.0: - resolution: {integrity: sha512-Ysbi9uYW9hFyfrThdDEQuykN4Ey6BuwPD2kpI5ES/nFTDn/98yxYNLZJcgUAKPT/mcrLLKaGzJR9YVxJrIdASQ==} - engines: {node: '>=8'} - dev: false + dev: true /mimic-fn@4.0.0: resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} engines: {node: '>=12'} - dev: true /mimic-response@1.0.1: resolution: {integrity: sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==} @@ -9063,6 +9081,7 @@ packages: engines: {node: '>=6'} dependencies: mimic-fn: 2.1.0 + dev: true /onetime@6.0.0: resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} @@ -9152,6 +9171,7 @@ packages: engines: {node: '>=6'} dependencies: p-try: 2.2.0 + dev: true /p-limit@3.1.0: resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} @@ -9165,6 +9185,7 @@ packages: engines: {node: '>=6'} dependencies: p-limit: 2.3.0 + dev: true /p-locate@4.1.0: resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==} @@ -9236,6 +9257,7 @@ packages: /p-try@2.2.0: resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} engines: {node: '>=6'} + dev: true /p-wait-for@5.0.2: resolution: {integrity: sha512-lwx6u1CotQYPVju77R+D0vFomni/AqRfqLmqQ8hekklqZ6gAY9rONh7lBQ0uxWMkC2AuX9b2DVAl8To0NyP1JA==} @@ -9327,6 +9349,7 @@ packages: /path-exists@3.0.0: resolution: {integrity: sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==} engines: {node: '>=4'} + dev: true /path-exists@4.0.0: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} @@ -9434,6 +9457,7 @@ packages: engines: {node: '>=8'} dependencies: find-up: 3.0.0 + dev: true /playwright-core@1.38.1: resolution: {integrity: sha512-tQqNFUKa3OfMf4b2jQ7aGLB8o9bS3bOY0yMEtldtC2+spf8QXG9zvXLTXUeRsoNuxEYMgLYR+NXfAa1rjKRcrg==} @@ -11221,6 +11245,10 @@ packages: engines: {node: '>=8'} dev: true + /stubborn-fs@1.2.5: + resolution: {integrity: sha512-H2N9c26eXjzL/S/K+i/RHHcFanE74dptvvjM8iwzwbVcWY/zjBbgRqF3K0DY4+OD+uTTASTBvDoxPDaPN02D7g==} + dev: false + /style-to-object@0.3.0: resolution: {integrity: sha512-CzFnRRXhzWIdItT3OmF8SQfWyahHhjq3HwcMNCNLn+N7klOOqPjMeG/4JSu77D7ypZdGvSzvkrbyeTMizz2VrA==} dependencies: @@ -11508,7 +11536,6 @@ packages: /type-fest@2.19.0: resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==} engines: {node: '>=12.20'} - dev: true /type-fest@3.13.1: resolution: {integrity: sha512-tLq3bSNx+xSpwvAJnzrK0Ep5CLNWjvFTOp71URMaAEWBfRb9nnJiBoUe0tF8bI4ZFO3omgBR6NvnbzVUT3Ly4g==} @@ -12172,6 +12199,10 @@ packages: webidl-conversions: 3.0.1 dev: false + /when-exit@2.1.1: + resolution: {integrity: sha512-XLipGldz/UcleuGaoQjbYuWwD+ICRnzIjlldtwTaTWr7aZz8yQW49rXk6MHQnh+KxOiWiJpM1vIyaxprOnlW4g==} + dev: false + /which-boxed-primitive@1.0.2: resolution: {integrity: sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==} dependencies: @@ -12403,3 +12434,9 @@ packages: /zwitch@1.0.5: resolution: {integrity: sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==} dev: true + + github.com/web3-storage/one-webcrypto/5148cd14d5489a8ac4cd38223870e02db15a2382: + resolution: {tarball: https://codeload.github.com/web3-storage/one-webcrypto/tar.gz/5148cd14d5489a8ac4cd38223870e02db15a2382} + name: one-webcrypto + version: 1.0.3 + dev: false From 7d44289471f9801ace5f0576ed6a2b9ea91f9193 Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 11:53:13 -0700 Subject: [PATCH 04/20] upload-api package is tsc with module/moduleResolution of NodeNext to make attw happy --- packages/did-mailto/package.json | 3 ++- packages/upload-api/package.json | 7 ------- packages/upload-api/src/access/authorize.js | 2 +- packages/upload-api/src/consumer/has.js | 1 + packages/upload-api/src/provider-add.js | 2 +- packages/upload-api/src/types.ts | 16 ++++++++-------- packages/upload-api/src/types/provisions.ts | 6 +++--- packages/upload-api/src/upload/add.js | 2 +- .../upload-api/src/utils/delegations-response.js | 2 +- packages/upload-api/src/utils/did-mailto.js | 4 ++-- packages/upload-api/src/utils/email.js | 2 +- packages/upload-api/src/utils/rate-limits.js | 2 +- packages/upload-api/src/validate.js | 2 +- packages/upload-api/test/access-client-agent.js | 2 +- packages/upload-api/tsconfig.json | 4 +++- 15 files changed, 27 insertions(+), 30 deletions(-) diff --git a/packages/did-mailto/package.json b/packages/did-mailto/package.json index e611bd614..8093f0b87 100644 --- a/packages/did-mailto/package.json +++ b/packages/did-mailto/package.json @@ -21,7 +21,8 @@ ".": { "types": "./dist/src/index.d.ts", "import": "./src/index.js" - } + }, + "./types": "./dist/src/types.js" }, "scripts": { "build": "tsc --build", diff --git a/packages/upload-api/package.json b/packages/upload-api/package.json index fb094c222..6a0198b7b 100644 --- a/packages/upload-api/package.json +++ b/packages/upload-api/package.json @@ -14,9 +14,6 @@ "src/lib.js": [ "dist/src/lib.d.ts" ], - "access": [ - "dist/src/access.d.ts" - ], "console": [ "dist/src/console.d.ts" ], @@ -58,10 +55,6 @@ "types": "./dist/src/types.d.ts", "import": "./src/types.js" }, - "./access": { - "types": "./dist/src/access.d.ts", - "import": "./src/access.js" - }, "./console": { "types": "./dist/src/console.d.ts", "import": "./src/console.js" diff --git a/packages/upload-api/src/access/authorize.js b/packages/upload-api/src/access/authorize.js index 2bb08a4c2..09a2566b8 100644 --- a/packages/upload-api/src/access/authorize.js +++ b/packages/upload-api/src/access/authorize.js @@ -18,7 +18,7 @@ export const provide = (ctx) => */ export const authorize = async ({ capability }, ctx) => { const accountMailtoDID = - /** @type {import('@web3-storage/did-mailto/dist/src/types').DidMailto} */ ( + /** @type {import('@web3-storage/did-mailto/types').DidMailto} */ ( capability.nb.iss ) const rateLimitResult = await ensureRateLimitAbove( diff --git a/packages/upload-api/src/consumer/has.js b/packages/upload-api/src/consumer/has.js index 24718beae..ad1d85f3b 100644 --- a/packages/upload-api/src/consumer/has.js +++ b/packages/upload-api/src/consumer/has.js @@ -6,6 +6,7 @@ import { Consumer } from '@web3-storage/capabilities' * @param {API.ConsumerServiceContext} context */ export const provide = (context) => + // @ts-ignore Provider.provide(Consumer.has, (input) => has(input, context)) /** diff --git a/packages/upload-api/src/provider-add.js b/packages/upload-api/src/provider-add.js index 0163de9ad..cf5379ff3 100644 --- a/packages/upload-api/src/provider-add.js +++ b/packages/upload-api/src/provider-add.js @@ -32,7 +32,7 @@ export const add = async ( } } const accountMailtoDID = - /** @type {import('@web3-storage/did-mailto/dist/src/types').DidMailto} */ ( + /** @type {import('@web3-storage/did-mailto/types').DidMailto} */ ( accountDID ) const rateLimitResult = await ensureRateLimitAbove( diff --git a/packages/upload-api/src/types.ts b/packages/upload-api/src/types.ts index 015ad2444..87ba15fd4 100644 --- a/packages/upload-api/src/types.ts +++ b/packages/upload-api/src/types.ts @@ -19,9 +19,9 @@ import type { import type { ProviderInput, ConnectionView } from '@ucanto/server' import { Signer as EdSigner } from '@ucanto/principal/ed25519' -import { DelegationsStorage as Delegations } from './types/delegations' -import { ProvisionsStorage as Provisions } from './types/provisions' -import { RateLimitsStorage as RateLimits } from './types/rate-limits' +import { DelegationsStorage as Delegations } from './types/delegations.js' +import { ProvisionsStorage as Provisions } from './types/provisions.js' +import { RateLimitsStorage as RateLimits } from './types/rate-limits.js' export type ValidationEmailSend = { to: string @@ -122,23 +122,23 @@ import { UCANRevokeFailure, } from '@web3-storage/capabilities/types' import * as Capabilities from '@web3-storage/capabilities' -import { RevocationsStorage } from './types/revocations' +import { RevocationsStorage } from './types/revocations.js' export * from '@web3-storage/capabilities/types' export * from '@ucanto/interface' -export type { ProvisionsStorage, Provision } from './types/provisions' +export type { ProvisionsStorage, Provision } from './types/provisions.js' export type { DelegationsStorage, Query as DelegationsStorageQuery, -} from './types/delegations' +} from './types/delegations.js' export type { Revocation, RevocationQuery, MatchingRevocations, RevocationsStorage, -} from './types/revocations' -export type { RateLimitsStorage, RateLimit } from './types/rate-limits' +} from './types/revocations.js' +export type { RateLimitsStorage, RateLimit } from './types/rate-limits.js' export interface Service { store: { diff --git a/packages/upload-api/src/types/provisions.ts b/packages/upload-api/src/types/provisions.ts index 2f061e07a..a2046c0b0 100644 --- a/packages/upload-api/src/types/provisions.ts +++ b/packages/upload-api/src/types/provisions.ts @@ -2,10 +2,10 @@ import type { AccountDID, ConsumerGetSuccess, ProviderDID, -} from '@web3-storage/capabilities/src/types' +} from '@web3-storage/capabilities/types' import * as Ucanto from '@ucanto/interface' -import { ProviderAdd } from '@web3-storage/capabilities/src/types' -import { SpaceDID } from '../types' +import { ProviderAdd } from '@web3-storage/capabilities/types' +import { SpaceDID } from '../types.js' /** * action which results in provisionment of a space consuming a storage provider diff --git a/packages/upload-api/src/upload/add.js b/packages/upload-api/src/upload/add.js index 977ae2f4d..c57312ce4 100644 --- a/packages/upload-api/src/upload/add.js +++ b/packages/upload-api/src/upload/add.js @@ -48,7 +48,7 @@ export function uploadAddProvider(context) { * Writes to a "bucket DB" the mapping from a data CID to the car CIDs it is composed of. * Retries up to 3 times, in case of failures. * - * @param {import("../types").DudewhereBucket} dudewhereStore + * @param {import("../types.js").DudewhereBucket} dudewhereStore * @param {Server.API.Link} root * @param {Server.API.Link[] | undefined} shards */ diff --git a/packages/upload-api/src/utils/delegations-response.js b/packages/upload-api/src/utils/delegations-response.js index 03214b6ec..6a0a46109 100644 --- a/packages/upload-api/src/utils/delegations-response.js +++ b/packages/upload-api/src/utils/delegations-response.js @@ -37,7 +37,7 @@ export function encode(delegations) { export function* decode(encoded) { for (const carBytes of Object.values(encoded)) { const delegations = bytesToDelegations( - /** @type {import('@web3-storage/access/src/types.js').BytesDelegation} */ ( + /** @type {import('@web3-storage/access/types').BytesDelegation} */ ( carBytes ) ) diff --git a/packages/upload-api/src/utils/did-mailto.js b/packages/upload-api/src/utils/did-mailto.js index 323b1e63b..35317d6e6 100644 --- a/packages/upload-api/src/utils/did-mailto.js +++ b/packages/upload-api/src/utils/did-mailto.js @@ -1,14 +1,14 @@ import * as DidMailto from '@web3-storage/did-mailto' /** - * @param {import("@web3-storage/did-mailto/dist/src/types").DidMailto} mailtoDid + * @param {import("@web3-storage/did-mailto/types").DidMailto} mailtoDid */ export function mailtoDidToEmail(mailtoDid) { return DidMailto.toEmail(DidMailto.fromString(mailtoDid)) } /** - * @param {import("@web3-storage/did-mailto/dist/src/types").DidMailto} mailtoDid + * @param {import("@web3-storage/did-mailto/types").DidMailto} mailtoDid */ export function mailtoDidToDomain(mailtoDid) { const accountEmail = mailtoDidToEmail(mailtoDid) diff --git a/packages/upload-api/src/utils/email.js b/packages/upload-api/src/utils/email.js index 70741cd0f..7b70bc668 100644 --- a/packages/upload-api/src/utils/email.js +++ b/packages/upload-api/src/utils/email.js @@ -1,5 +1,5 @@ /** - * @typedef { import("../types").ValidationEmailSend } ValidationEmailSend + * @typedef { import("../types.js").ValidationEmailSend } ValidationEmailSend */ export const debug = () => new DebugEmail() diff --git a/packages/upload-api/src/utils/rate-limits.js b/packages/upload-api/src/utils/rate-limits.js index eefc0b691..01961f85c 100644 --- a/packages/upload-api/src/utils/rate-limits.js +++ b/packages/upload-api/src/utils/rate-limits.js @@ -4,7 +4,7 @@ * not, and a Ucanto.Error if so, or if we get an error from the underlying * store. * - * @param {import("../types").RateLimitsStorage} storage + * @param {import("../types.js").RateLimitsStorage} storage * @param {string[]} subjects * @param {number} limitThreshold * @return {Promise>} diff --git a/packages/upload-api/src/validate.js b/packages/upload-api/src/validate.js index ec4467be0..5d21755ae 100644 --- a/packages/upload-api/src/validate.js +++ b/packages/upload-api/src/validate.js @@ -29,7 +29,7 @@ export async function authorizeFromUrl(url, env) { export async function authorize(encodedUcan, env) { try { /** - * @type {import('@ucanto/interface').Delegation<[import('@web3-storage/capabilities/src/types.js').AccessConfirm]>} + * @type {import('@ucanto/interface').Delegation<[import('@web3-storage/capabilities/types').AccessConfirm]>} */ const request = stringToDelegation(encodedUcan) diff --git a/packages/upload-api/test/access-client-agent.js b/packages/upload-api/test/access-client-agent.js index 0538caa99..7bb4fcc93 100644 --- a/packages/upload-api/test/access-client-agent.js +++ b/packages/upload-api/test/access-client-agent.js @@ -64,7 +64,7 @@ export const test = { ) assert.deepEqual(confirmationInvocations.length, 1) const serviceSaysAccountCanConfirm = - /** @type {API.Invocation} */ ( + /** @type {API.Invocation} */ ( confirmationInvocations[0] ) diff --git a/packages/upload-api/tsconfig.json b/packages/upload-api/tsconfig.json index 129f514ca..27148244c 100644 --- a/packages/upload-api/tsconfig.json +++ b/packages/upload-api/tsconfig.json @@ -2,7 +2,9 @@ "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "dist", - "types": ["mocha"] + "types": ["mocha"], + "module": "NodeNext", + "moduleResolution": "NodeNext" }, "include": ["src", "test"], "exclude": ["**/node_modules/**", "dist"], From baca19fc2bff7100dc8be79abac80c63ed8dde62 Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 12:36:21 -0700 Subject: [PATCH 05/20] wip fix upload-client --- packages/upload-client/package.json | 14 +++++----- packages/upload-client/src/car.js | 10 +++---- packages/upload-client/src/index.js | 28 ++++++++++---------- packages/upload-client/src/service.js | 2 +- packages/upload-client/src/sharding.js | 4 +-- packages/upload-client/src/store.js | 24 ++++++++--------- packages/upload-client/src/types.ts | 5 ++-- packages/upload-client/src/unixfs.js | 20 +++++++------- packages/upload-client/src/upload.js | 18 ++++++------- packages/upload-client/test/helpers/mocks.js | 4 +-- packages/upload-client/test/index.test.js | 22 +++++++-------- packages/upload-client/test/sharding.test.js | 6 ++--- packages/upload-client/test/unixfs.test.js | 3 ++- packages/upload-client/tsconfig.json | 3 +-- 14 files changed, 81 insertions(+), 82 deletions(-) diff --git a/packages/upload-client/package.json b/packages/upload-client/package.json index 4a4d92a4d..462a3ca4a 100644 --- a/packages/upload-client/package.json +++ b/packages/upload-client/package.json @@ -28,13 +28,13 @@ "rc": "npm version prerelease --preid rc" }, "exports": { - ".": "./src/index.js", - "./car": "./src/car.js", - "./sharding": "./src/sharding.js", - "./upload": "./src/upload.js", - "./store": "./src/store.js", - "./unixfs": "./src/unixfs.js", - "./types": "./src/types.js" + ".": "./dist/src/index.js", + "./car": "./dist/src/car.js", + "./sharding": "./dist/src/sharding.js", + "./upload": "./dist/src/upload.js", + "./store": "./dist/src/store.js", + "./unixfs": "./dist/src/unixfs.js", + "./types": "./dist/src/types.js" }, "typesVersions": { "*": { diff --git a/packages/upload-client/src/car.js b/packages/upload-client/src/car.js index 33406caf9..685d41a43 100644 --- a/packages/upload-client/src/car.js +++ b/packages/upload-client/src/car.js @@ -9,7 +9,7 @@ import varint from 'varint' /** Byte length of a CBOR encoded CAR header with zero roots. */ const NO_ROOTS_HEADER_LENGTH = 17 -/** @param {import('./types').AnyLink} [root] */ +/** @param {import('./types.js').AnyLink} [root] */ export function headerEncodingLength(root) { if (!root) return NO_ROOTS_HEADER_LENGTH const headerLength = dagCBOR.encode({ version: 1, roots: [root] }).length @@ -26,8 +26,8 @@ export function blockEncodingLength(block) { /** * @param {Iterable | AsyncIterable} blocks - * @param {import('./types').AnyLink} [root] - * @returns {Promise} + * @param {import('./types.js').AnyLink} [root] + * @returns {Promise} */ export async function encode(blocks, root) { // @ts-expect-error @@ -56,7 +56,7 @@ export async function encode(blocks, root) { /** @extends {ReadableStream} */ export class BlockStream extends ReadableStream { - /** @param {import('./types').BlobLike} car */ + /** @param {import('./types.js').BlobLike} car */ constructor(car) { /** @type {Promise?} */ let blocksPromise = null @@ -84,7 +84,7 @@ export class BlockStream extends ReadableStream { }, }) - /** @returns {Promise} */ + /** @returns {Promise} */ this.getRoots = async () => { const blocks = await getBlocksIterable() return await blocks.getRoots() diff --git a/packages/upload-client/src/index.js b/packages/upload-client/src/index.js index e1e90033a..bb4baead2 100644 --- a/packages/upload-client/src/index.js +++ b/packages/upload-client/src/index.js @@ -21,7 +21,7 @@ const PIECE_MULTIHASH_SIZE = PieceHasher.prefix.length + PieceHasher.size * * Required delegated capability proofs: `store/add`, `upload/add` * - * @param {import('./types').InvocationConfig} conf Configuration + * @param {import('./types.js').InvocationConfig} conf Configuration * for the UCAN invocation. An object with `issuer`, `with` and `proofs`. * * The `issuer` is the signing authority that is issuing the UCAN @@ -34,8 +34,8 @@ const PIECE_MULTIHASH_SIZE = PieceHasher.prefix.length + PieceHasher.size * has the capability to perform the action. * * The issuer needs the `store/add` and `upload/add` delegated capability. - * @param {import('./types').BlobLike} file File data. - * @param {import('./types').UploadOptions} [options] + * @param {import('./types.js').BlobLike} file File data. + * @param {import('./types.js').UploadOptions} [options] */ export async function uploadFile(conf, file, options = {}) { return await uploadBlockStream( @@ -52,7 +52,7 @@ export async function uploadFile(conf, file, options = {}) { * * Required delegated capability proofs: `store/add`, `upload/add` * - * @param {import('./types').InvocationConfig} conf Configuration + * @param {import('./types.js').InvocationConfig} conf Configuration * for the UCAN invocation. An object with `issuer`, `with` and `proofs`. * * The `issuer` is the signing authority that is issuing the UCAN @@ -65,8 +65,8 @@ export async function uploadFile(conf, file, options = {}) { * has the capability to perform the action. * * The issuer needs the `store/add` and `upload/add` delegated capability. - * @param {import('./types').FileLike[]} files File data. - * @param {import('./types').UploadDirectoryOptions} [options] + * @param {import('./types.js').FileLike[]} files File data. + * @param {import('./types.js').UploadDirectoryOptions} [options] */ export async function uploadDirectory(conf, files, options = {}) { return await uploadBlockStream( @@ -87,7 +87,7 @@ export async function uploadDirectory(conf, files, options = {}) { * * Required delegated capability proofs: `store/add`, `upload/add` * - * @param {import('./types').InvocationConfig} conf Configuration + * @param {import('./types.js').InvocationConfig} conf Configuration * for the UCAN invocation. An object with `issuer`, `with` and `proofs`. * * The `issuer` is the signing authority that is issuing the UCAN @@ -100,8 +100,8 @@ export async function uploadDirectory(conf, files, options = {}) { * has the capability to perform the action. * * The issuer needs the `store/add` and `upload/add` delegated capability. - * @param {import('./types').BlobLike} car CAR file. - * @param {import('./types').UploadOptions} [options] + * @param {import('./types.js').BlobLike} car CAR file. + * @param {import('./types.js').UploadOptions} [options] */ export async function uploadCAR(conf, car, options = {}) { const blocks = new CAR.BlockStream(car) @@ -110,15 +110,15 @@ export async function uploadCAR(conf, car, options = {}) { } /** - * @param {import('./types').InvocationConfig} conf + * @param {import('./types.js').InvocationConfig} conf * @param {ReadableStream} blocks - * @param {import('./types').UploadOptions} [options] - * @returns {Promise} + * @param {import('./types.js').UploadOptions} [options] + * @returns {Promise} */ async function uploadBlockStream(conf, blocks, options = {}) { - /** @type {import('./types').CARLink[]} */ + /** @type {import('./types.js').CARLink[]} */ const shards = [] - /** @type {import('./types').AnyLink?} */ + /** @type {import('./types.js').AnyLink?} */ let root = null const concurrency = options.concurrentRequests ?? CONCURRENT_REQUESTS await blocks diff --git a/packages/upload-client/src/service.js b/packages/upload-client/src/service.js index 9839ecc38..68ff213c5 100644 --- a/packages/upload-client/src/service.js +++ b/packages/upload-client/src/service.js @@ -5,7 +5,7 @@ import * as DID from '@ipld/dag-ucan/did' export const serviceURL = new URL('https://up.web3.storage') export const servicePrincipal = DID.parse('did:web:web3.storage') -/** @type {import('@ucanto/interface').ConnectionView} */ +/** @type {import('@ucanto/interface').ConnectionView} */ export const connection = connect({ id: servicePrincipal, codec: CAR.outbound, diff --git a/packages/upload-client/src/sharding.js b/packages/upload-client/src/sharding.js index 9eefd9b36..b69bdc4e0 100644 --- a/packages/upload-client/src/sharding.js +++ b/packages/upload-client/src/sharding.js @@ -8,11 +8,11 @@ const SHARD_SIZE = 133_169_152 * received is assumed to be the DAG root and becomes the CAR root CID for the * last CAR output. Set the `rootCID` option to override. * - * @extends {TransformStream} + * @extends {TransformStream} */ export class ShardingStream extends TransformStream { /** - * @param {import('./types').ShardingOptions} [options] + * @param {import('./types.js').ShardingOptions} [options] */ constructor(options = {}) { const shardSize = options.shardSize ?? SHARD_SIZE diff --git a/packages/upload-client/src/store.js b/packages/upload-client/src/store.js index e4789fd76..6dab2a436 100644 --- a/packages/upload-client/src/store.js +++ b/packages/upload-client/src/store.js @@ -10,12 +10,12 @@ const { fetch } = fetchPkg /** * * @param {string} url - * @param {import('./types').ProgressFn} handler + * @param {import('./types.js').ProgressFn} handler */ function createUploadProgressHandler(url, handler) { /** * - * @param {import('./types').ProgressStatus} status + * @param {import('./types.js').ProgressStatus} status */ function onUploadProgress({ total, loaded, lengthComputable }) { return handler({ total, loaded, lengthComputable, url }) @@ -29,7 +29,7 @@ function createUploadProgressHandler(url, handler) { * * Required delegated capability proofs: `store/add` * - * @param {import('./types').InvocationConfig} conf Configuration + * @param {import('./types.js').InvocationConfig} conf Configuration * for the UCAN invocation. An object with `issuer`, `with` and `proofs`. * * The `issuer` is the signing authority that is issuing the UCAN @@ -43,8 +43,8 @@ function createUploadProgressHandler(url, handler) { * * The issuer needs the `store/add` delegated capability. * @param {Blob|Uint8Array} car CAR file data. - * @param {import('./types').RequestOptions} [options] - * @returns {Promise} + * @param {import('./types.js').RequestOptions} [options] + * @returns {Promise} */ export async function add( { issuer, with: resource, proofs, audience }, @@ -90,7 +90,7 @@ export async function add( const responseAddUpload = result.out.ok const fetchWithUploadProgress = - /** @type {(url: string, init?: import('./types').FetchOptions) => Promise} */ ( + /** @type {(url: string, init?: import('./types.js').FetchOptions) => Promise} */ ( fetch ) @@ -138,7 +138,7 @@ export async function add( /** * List CAR files stored by the issuer. * - * @param {import('./types').InvocationConfig} conf Configuration + * @param {import('./types.js').InvocationConfig} conf Configuration * for the UCAN invocation. An object with `issuer`, `with` and `proofs`. * * The `issuer` is the signing authority that is issuing the UCAN @@ -151,8 +151,8 @@ export async function add( * has the capability to perform the action. * * The issuer needs the `store/list` delegated capability. - * @param {import('./types').ListRequestOptions} [options] - * @returns {Promise} + * @param {import('./types.js').ListRequestOptions} [options] + * @returns {Promise} */ export async function list( { issuer, with: resource, proofs, audience }, @@ -187,7 +187,7 @@ export async function list( /** * Remove a stored CAR file by CAR CID. * - * @param {import('./types').InvocationConfig} conf Configuration + * @param {import('./types.js').InvocationConfig} conf Configuration * for the UCAN invocation. An object with `issuer`, `with` and `proofs`. * * The `issuer` is the signing authority that is issuing the UCAN @@ -200,8 +200,8 @@ export async function list( * has the capability to perform the action. * * The issuer needs the `store/remove` delegated capability. - * @param {import('./types').CARLink} link CID of CAR file to remove. - * @param {import('./types').RequestOptions} [options] + * @param {import('./types.js').CARLink} link CID of CAR file to remove. + * @param {import('./types.js').RequestOptions} [options] */ export async function remove( { issuer, with: resource, proofs, audience }, diff --git a/packages/upload-client/src/types.ts b/packages/upload-client/src/types.ts index b1390f265..688b9ec76 100644 --- a/packages/upload-client/src/types.ts +++ b/packages/upload-client/src/types.ts @@ -1,7 +1,7 @@ import type { FetchOptions, ProgressStatus as XHRProgressStatus, -} from 'ipfs-utils/src/types' +} from 'ipfs-utils/src/types.js' import { Link, UnknownLink, Version } from 'multiformats/link' import { Block } from '@ipld/unixfs' import { @@ -41,7 +41,6 @@ import { UploadGetSuccess, UploadGetFailure, } from '@web3-storage/capabilities/types' -import * as UnixFS from '@ipld/unixfs/src/unixfs' export type { FetchOptions, @@ -202,7 +201,7 @@ export interface RequestOptions export interface ListRequestOptions extends RequestOptions, Pageable {} -export type DirectoryEntryLink = UnixFS.DirectoryEntryLink +export type DirectoryEntryLink = import('@ipld/unixfs/directory').DirectoryEntryLink export interface UnixFSDirectoryEncoderOptions { /** diff --git a/packages/upload-client/src/unixfs.js b/packages/upload-client/src/unixfs.js index 942e2ea95..3547ba71f 100644 --- a/packages/upload-client/src/unixfs.js +++ b/packages/upload-client/src/unixfs.js @@ -14,8 +14,8 @@ const settings = UnixFS.configure({ }) /** - * @param {import('./types').BlobLike} blob - * @returns {Promise} + * @param {import('./types.js').BlobLike} blob + * @returns {Promise} */ export async function encodeFile(blob) { const readable = createFileEncoderStream(blob) @@ -25,7 +25,7 @@ export async function encodeFile(blob) { } /** - * @param {import('./types').BlobLike} blob + * @param {import('./types.js').BlobLike} blob * @returns {ReadableStream} */ export function createFileEncoderStream(blob) { @@ -45,7 +45,7 @@ class UnixFSFileBuilder { /** * @param {string} name - * @param {import('./types').BlobLike} file + * @param {import('./types.js').BlobLike} file */ constructor(name, file) { this.name = name @@ -74,7 +74,7 @@ class UnixFSDirectoryBuilder { /** * @param {string} name - * @param {import('./types').UnixFSDirectoryEncoderOptions} [options] + * @param {import('./types.js').UnixFSDirectoryEncoderOptions} [options] */ constructor(name, options) { this.name = name @@ -100,9 +100,9 @@ class UnixFSDirectoryBuilder { } /** - * @param {Iterable} files - * @param {import('./types').UnixFSDirectoryEncoderOptions} [options] - * @returns {Promise} + * @param {Iterable} files + * @param {import('./types.js').UnixFSDirectoryEncoderOptions} [options] + * @returns {Promise} */ export async function encodeDirectory(files, options) { const readable = createDirectoryEncoderStream(files, options) @@ -112,8 +112,8 @@ export async function encodeDirectory(files, options) { } /** - * @param {Iterable} files - * @param {import('./types').UnixFSDirectoryEncoderOptions} [options] + * @param {Iterable} files + * @param {import('./types.js').UnixFSDirectoryEncoderOptions} [options] * @returns {ReadableStream} */ export function createDirectoryEncoderStream(files, options) { diff --git a/packages/upload-client/src/upload.js b/packages/upload-client/src/upload.js index 733132959..28dd89e6c 100644 --- a/packages/upload-client/src/upload.js +++ b/packages/upload-client/src/upload.js @@ -10,7 +10,7 @@ import { REQUEST_RETRIES } from './constants.js' * * Required delegated capability proofs: `upload/add` * - * @param {import('./types').InvocationConfig} conf Configuration + * @param {import('./types.js').InvocationConfig} conf Configuration * for the UCAN invocation. An object with `issuer`, `with` and `proofs`. * * The `issuer` is the signing authority that is issuing the UCAN @@ -24,9 +24,9 @@ import { REQUEST_RETRIES } from './constants.js' * * The issuer needs the `upload/add` delegated capability. * @param {import('multiformats/link').UnknownLink} root Root data CID for the DAG that was stored. - * @param {import('./types').CARLink[]} shards CIDs of CAR files that contain the DAG. - * @param {import('./types').RequestOptions} [options] - * @returns {Promise} + * @param {import('./types.js').CARLink[]} shards CIDs of CAR files that contain the DAG. + * @param {import('./types.js').RequestOptions} [options] + * @returns {Promise} */ export async function add( { issuer, with: resource, proofs, audience }, @@ -67,7 +67,7 @@ export async function add( /** * List uploads created by the issuer. * - * @param {import('./types').InvocationConfig} conf Configuration + * @param {import('./types.js').InvocationConfig} conf Configuration * for the UCAN invocation. An object with `issuer`, `with` and `proofs`. * * The `issuer` is the signing authority that is issuing the UCAN @@ -80,8 +80,8 @@ export async function add( * has the capability to perform the action. * * The issuer needs the `upload/list` delegated capability. - * @param {import('./types').ListRequestOptions} [options] - * @returns {Promise} + * @param {import('./types.js').ListRequestOptions} [options] + * @returns {Promise} */ export async function list( { issuer, with: resource, proofs, audience }, @@ -117,7 +117,7 @@ export async function list( /** * Remove an upload by root data CID. * - * @param {import('./types').InvocationConfig} conf Configuration + * @param {import('./types.js').InvocationConfig} conf Configuration * for the UCAN invocation. An object with `issuer`, `with` and `proofs`. * * The `issuer` is the signing authority that is issuing the UCAN @@ -131,7 +131,7 @@ export async function list( * * The issuer needs the `upload/remove` delegated capability. * @param {import('multiformats').UnknownLink} root Root data CID to remove. - * @param {import('./types').RequestOptions} [options] + * @param {import('./types.js').RequestOptions} [options] */ export async function remove( { issuer, with: resource, proofs, audience }, diff --git a/packages/upload-client/test/helpers/mocks.js b/packages/upload-client/test/helpers/mocks.js index 937914bf6..555287f04 100644 --- a/packages/upload-client/test/helpers/mocks.js +++ b/packages/upload-client/test/helpers/mocks.js @@ -6,8 +6,8 @@ const notImplemented = () => { /** * @param {Partial<{ - * store: Partial - * upload: Partial + * store: Partial + * upload: Partial * }>} impl */ export function mockService(impl) { diff --git a/packages/upload-client/test/index.test.js b/packages/upload-client/test/index.test.js index 2804ac020..8cf0f7472 100644 --- a/packages/upload-client/test/index.test.js +++ b/packages/upload-client/test/index.test.js @@ -28,7 +28,7 @@ describe('uploadFile', () => { const file = new Blob([bytes]) const expectedCar = await toCAR(bytes) - /** @type {import('../src/types').CARLink|undefined} */ + /** @type {import('../src/types.js').CARLink|undefined} */ let carCID const proofs = await Promise.all([ @@ -120,7 +120,7 @@ describe('uploadFile', () => { const space = await Signer.generate() const agent = await Signer.generate() // The "user" that will ask the service to accept the upload const file = new Blob([await randomBytes(1024 * 1024 * 5)]) - /** @type {import('../src/types').CARLink[]} */ + /** @type {import('../src/types.js').CARLink[]} */ const carCIDs = [] const proofs = await Promise.all([ @@ -151,7 +151,7 @@ describe('uploadFile', () => { add: provide(StoreCapabilities.add, ({ capability }) => ({ ok: { ...res, - link: /** @type {import('../src/types').CARLink} */ ( + link: /** @type {import('../src/types.js').CARLink} */ ( capability.nb.link ), }, @@ -206,7 +206,7 @@ describe('uploadDirectory', () => { new File([await randomBytes(32)], '2.txt'), ] - /** @type {import('../src/types').CARLink?} */ + /** @type {import('../src/types.js').CARLink?} */ let carCID = null const proofs = await Promise.all([ @@ -243,7 +243,7 @@ describe('uploadDirectory', () => { return { ok: { ...res, - link: /** @type {import('../src/types').CARLink} */ ( + link: /** @type {import('../src/types.js').CARLink} */ ( capability.nb.link ), }, @@ -300,7 +300,7 @@ describe('uploadDirectory', () => { const space = await Signer.generate() const agent = await Signer.generate() // The "user" that will ask the service to accept the upload const files = [new File([await randomBytes(500_000)], '1.txt')] - /** @type {import('../src/types').CARLink[]} */ + /** @type {import('../src/types.js').CARLink[]} */ const carCIDs = [] const proofs = await Promise.all([ @@ -331,7 +331,7 @@ describe('uploadDirectory', () => { add: provide(StoreCapabilities.add, ({ capability }) => ({ ok: { ...res, - link: /** @type {import('../src/types').CARLink} */ ( + link: /** @type {import('../src/types.js').CARLink} */ ( capability.nb.link ), }, @@ -388,7 +388,7 @@ describe('uploadCAR', () => { .slice(0, -1) .reduce((size, block) => size + blockEncodingLength(block), 0) - /** @type {import('../src/types').CARLink[]} */ + /** @type {import('../src/types.js').CARLink[]} */ const carCIDs = [] const proofs = await Promise.all([ @@ -425,7 +425,7 @@ describe('uploadCAR', () => { return { ok: { ...res, - link: /** @type {import('../src/types').CARLink} */ ( + link: /** @type {import('../src/types.js').CARLink} */ ( capability.nb.link ), }, @@ -489,7 +489,7 @@ describe('uploadCAR', () => { ] const car = await encode(blocks, blocks.at(-1)?.cid) - /** @type {import('../src/types').PieceLink[]} */ + /** @type {import('../src/types.js').PieceLink[]} */ const pieceCIDs = [] const proofs = await Promise.all([ @@ -526,7 +526,7 @@ describe('uploadCAR', () => { return { ok: { ...res, - link: /** @type {import('../src/types').CARLink} */ ( + link: /** @type {import('../src/types.js').CARLink} */ ( capability.nb.link ), }, diff --git a/packages/upload-client/test/sharding.test.js b/packages/upload-client/test/sharding.test.js index 3c808c54a..a40f22f9e 100644 --- a/packages/upload-client/test/sharding.test.js +++ b/packages/upload-client/test/sharding.test.js @@ -9,7 +9,7 @@ describe('ShardingStream', () => { const file = new Blob([await randomBytes(1024 * 1024 * 5)]) const shardSize = 1024 * 1024 * 2 - /** @type {import('../src/types').CARFile[]} */ + /** @type {import('../src/types.js').CARFile[]} */ const shards = [] await createFileEncoderStream(file) @@ -36,7 +36,7 @@ describe('ShardingStream', () => { const rootCID = CID.parse( 'bafybeibrqc2se2p3k4kfdwg7deigdggamlumemkiggrnqw3edrjosqhvnm' ) - /** @type {import('../src/types').CARFile[]} */ + /** @type {import('../src/types.js').CARFile[]} */ const shards = [] await createFileEncoderStream(file) @@ -76,7 +76,7 @@ describe('ShardingStream', () => { await randomBlock(32), // encoded block length = 70 ] - /** @type {import('../src/types').CARFile[]} */ + /** @type {import('../src/types.js').CARFile[]} */ const shards = [] await new ReadableStream({ pull(controller) { diff --git a/packages/upload-client/test/unixfs.test.js b/packages/upload-client/test/unixfs.test.js index 62b8191c3..f8d430984 100644 --- a/packages/upload-client/test/unixfs.test.js +++ b/packages/upload-client/test/unixfs.test.js @@ -1,6 +1,7 @@ import assert from 'assert' import { decode, NodeType } from '@ipld/unixfs' import { exporter } from 'ipfs-unixfs-exporter' +// @ts-ignore import { MemoryBlockstore } from 'blockstore-core/memory' import * as raw from 'multiformats/codecs/raw' import path from 'path' @@ -25,7 +26,7 @@ async function collectDir(dir) { async function blocksToBlockstore(blocks) { const blockstore = new MemoryBlockstore() for (const block of blocks) { - // @ts-expect-error https://github.com/ipld/js-unixfs/issues/30 + // @ts-expect-error await blockstore.put(block.cid, block.bytes) } return blockstore diff --git a/packages/upload-client/tsconfig.json b/packages/upload-client/tsconfig.json index 19939a363..3cbd72f5a 100644 --- a/packages/upload-client/tsconfig.json +++ b/packages/upload-client/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "dist", - "lib": ["ESNext", "DOM"], - "emitDeclarationOnly": true + "lib": ["ESNext", "DOM"] }, "include": ["src", "scripts", "test", "package.json"], "exclude": ["**/node_modules/**"], From e4e431dc67bdc345abed86a5e330e963184bdb49 Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 12:45:05 -0700 Subject: [PATCH 06/20] w3up-client package uses module/moduleResolution NodeNext and now passes attw check --- packages/w3up-client/src/base.js | 6 ++-- packages/w3up-client/src/capability/access.js | 2 +- packages/w3up-client/src/capability/space.js | 2 +- packages/w3up-client/src/capability/store.js | 8 ++--- packages/w3up-client/src/capability/upload.js | 12 +++---- packages/w3up-client/src/client.js | 36 +++++++++---------- packages/w3up-client/src/delegation.js | 6 ++-- packages/w3up-client/src/index.js | 2 +- packages/w3up-client/src/index.node.js | 2 +- packages/w3up-client/src/service.js | 2 +- packages/w3up-client/src/space.js | 4 +-- packages/w3up-client/src/types.ts | 4 +-- packages/w3up-client/test/client.test.js | 2 +- packages/w3up-client/tsconfig.json | 4 ++- 14 files changed, 47 insertions(+), 45 deletions(-) diff --git a/packages/w3up-client/src/base.js b/packages/w3up-client/src/base.js index dd337470f..decf8abc6 100644 --- a/packages/w3up-client/src/base.js +++ b/packages/w3up-client/src/base.js @@ -9,7 +9,7 @@ export class Base { _agent /** - * @type {import('./types').ServiceConf} + * @type {import('./types.js').ServiceConf} * @protected */ _serviceConf @@ -17,7 +17,7 @@ export class Base { /** * @param {import('@web3-storage/access').AgentData} agentData * @param {object} [options] - * @param {import('./types').ServiceConf} [options.serviceConf] + * @param {import('./types.js').ServiceConf} [options.serviceConf] */ constructor(agentData, options = {}) { this._serviceConf = options.serviceConf ?? serviceConf @@ -31,7 +31,7 @@ export class Base { /** * @protected - * @param {import('./types').Ability[]} abilities + * @param {import('./types.js').Ability[]} abilities */ async _invocationConfig(abilities) { const resource = this._agent.currentSpace() diff --git a/packages/w3up-client/src/capability/access.js b/packages/w3up-client/src/capability/access.js index bba8ce38d..f7feff0a2 100644 --- a/packages/w3up-client/src/capability/access.js +++ b/packages/w3up-client/src/capability/access.js @@ -13,7 +13,7 @@ export class AccessClient extends Base { * @param {`${string}@${string}`} email * @param {object} [options] * @param {AbortSignal} [options.signal] - * @param {Iterable<{ can: import('../types').Ability }>} [options.capabilities] + * @param {Iterable<{ can: import('../types.js').Ability }>} [options.capabilities] */ async authorize(email, options) { return authorizeWaitAndClaim(this._agent, email, options) diff --git a/packages/w3up-client/src/capability/space.js b/packages/w3up-client/src/capability/space.js index 95992031c..f2c077d28 100644 --- a/packages/w3up-client/src/capability/space.js +++ b/packages/w3up-client/src/capability/space.js @@ -7,7 +7,7 @@ export class SpaceClient extends Base { /** * Get information about a space. * - * @param {import('../types').DID} space - DID of the space to retrieve info about. + * @param {import('../types.js').DID} space - DID of the space to retrieve info about. */ async info(space) { return await this._agent.getSpaceInfo(space) diff --git a/packages/w3up-client/src/capability/store.js b/packages/w3up-client/src/capability/store.js index 18fc1cdf8..1ced89bfe 100644 --- a/packages/w3up-client/src/capability/store.js +++ b/packages/w3up-client/src/capability/store.js @@ -10,7 +10,7 @@ export class StoreClient extends Base { * Store a DAG encoded as a CAR file. * * @param {Blob} car - CAR file data. - * @param {import('../types').RequestOptions} [options] + * @param {import('../types.js').RequestOptions} [options] */ async add(car, options = {}) { const conf = await this._invocationConfig([StoreCapabilities.add.can]) @@ -21,7 +21,7 @@ export class StoreClient extends Base { /** * List CAR files stored to the resource. * - * @param {import('../types').ListRequestOptions} [options] + * @param {import('../types.js').ListRequestOptions} [options] */ async list(options = {}) { const conf = await this._invocationConfig([StoreCapabilities.add.can]) @@ -32,8 +32,8 @@ export class StoreClient extends Base { /** * Remove a stored CAR file by CAR CID. * - * @param {import('../types').CARLink} link - CID of CAR file to remove. - * @param {import('../types').RequestOptions} [options] + * @param {import('../types.js').CARLink} link - CID of CAR file to remove. + * @param {import('../types.js').RequestOptions} [options] */ async remove(link, options = {}) { const conf = await this._invocationConfig([StoreCapabilities.remove.can]) diff --git a/packages/w3up-client/src/capability/upload.js b/packages/w3up-client/src/capability/upload.js index 56d5db287..f27e41965 100644 --- a/packages/w3up-client/src/capability/upload.js +++ b/packages/w3up-client/src/capability/upload.js @@ -9,9 +9,9 @@ export class UploadClient extends Base { /** * Register an "upload" to the resource. * - * @param {import('../types').UnknownLink} root - Root data CID for the DAG that was stored. - * @param {import('../types').CARLink[]} shards - CIDs of CAR files that contain the DAG. - * @param {import('../types').RequestOptions} [options] + * @param {import('../types.js').UnknownLink} root - Root data CID for the DAG that was stored. + * @param {import('../types.js').CARLink[]} shards - CIDs of CAR files that contain the DAG. + * @param {import('../types.js').RequestOptions} [options] */ async add(root, shards, options = {}) { const conf = await this._invocationConfig([UploadCapabilities.add.can]) @@ -22,7 +22,7 @@ export class UploadClient extends Base { /** * List uploads registered to the resource. * - * @param {import('../types').ListRequestOptions} [options] + * @param {import('../types.js').ListRequestOptions} [options] */ async list(options = {}) { const conf = await this._invocationConfig([UploadCapabilities.list.can]) @@ -33,8 +33,8 @@ export class UploadClient extends Base { /** * Remove an upload by root data CID. * - * @param {import('../types').UnknownLink} root - Root data CID to remove. - * @param {import('../types').RequestOptions} [options] + * @param {import('../types.js').UnknownLink} root - Root data CID to remove. + * @param {import('../types.js').RequestOptions} [options] */ async remove(root, options = {}) { const conf = await this._invocationConfig([UploadCapabilities.remove.can]) diff --git a/packages/w3up-client/src/client.js b/packages/w3up-client/src/client.js index 570ba9670..071d59eed 100644 --- a/packages/w3up-client/src/client.js +++ b/packages/w3up-client/src/client.js @@ -21,7 +21,7 @@ export class Client extends Base { /** * @param {import('@web3-storage/access').AgentData} agentData * @param {object} [options] - * @param {import('./types').ServiceConf} [options.serviceConf] + * @param {import('./types.js').ServiceConf} [options.serviceConf] */ constructor(agentData, options) { super(agentData, options) @@ -41,7 +41,7 @@ export class Client extends Base { * @param {`${string}@${string}`} email * @param {object} [options] * @param {AbortSignal} [options.signal] - * @param {Iterable<{ can: import('./types').Ability }>} [options.capabilities] + * @param {Iterable<{ can: import('./types.js').Ability }>} [options.capabilities] */ async authorize(email, options) { await this.capability.access.authorize(email, options) @@ -52,8 +52,8 @@ export class Client extends Base { * Uploads a file to the service and returns the root data CID for the * generated DAG. * - * @param {import('./types').BlobLike} file - File data. - * @param {import('./types').UploadOptions} [options] + * @param {import('./types.js').BlobLike} file - File data. + * @param {import('./types.js').UploadOptions} [options] */ async uploadFile(file, options = {}) { const conf = await this._invocationConfig([ @@ -69,8 +69,8 @@ export class Client extends Base { * for the generated DAG. All files are added to a container directory, with * paths in file names preserved. * - * @param {import('./types').FileLike[]} files - File data. - * @param {import('./types').UploadDirectoryOptions} [options] + * @param {import('./types.js').FileLike[]} files - File data. + * @param {import('./types.js').UploadDirectoryOptions} [options] */ async uploadDirectory(files, options = {}) { const conf = await this._invocationConfig([ @@ -90,8 +90,8 @@ export class Client extends Base { * * Use the `onShardStored` callback to obtain the CIDs of the CAR file shards. * - * @param {import('./types').BlobLike} car - CAR file. - * @param {import('./types').UploadOptions} [options] + * @param {import('./types.js').BlobLike} car - CAR file. + * @param {import('./types.js').UploadOptions} [options] */ async uploadCAR(car, options = {}) { const conf = await this._invocationConfig([ @@ -127,7 +127,7 @@ export class Client extends Base { /** * Use a specific space. * - * @param {import('./types').DID} did + * @param {import('./types.js').DID} did */ async setCurrentSpace(did) { await this._agent.setCurrentSpace(/** @type {`did:key:${string}`} */ (did)) @@ -158,13 +158,13 @@ export class Client extends Base { * * @param {string} email * @param {object} [options] - * @param {import('./types').DID<'web'>} [options.provider] + * @param {import('./types.js').DID<'web'>} [options.provider] * @param {AbortSignal} [options.signal] */ async registerSpace(email, options = {}) { options.provider = options.provider ?? - /** @type {import('./types').DID<'web'>} */ (this.defaultProvider()) + /** @type {import('./types.js').DID<'web'>} */ (this.defaultProvider()) await this._agent.registerSpace(email, options) } /* c8 ignore stop */ @@ -172,7 +172,7 @@ export class Client extends Base { /** * Add a space from a received proof. * - * @param {import('./types').Delegation} proof + * @param {import('./types.js').Delegation} proof */ async addSpace(proof) { const { did, meta } = await this._agent.importSpaceFromDelegation(proof) @@ -184,7 +184,7 @@ export class Client extends Base { * * Proofs are delegations with an _audience_ matching the agent DID. * - * @param {import('./types').Capability[]} [caps] - Capabilities to + * @param {import('./types.js').Capability[]} [caps] - Capabilities to * filter by. Empty or undefined caps with return all the proofs. */ proofs(caps) { @@ -195,7 +195,7 @@ export class Client extends Base { * Add a proof to the agent. Proofs are delegations with an _audience_ * matching the agent DID. * - * @param {import('./types').Delegation} proof + * @param {import('./types.js').Delegation} proof */ async addProof(proof) { await this._agent.addProof(proof) @@ -204,7 +204,7 @@ export class Client extends Base { /** * Get delegations created by the agent for others. * - * @param {import('./types').Capability[]} [caps] - Capabilities to + * @param {import('./types.js').Capability[]} [caps] - Capabilities to * filter by. Empty or undefined caps with return all the delegations. */ delegations(caps) { @@ -221,9 +221,9 @@ export class Client extends Base { * Create a delegation to the passed audience for the given abilities with * the _current_ space as the resource. * - * @param {import('./types').Principal} audience - * @param {import('./types').Abilities[]} abilities - * @param {Omit & { audienceMeta?: import('./types').AgentMeta }} [options] + * @param {import('./types.js').Principal} audience + * @param {import('./types.js').Abilities[]} abilities + * @param {Omit & { audienceMeta?: import('./types.js').AgentMeta }} [options] */ async createDelegation(audience, abilities, options = {}) { const audienceMeta = options.audienceMeta ?? { diff --git a/packages/w3up-client/src/delegation.js b/packages/w3up-client/src/delegation.js index a5f86e3f2..358df2e66 100644 --- a/packages/w3up-client/src/delegation.js +++ b/packages/w3up-client/src/delegation.js @@ -1,7 +1,7 @@ import { Delegation as CoreDelegation } from '@ucanto/core/delegation' /** - * @template {import('./types').Capabilities} C + * @template {import('./types.js').Capabilities} C * @extends {CoreDelegation} */ export class Delegation extends CoreDelegation { @@ -9,8 +9,8 @@ export class Delegation extends CoreDelegation { #meta /** - * @param {import('./types').UCANBlock} root - * @param {Map} [blocks] + * @param {import('./types.js').UCANBlock} root + * @param {Map} [blocks] * @param {Record} [meta] */ constructor(root, blocks, meta = {}) { diff --git a/packages/w3up-client/src/index.js b/packages/w3up-client/src/index.js index 11488e8d9..9b5d4f85b 100644 --- a/packages/w3up-client/src/index.js +++ b/packages/w3up-client/src/index.js @@ -22,7 +22,7 @@ import { Client } from './client.js' * * If the backing store already has data stored, it will be loaded and used. * - * @type {import('./types').ClientFactory} + * @type {import('./types.js').ClientFactory} */ export async function create(options = {}) { const store = options.store ?? new StoreIndexedDB('w3up-client') diff --git a/packages/w3up-client/src/index.node.js b/packages/w3up-client/src/index.node.js index c7dd0deb6..2778d4b16 100644 --- a/packages/w3up-client/src/index.node.js +++ b/packages/w3up-client/src/index.node.js @@ -19,7 +19,7 @@ import { Client } from './client.js' * * If the backing store already has data stored, it will be loaded and used. * - * @type {import('./types').ClientFactory} + * @type {import('./types.js').ClientFactory} */ export async function create(options = {}) { const store = options.store ?? new StoreConf({ profile: 'w3up-client' }) diff --git a/packages/w3up-client/src/service.js b/packages/w3up-client/src/service.js index bff1c2951..26d00daba 100644 --- a/packages/w3up-client/src/service.js +++ b/packages/w3up-client/src/service.js @@ -26,7 +26,7 @@ export const uploadServiceConnection = connect({ }), }) -/** @type {import('./types').ServiceConf} */ +/** @type {import('./types.js').ServiceConf} */ export const serviceConf = { access: accessServiceConnection, upload: uploadServiceConnection, diff --git a/packages/w3up-client/src/space.js b/packages/w3up-client/src/space.js index 6bb366d94..37f1b4cca 100644 --- a/packages/w3up-client/src/space.js +++ b/packages/w3up-client/src/space.js @@ -1,12 +1,12 @@ export class Space { - /** @type {import('./types').DID} */ + /** @type {import('./types.js').DID} */ #did /** @type {Record} */ #meta /** - * @param {import('./types').DID} did + * @param {import('./types.js').DID} did * @param {Record} meta */ constructor(did, meta = {}) { diff --git a/packages/w3up-client/src/types.ts b/packages/w3up-client/src/types.ts index 98d314e51..916f25419 100644 --- a/packages/w3up-client/src/types.ts +++ b/packages/w3up-client/src/types.ts @@ -5,7 +5,7 @@ import { } from '@web3-storage/access/types' import { type Service as UploadService } from '@web3-storage/upload-client/types' import type { ConnectionView, Signer, DID } from '@ucanto/interface' -import { type Client } from './client' +import { type Client } from './client.js' export interface ServiceConf { access: ConnectionView @@ -31,7 +31,7 @@ export interface ClientFactoryOptions { export type ClientFactory = (options?: ClientFactoryOptions) => Promise -export { Client } from './client' +export { Client } from './client.js' export type { UnknownLink } from 'multiformats' diff --git a/packages/w3up-client/test/client.test.js b/packages/w3up-client/test/client.test.js index 79b18951c..f2d143d80 100644 --- a/packages/w3up-client/test/client.test.js +++ b/packages/w3up-client/test/client.test.js @@ -188,7 +188,7 @@ describe('Client', () => { it('uploads a CAR file to the service', async () => { const car = await randomCAR(32) - /** @type {import('../src/types').CARLink?} */ + /** @type {import('../src/types.js').CARLink?} */ let carCID const service = mockService({ diff --git a/packages/w3up-client/tsconfig.json b/packages/w3up-client/tsconfig.json index cd6061a54..49a37df23 100644 --- a/packages/w3up-client/tsconfig.json +++ b/packages/w3up-client/tsconfig.json @@ -4,7 +4,9 @@ "outDir": "dist", "emitDeclarationOnly": true, "composite": true, - "noUnusedParameters": false + "noUnusedParameters": false, + "module": "NodeNext", + "moduleResolution": "NodeNext" }, "include": ["./src", "./test"], "typedocOptions": { From 51fac4635712eeb9ad99a48221d63f684c8a97da Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 12:49:36 -0700 Subject: [PATCH 07/20] filecoin-client fix attw --- packages/filecoin-client/package.json | 12 ++++++------ packages/filecoin-client/src/service.js | 4 ++-- packages/filecoin-client/test/aggregator.test.js | 2 +- packages/filecoin-client/test/helpers/mocks.js | 8 ++++---- packages/filecoin-client/test/storefront.test.js | 2 +- packages/filecoin-client/tsconfig.json | 3 ++- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/packages/filecoin-client/package.json b/packages/filecoin-client/package.json index 93fd09f83..041f5ad08 100644 --- a/packages/filecoin-client/package.json +++ b/packages/filecoin-client/package.json @@ -23,12 +23,12 @@ "rc": "npm version prerelease --preid rc" }, "exports": { - ".": "./src/index.js", - "./aggregator": "./src/aggregator.js", - "./dealer": "./src/dealer.js", - "./chain-tracker": "./src/chain-tracker.js", - "./storefront": "./src/storefront.js", - "./types": "./src/types.js" + ".": "./dist/src/index.js", + "./aggregator": "./dist/src/aggregator.js", + "./dealer": "./dist/src/dealer.js", + "./chain-tracker": "./dist/src/chain-tracker.js", + "./storefront": "./dist/src/storefront.js", + "./types": "./dist/src/types.js" }, "typesVersions": { "*": { diff --git a/packages/filecoin-client/src/service.js b/packages/filecoin-client/src/service.js index c5e62c2ee..bbc3f304c 100644 --- a/packages/filecoin-client/src/service.js +++ b/packages/filecoin-client/src/service.js @@ -1,8 +1,8 @@ import * as DID from '@ipld/dag-ucan/did' /** - * @typedef {import('./types').SERVICE} Service - * @typedef {import('./types').ServiceConfig} ServiceConfig + * @typedef {import('./types.js').SERVICE} Service + * @typedef {import('./types.js').ServiceConfig} ServiceConfig */ /** diff --git a/packages/filecoin-client/test/aggregator.test.js b/packages/filecoin-client/test/aggregator.test.js index 09ba7c40e..5f1226584 100644 --- a/packages/filecoin-client/test/aggregator.test.js +++ b/packages/filecoin-client/test/aggregator.test.js @@ -217,7 +217,7 @@ async function getContext() { } /** - * @param {import('../src/types').AggregatorService} service + * @param {import('../src/types.js').AggregatorService} service */ function getConnection(service) { const server = Server.create({ diff --git a/packages/filecoin-client/test/helpers/mocks.js b/packages/filecoin-client/test/helpers/mocks.js index 5a71c785c..61ec8bd88 100644 --- a/packages/filecoin-client/test/helpers/mocks.js +++ b/packages/filecoin-client/test/helpers/mocks.js @@ -6,10 +6,10 @@ const notImplemented = () => { /** * @param {Partial< - * import('../../src/types').StorefrontService & - * import('../../src/types').AggregatorService & - * import('../../src/types').DealerService & - * import('../../src/types').ChainTrackerService + * import('../../src/types.js').StorefrontService & + * import('../../src/types.js').AggregatorService & + * import('../../src/types.js').DealerService & + * import('../../src/types.js').ChainTrackerService * >} impl */ export function mockService(impl) { diff --git a/packages/filecoin-client/test/storefront.test.js b/packages/filecoin-client/test/storefront.test.js index fd15093fb..93901f5ad 100644 --- a/packages/filecoin-client/test/storefront.test.js +++ b/packages/filecoin-client/test/storefront.test.js @@ -198,7 +198,7 @@ async function getContext() { } /** - * @param {import('../src/types').StorefrontService} service + * @param {import('../src/types.js').StorefrontService} service */ function getConnection(service) { const server = Server.create({ diff --git a/packages/filecoin-client/tsconfig.json b/packages/filecoin-client/tsconfig.json index 41da08733..a7eb49b0b 100644 --- a/packages/filecoin-client/tsconfig.json +++ b/packages/filecoin-client/tsconfig.json @@ -3,7 +3,8 @@ "compilerOptions": { "outDir": "dist", "lib": ["ESNext", "DOM"], - "emitDeclarationOnly": true + "module": "NodeNext", + "moduleResolution": "NodeNext", }, "include": ["src", "test", "package.json"], "exclude": ["**/node_modules/**"], From 52724b210b44d78751590ddd54c8072ff8b3fe5c Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 12:56:22 -0700 Subject: [PATCH 08/20] fix attw in filecoin-api --- packages/filecoin-api/package.json | 7 ------- packages/filecoin-api/tsconfig.json | 4 +++- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/filecoin-api/package.json b/packages/filecoin-api/package.json index 0a667e8ce..6d1f16939 100644 --- a/packages/filecoin-api/package.json +++ b/packages/filecoin-api/package.json @@ -20,9 +20,6 @@ "dealer": [ "dist/src/dealer.d.ts" ], - "chain-tracker": [ - "dist/src/chain-tracker.d.ts" - ], "errors": [ "dist/src/errors.d.ts" ], @@ -54,10 +51,6 @@ "types": "./dist/src/dealer.d.ts", "import": "./src/dealer.js" }, - "./chain-tracker": { - "types": "./dist/src/chain-tracker.d.ts", - "import": "./src/chain-tracker.js" - }, "./storefront": { "types": "./dist/src/storefront.d.ts", "import": "./src/storefront.js" diff --git a/packages/filecoin-api/tsconfig.json b/packages/filecoin-api/tsconfig.json index 129f514ca..27148244c 100644 --- a/packages/filecoin-api/tsconfig.json +++ b/packages/filecoin-api/tsconfig.json @@ -2,7 +2,9 @@ "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "dist", - "types": ["mocha"] + "types": ["mocha"], + "module": "NodeNext", + "moduleResolution": "NodeNext" }, "include": ["src", "test"], "exclude": ["**/node_modules/**", "dist"], From 7b6139a9bf05c4a81d08892a2a7c5520b0f0e03b Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 13:07:08 -0700 Subject: [PATCH 09/20] root tsconfig.json (that others inherit from) use module=NodeNext and moduleResolution=NodeNext. It is a better default to use to ensure that https://arethetypeswrong.github.io/ passes --- packages/access-client/tsconfig.json | 4 +--- packages/capabilities/tsconfig.json | 4 +--- packages/did-mailto/tsconfig.json | 4 +--- packages/filecoin-api/tsconfig.json | 4 +--- packages/upload-api/tsconfig.json | 4 +--- packages/upload-client/src/car.js | 1 - packages/upload-client/test/unixfs.test.js | 4 ---- packages/w3up-client/tsconfig.json | 4 +--- tsconfig.json | 4 ++-- 9 files changed, 8 insertions(+), 25 deletions(-) diff --git a/packages/access-client/tsconfig.json b/packages/access-client/tsconfig.json index b94f18019..186028130 100644 --- a/packages/access-client/tsconfig.json +++ b/packages/access-client/tsconfig.json @@ -2,9 +2,7 @@ "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "dist", - "lib": ["ESNext", "DOM"], - "module": "NodeNext", - "moduleResolution": "NodeNext" + "lib": ["ESNext", "DOM"] }, "include": ["src", "scripts", "test", "package.json"], "exclude": ["**/node_modules/**"], diff --git a/packages/capabilities/tsconfig.json b/packages/capabilities/tsconfig.json index 41f9d7b5e..565f5779d 100644 --- a/packages/capabilities/tsconfig.json +++ b/packages/capabilities/tsconfig.json @@ -2,9 +2,7 @@ "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "dist", - "emitDeclarationOnly": true, - "module": "NodeNext", - "moduleResolution": "NodeNext" + "emitDeclarationOnly": true }, "include": ["src", "test", "package.json"], "exclude": ["**/node_modules/**"] diff --git a/packages/did-mailto/tsconfig.json b/packages/did-mailto/tsconfig.json index 5d3671bd9..ab5d5d625 100644 --- a/packages/did-mailto/tsconfig.json +++ b/packages/did-mailto/tsconfig.json @@ -1,9 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "outDir": "dist", - "moduleResolution": "NodeNext", - "module": "NodeNext" + "outDir": "dist" }, "include": ["src", "test"], "exclude": ["**/node_modules/**", "dist"], diff --git a/packages/filecoin-api/tsconfig.json b/packages/filecoin-api/tsconfig.json index 27148244c..129f514ca 100644 --- a/packages/filecoin-api/tsconfig.json +++ b/packages/filecoin-api/tsconfig.json @@ -2,9 +2,7 @@ "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "dist", - "types": ["mocha"], - "module": "NodeNext", - "moduleResolution": "NodeNext" + "types": ["mocha"] }, "include": ["src", "test"], "exclude": ["**/node_modules/**", "dist"], diff --git a/packages/upload-api/tsconfig.json b/packages/upload-api/tsconfig.json index 27148244c..129f514ca 100644 --- a/packages/upload-api/tsconfig.json +++ b/packages/upload-api/tsconfig.json @@ -2,9 +2,7 @@ "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "dist", - "types": ["mocha"], - "module": "NodeNext", - "moduleResolution": "NodeNext" + "types": ["mocha"] }, "include": ["src", "test"], "exclude": ["**/node_modules/**", "dist"], diff --git a/packages/upload-client/src/car.js b/packages/upload-client/src/car.js index 685d41a43..8f06cb3f1 100644 --- a/packages/upload-client/src/car.js +++ b/packages/upload-client/src/car.js @@ -37,7 +37,6 @@ export async function encode(blocks, root) { void (async () => { try { for await (const block of blocks) { - // @ts-expect-error await writer.put(block) } } catch (/** @type {any} */ err) { diff --git a/packages/upload-client/test/unixfs.test.js b/packages/upload-client/test/unixfs.test.js index f8d430984..72ab04965 100644 --- a/packages/upload-client/test/unixfs.test.js +++ b/packages/upload-client/test/unixfs.test.js @@ -26,7 +26,6 @@ async function collectDir(dir) { async function blocksToBlockstore(blocks) { const blockstore = new MemoryBlockstore() for (const block of blocks) { - // @ts-expect-error await blockstore.put(block.cid, block.bytes) } return blockstore @@ -62,7 +61,6 @@ describe('UnixFS', () => { assert.equal(dirEntry.type, 'directory') const expectedPaths = files.map((f) => path.join(cid.toString(), f.name)) - // @ts-expect-error const entries = await collectDir(dirEntry) const actualPaths = entries.map((e) => e.path) @@ -81,14 +79,12 @@ describe('UnixFS', () => { assert.equal(dirEntry.type, 'directory') const expectedPaths = files.map((f) => path.join(cid.toString(), f.name)) - // @ts-expect-error const entries = await collectDir(dirEntry) const actualPaths = entries.map((e) => e.path) expectedPaths.forEach((p) => assert(actualPaths.includes(p))) // check root node is a HAMT sharded directory - // @ts-expect-error const bytes = await blockstore.get(cid) const node = decode(bytes) assert.equal(node.type, NodeType.HAMTShard) diff --git a/packages/w3up-client/tsconfig.json b/packages/w3up-client/tsconfig.json index 49a37df23..cd6061a54 100644 --- a/packages/w3up-client/tsconfig.json +++ b/packages/w3up-client/tsconfig.json @@ -4,9 +4,7 @@ "outDir": "dist", "emitDeclarationOnly": true, "composite": true, - "noUnusedParameters": false, - "module": "NodeNext", - "moduleResolution": "NodeNext" + "noUnusedParameters": false }, "include": ["./src", "./test"], "typedocOptions": { diff --git a/tsconfig.json b/tsconfig.json index 53479fd56..699aa11e8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "allowJs": true, "checkJs": true, "target": "ES2022", - "module": "ES2022", + "module": "NodeNext", "lib": ["ES2022", "DOM", "DOM.Iterable"], "noEmit": false, "noEmitOnError": true, @@ -20,7 +20,7 @@ "removeComments": false, // module resolution "esModuleInterop": true, - "moduleResolution": "Node", + "moduleResolution": "NodeNext", // linter checks "noImplicitReturns": false, "noFallthroughCasesInSwitch": true, From 89f5c5e062141b02b76ff5d061d1279eea9e1910 Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 13:55:03 -0700 Subject: [PATCH 10/20] all packages have an attw script --- .attw.json | 5 +++ packages/access-client/.attw.json | 1 + packages/access-client/package.json | 1 + packages/capabilities/.attw.json | 1 + packages/capabilities/package.json | 1 + packages/did-mailto/.attw.json | 1 + packages/did-mailto/package.json | 18 ++++++---- packages/did-mailto/src/types.ts | 2 ++ packages/did-mailto/tsconfig.json | 4 ++- packages/filecoin-api/.attw.json | 1 + packages/filecoin-api/package.json | 5 +-- .../src/aggregator/buffer-reducing.js | 22 ++++++------ .../filecoin-api/src/aggregator/events.js | 36 +++++++++---------- .../filecoin-api/src/aggregator/service.js | 8 ++--- .../filecoin-api/src/deal-tracker/service.js | 9 ++--- packages/filecoin-api/src/dealer/events.js | 10 +++--- packages/filecoin-api/src/dealer/service.js | 8 ++--- .../filecoin-api/src/storefront/events.js | 18 +++++----- .../filecoin-api/src/storefront/service.js | 10 +++--- packages/filecoin-api/test/context/mocks.js | 8 ++--- packages/filecoin-api/test/types.ts | 24 ++++++------- packages/filecoin-client/.attw.json | 1 + packages/filecoin-client/package.json | 1 + packages/upload-api/.attw.json | 1 + packages/upload-api/package.json | 1 + packages/upload-client/.attw.json | 1 + packages/upload-client/package.json | 1 + packages/w3up-client/.attw.json | 1 + packages/w3up-client/package.json | 1 + 29 files changed, 113 insertions(+), 88 deletions(-) create mode 100644 .attw.json create mode 120000 packages/access-client/.attw.json create mode 120000 packages/capabilities/.attw.json create mode 120000 packages/did-mailto/.attw.json create mode 120000 packages/filecoin-api/.attw.json create mode 120000 packages/filecoin-client/.attw.json create mode 120000 packages/upload-api/.attw.json create mode 120000 packages/upload-client/.attw.json create mode 120000 packages/w3up-client/.attw.json diff --git a/.attw.json b/.attw.json new file mode 100644 index 000000000..7aa79ea41 --- /dev/null +++ b/.attw.json @@ -0,0 +1,5 @@ +{ + "ignoreRules": [ + "cjs-resolves-to-esm" + ] +} diff --git a/packages/access-client/.attw.json b/packages/access-client/.attw.json new file mode 120000 index 000000000..eb964d1d2 --- /dev/null +++ b/packages/access-client/.attw.json @@ -0,0 +1 @@ +../../.attw.json \ No newline at end of file diff --git a/packages/access-client/package.json b/packages/access-client/package.json index d7148d87e..7f277cf08 100644 --- a/packages/access-client/package.json +++ b/packages/access-client/package.json @@ -14,6 +14,7 @@ "types": "dist/src/index.d.ts", "main": "src/index.js", "scripts": { + "attw": "attw --pack .", "lint": "tsc --build && eslint '**/*.{js,ts}' && prettier --check '**/*.{js,ts,yml,json}' --ignore-path ../../.gitignore", "build": "tsc --build", "check": "tsc --build", diff --git a/packages/capabilities/.attw.json b/packages/capabilities/.attw.json new file mode 120000 index 000000000..eb964d1d2 --- /dev/null +++ b/packages/capabilities/.attw.json @@ -0,0 +1 @@ +../../.attw.json \ No newline at end of file diff --git a/packages/capabilities/package.json b/packages/capabilities/package.json index 056243cf6..587d12dcb 100644 --- a/packages/capabilities/package.json +++ b/packages/capabilities/package.json @@ -13,6 +13,7 @@ "types": "dist/src/index.d.ts", "main": "src/index.js", "scripts": { + "attw": "attw --pack .", "lint": "tsc && eslint '**/*.{js,ts}' && prettier --check '**/*.{js,ts,yml,json}' --ignore-path ../../.gitignore", "build": "tsc --build", "check": "tsc --build", diff --git a/packages/did-mailto/.attw.json b/packages/did-mailto/.attw.json new file mode 120000 index 000000000..eb964d1d2 --- /dev/null +++ b/packages/did-mailto/.attw.json @@ -0,0 +1 @@ +../../.attw.json \ No newline at end of file diff --git a/packages/did-mailto/package.json b/packages/did-mailto/package.json index 8093f0b87..1c1da4ecc 100644 --- a/packages/did-mailto/package.json +++ b/packages/did-mailto/package.json @@ -14,17 +14,21 @@ "files": [ "src", "test", - "dist/**/*.d.ts", - "dist/**/*.d.ts.map" + "dist" ], - "exports": { - ".": { - "types": "./dist/src/index.d.ts", - "import": "./src/index.js" - }, + "exports": { + ".": "./dist/src/index.js", "./types": "./dist/src/types.js" }, + "typesVersions": { + "*": { + "types": [ + "dist/src/types" + ] + } + }, "scripts": { + "attw": "attw --pack .", "build": "tsc --build", "check": "tsc --build", "lint": "tsc --build", diff --git a/packages/did-mailto/src/types.ts b/packages/did-mailto/src/types.ts index 51c2a45b5..6a8f431ed 100644 --- a/packages/did-mailto/src/types.ts +++ b/packages/did-mailto/src/types.ts @@ -10,3 +10,5 @@ export type PercentEncoded = string // did:mailto export type DidMailto = `did:mailto:${PercentEncoded}:${PercentEncoded}` + +export const test = 1; diff --git a/packages/did-mailto/tsconfig.json b/packages/did-mailto/tsconfig.json index ab5d5d625..5d3671bd9 100644 --- a/packages/did-mailto/tsconfig.json +++ b/packages/did-mailto/tsconfig.json @@ -1,7 +1,9 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "outDir": "dist" + "outDir": "dist", + "moduleResolution": "NodeNext", + "module": "NodeNext" }, "include": ["src", "test"], "exclude": ["**/node_modules/**", "dist"], diff --git a/packages/filecoin-api/.attw.json b/packages/filecoin-api/.attw.json new file mode 120000 index 000000000..eb964d1d2 --- /dev/null +++ b/packages/filecoin-api/.attw.json @@ -0,0 +1 @@ +../../.attw.json \ No newline at end of file diff --git a/packages/filecoin-api/package.json b/packages/filecoin-api/package.json index b8aa4d75a..5acd608b9 100644 --- a/packages/filecoin-api/package.json +++ b/packages/filecoin-api/package.json @@ -105,10 +105,6 @@ "types": "./dist/src/deal-tracker/service.d.ts", "import": "./src/deal-tracker/service.js" }, - "./storefront": { - "types": "./dist/src/storefront.d.ts", - "import": "./src/storefront.js" - }, "./storefront/api": { "types": "./dist/src/storefront/api.d.ts", "import": "./src/storefront/api.js" @@ -135,6 +131,7 @@ } }, "scripts": { + "attw": "attw --pack .", "build": "tsc --build", "check": "tsc --build", "lint": "tsc --build", diff --git a/packages/filecoin-api/src/aggregator/buffer-reducing.js b/packages/filecoin-api/src/aggregator/buffer-reducing.js index 091928f29..13f6e635e 100644 --- a/packages/filecoin-api/src/aggregator/buffer-reducing.js +++ b/packages/filecoin-api/src/aggregator/buffer-reducing.js @@ -7,11 +7,11 @@ import { UnexpectedState } from '../errors.js' * @typedef {import('@ucanto/interface').Link} Link * @typedef {import('@web3-storage/data-segment').AggregateView} AggregateView * - * @typedef {import('./api').BufferedPiece} BufferedPiece - * @typedef {import('./api').BufferRecord} BufferRecord - * @typedef {import('./api').BufferMessage} BufferMessage - * @typedef {import('./api').AggregateOfferMessage} AggregateOfferMessage - * @typedef {import('../types').StoreGetError} StoreGetError + * @typedef {import('./api.js').BufferedPiece} BufferedPiece + * @typedef {import('./api.js').BufferRecord} BufferRecord + * @typedef {import('./api.js').BufferMessage} BufferMessage + * @typedef {import('./api.js').AggregateOfferMessage} AggregateOfferMessage + * @typedef {import('../types.js').StoreGetError} StoreGetError * @typedef {{ bufferedPieces: BufferedPiece[], group: string }} GetBufferedPieces * @typedef {import('../types.js').Result} GetBufferedPiecesResult * @@ -24,9 +24,9 @@ import { UnexpectedState } from '../errors.js' /** * @param {object} props * @param {AggregateInfo} props.aggregateInfo - * @param {import('../types').Store} props.bufferStore - * @param {import('../types').Queue} props.bufferQueue - * @param {import('../types').Queue} props.aggregateOfferQueue + * @param {import('../types.js').Store} props.bufferStore + * @param {import('../types.js').Queue} props.bufferQueue + * @param {import('../types.js').Queue} props.aggregateOfferQueue * @param {string} props.group */ export async function handleBufferReducingWithAggregate({ @@ -103,8 +103,8 @@ export async function handleBufferReducingWithAggregate({ * * @param {object} props * @param {import('./api.js').Buffer} props.buffer - * @param {import('../types').Store} props.bufferStore - * @param {import('../types').Queue} props.bufferQueue + * @param {import('../types.js').Store} props.bufferStore + * @param {import('../types.js').Queue} props.bufferQueue */ export async function handleBufferReducingWithoutAggregate({ buffer, @@ -199,7 +199,7 @@ export function aggregatePieces(bufferedPieces, sizes) { * Get buffered pieces from queue buffer records. * * @param {Link[]} bufferPieces - * @param {import('../types').Store} bufferStore + * @param {import('../types.js').Store} bufferStore * @returns {Promise} */ export async function getBufferedPieces(bufferPieces, bufferStore) { diff --git a/packages/filecoin-api/src/aggregator/events.js b/packages/filecoin-api/src/aggregator/events.js index 1d62bbdea..1de5d4134 100644 --- a/packages/filecoin-api/src/aggregator/events.js +++ b/packages/filecoin-api/src/aggregator/events.js @@ -17,8 +17,8 @@ import { /** * On piece queue messages, store piece. * - * @param {import('./api').PieceMessageContext} context - * @param {import('./api').PieceMessage} message + * @param {import('./api.js').PieceMessageContext} context + * @param {import('./api.js').PieceMessage} message */ export const handlePieceMessage = async (context, message) => { const { piece, group } = message @@ -43,8 +43,8 @@ export const handlePieceMessage = async (context, message) => { /** * On Piece store insert batch, buffer pieces together to resume buffer processing. * - * @param {import('./api').PieceInsertEventContext} context - * @param {import('./api').PieceRecord[]} records + * @param {import('./api.js').PieceInsertEventContext} context + * @param {import('./api.js').PieceRecord[]} records */ export const handlePiecesInsert = async (context, records) => { // TODO: separate buffers per group after MVP @@ -93,8 +93,8 @@ export const handlePiecesInsert = async (context, records) => { * into aggregateOfferQueue. Remaining of the new buffer (in case buffer bigger * than maximum aggregate size) is re-queued into the buffer queue. * - * @param {import('./api').BufferMessageContext} context - * @param {import('./api').BufferMessage[]} records + * @param {import('./api.js').BufferMessageContext} context + * @param {import('./api.js').BufferMessage[]} records */ export const handleBufferQueueMessage = async (context, records) => { // Get reduced buffered pieces @@ -164,8 +164,8 @@ export const handleBufferQueueMessage = async (context, records) => { /** * On aggregate offer queue message, store aggregate record in store. * - * @param {import('./api').AggregateOfferMessageContext} context - * @param {import('./api').AggregateOfferMessage} message + * @param {import('./api.js').AggregateOfferMessageContext} context + * @param {import('./api.js').AggregateOfferMessage} message */ export const handleAggregateOfferMessage = async (context, message) => { const { pieces, aggregate, group } = message @@ -189,8 +189,8 @@ export const handleAggregateOfferMessage = async (context, message) => { /** * On Aggregate store insert, offer inserted aggregate for deal. * - * @param {import('./api').AggregateInsertEventToPieceAcceptQueueContext} context - * @param {import('./api').AggregateRecord} record + * @param {import('./api.js').AggregateInsertEventToPieceAcceptQueueContext} context + * @param {import('./api.js').AggregateRecord} record */ export const handleAggregateInsertToPieceAcceptQueue = async ( context, @@ -249,8 +249,8 @@ export const handleAggregateInsertToPieceAcceptQueue = async ( /** * On piece accept queue message, store inclusion record in store. * - * @param {import('./api').PieceAcceptMessageContext} context - * @param {import('./api').PieceAcceptMessage} message + * @param {import('./api.js').PieceAcceptMessageContext} context + * @param {import('./api.js').PieceAcceptMessage} message */ export const handlePieceAcceptMessage = async (context, message) => { const { piece, aggregate, group, inclusion } = message @@ -275,8 +275,8 @@ export const handlePieceAcceptMessage = async (context, message) => { /** * On Inclusion store insert, piece table can be updated to reflect piece state. * - * @param {import('./api').InclusionInsertEventToUpdateState} context - * @param {import('./api').InclusionRecord} record + * @param {import('./api.js').InclusionInsertEventToUpdateState} context + * @param {import('./api.js').InclusionRecord} record */ export const handleInclusionInsertToUpdateState = async (context, record) => { const updateRes = await context.pieceStore.update( @@ -297,8 +297,8 @@ export const handleInclusionInsertToUpdateState = async (context, record) => { } /** - * @param {import('./api').InclusionInsertEventToIssuePieceAccept} context - * @param {import('./api').InclusionRecord} record + * @param {import('./api.js').InclusionInsertEventToIssuePieceAccept} context + * @param {import('./api.js').InclusionRecord} record */ export const handleInclusionInsertToIssuePieceAccept = async ( context, @@ -324,8 +324,8 @@ export const handleInclusionInsertToIssuePieceAccept = async ( /** * On Aggregate store insert, offer inserted aggregate for deal. * - * @param {import('./api').AggregateInsertEventToAggregateOfferContext} context - * @param {import('./api').AggregateRecord} record + * @param {import('./api.js').AggregateInsertEventToAggregateOfferContext} context + * @param {import('./api.js').AggregateRecord} record */ export const handleAggregateInsertToAggregateOffer = async ( context, diff --git a/packages/filecoin-api/src/aggregator/service.js b/packages/filecoin-api/src/aggregator/service.js index 6f2298371..365572463 100644 --- a/packages/filecoin-api/src/aggregator/service.js +++ b/packages/filecoin-api/src/aggregator/service.js @@ -14,7 +14,7 @@ import { /** * @param {API.Input} input - * @param {import('./api').ServiceContext} context + * @param {import('./api.js').ServiceContext} context * @returns {Promise | API.UcantoInterface.JoinBuilder>} */ export const pieceOffer = async ({ capability }, context) => { @@ -60,7 +60,7 @@ export const pieceOffer = async ({ capability }, context) => { /** * @param {API.Input} input - * @param {import('./api').ServiceContext} context + * @param {import('./api.js').ServiceContext} context * @returns {Promise | API.UcantoInterface.JoinBuilder>} */ export const pieceAccept = async ({ capability }, context) => { @@ -109,7 +109,7 @@ export const pieceAccept = async ({ capability }, context) => { } /** - * @param {import('./api').ServiceContext} context + * @param {import('./api.js').ServiceContext} context */ export function createService(context) { return { @@ -127,7 +127,7 @@ export function createService(context) { } /** - * @param {API.UcantoServerContext & import('./api').ServiceContext} context + * @param {API.UcantoServerContext & import('./api.js').ServiceContext} context */ export const createServer = (context) => Server.create({ diff --git a/packages/filecoin-api/src/deal-tracker/service.js b/packages/filecoin-api/src/deal-tracker/service.js index 9d78ab351..18a339bb5 100644 --- a/packages/filecoin-api/src/deal-tracker/service.js +++ b/packages/filecoin-api/src/deal-tracker/service.js @@ -8,12 +8,12 @@ import * as API from '../types.js' import { StoreOperationFailed } from '../errors.js' /** - * @typedef {import('@web3-storage/capabilities/types.js').DealDetails} DealDetails + * @typedef {import('@web3-storage/capabilities/types').DealDetails} DealDetails */ /** * @param {API.Input} input - * @param {import('./api').ServiceContext} context + * @param {import('./api.js').ServiceContext} context * @returns {Promise>} */ export const dealInfo = async ({ capability }, context) => { @@ -28,6 +28,7 @@ export const dealInfo = async ({ capability }, context) => { return { ok: { + // eslint-disable-next-line unicorn/no-array-reduce deals: storeGet.ok.reduce((acc, curr) => { acc[`${curr.dealId}`] = { provider: curr.provider, @@ -40,7 +41,7 @@ export const dealInfo = async ({ capability }, context) => { } /** - * @param {import('./api').ServiceContext} context + * @param {import('./api.js').ServiceContext} context */ export function createService(context) { return { @@ -53,7 +54,7 @@ export function createService(context) { } /** - * @param {API.UcantoServerContext & import('./api').ServiceContext} context + * @param {API.UcantoServerContext & import('./api.js').ServiceContext} context */ export const createServer = (context) => Server.create({ diff --git a/packages/filecoin-api/src/dealer/events.js b/packages/filecoin-api/src/dealer/events.js index cff4f0de1..89d0178c2 100644 --- a/packages/filecoin-api/src/dealer/events.js +++ b/packages/filecoin-api/src/dealer/events.js @@ -3,14 +3,14 @@ import { Dealer, DealTracker } from '@web3-storage/filecoin-client' import { StoreOperationFailed } from '../errors.js' /** - * @typedef {import('./api').AggregateRecord} AggregateRecord - * @typedef {import('./api').AggregateRecordKey} AggregateRecordKey + * @typedef {import('./api.js').AggregateRecord} AggregateRecord + * @typedef {import('./api.js').AggregateRecordKey} AggregateRecordKey */ /** * On aggregate insert event, update offer key with date to be retrievable by broker. * - * @param {import('./api').AggregateInsertEventContext} context + * @param {import('./api.js').AggregateInsertEventContext} context * @param {AggregateRecord} record */ export const handleAggregateInsert = async (context, record) => { @@ -29,7 +29,7 @@ export const handleAggregateInsert = async (context, record) => { /** * On Aggregate update status event, issue aggregate accept receipt. * - * @param {import('./api').AggregateUpdatedStatusEventContext} context + * @param {import('./api.js').AggregateUpdatedStatusEventContext} context * @param {AggregateRecord} record */ export const handleAggregatUpdatedStatus = async (context, record) => { @@ -52,7 +52,7 @@ export const handleAggregatUpdatedStatus = async (context, record) => { * On cron tick event, get aggregates without deals, and verify if there are updates on them. * If there are deals for pending aggregates, their state can be updated. * - * @param {import('./api').CronContext} context + * @param {import('./api.js').CronContext} context */ export const handleCronTick = async (context) => { // Get offered deals pending approval/rejection diff --git a/packages/filecoin-api/src/dealer/service.js b/packages/filecoin-api/src/dealer/service.js index 8dc05e8da..28b22130e 100644 --- a/packages/filecoin-api/src/dealer/service.js +++ b/packages/filecoin-api/src/dealer/service.js @@ -15,7 +15,7 @@ import { /** * @param {API.Input} input - * @param {import('./api').ServiceContext} context + * @param {import('./api.js').ServiceContext} context * @returns {Promise | API.UcantoInterface.JoinBuilder>} */ export const aggregateOffer = async ({ capability, invocation }, context) => { @@ -92,7 +92,7 @@ export const aggregateOffer = async ({ capability, invocation }, context) => { /** * @param {API.Input} input - * @param {import('./api').ServiceContext} context + * @param {import('./api.js').ServiceContext} context * @returns {Promise>} */ export const aggregateAccept = async ({ capability }, context) => { @@ -145,7 +145,7 @@ const findCBORBlock = async (cid, blocks) => { } /** - * @param {import('./api').ServiceContext} context + * @param {import('./api.js').ServiceContext} context */ export function createService(context) { return { @@ -163,7 +163,7 @@ export function createService(context) { } /** - * @param {API.UcantoServerContext & import('./api').ServiceContext} context + * @param {API.UcantoServerContext & import('./api.js').ServiceContext} context */ export const createServer = (context) => Server.create({ diff --git a/packages/filecoin-api/src/storefront/events.js b/packages/filecoin-api/src/storefront/events.js index 5d05777fe..f6e2425d1 100644 --- a/packages/filecoin-api/src/storefront/events.js +++ b/packages/filecoin-api/src/storefront/events.js @@ -10,16 +10,16 @@ import { } from '../errors.js' /** - * @typedef {import('./api').PieceRecord} PieceRecord - * @typedef {import('./api').PieceRecordKey} PieceRecordKey + * @typedef {import('./api.js').PieceRecord} PieceRecord + * @typedef {import('./api.js').PieceRecordKey} PieceRecordKey * @typedef {import('../types.js').UpdatableAndQueryableStore>} PieceStore */ /** * On filecoin submit queue messages, validate piece for given content and store it in store. * - * @param {import('./api').FilecoinSubmitMessageContext} context - * @param {import('./api').FilecoinSubmitMessage} message + * @param {import('./api.js').FilecoinSubmitMessageContext} context + * @param {import('./api.js').FilecoinSubmitMessage} message */ export const handleFilecoinSubmitMessage = async (context, message) => { // dedupe concurrent writes @@ -47,8 +47,8 @@ export const handleFilecoinSubmitMessage = async (context, message) => { /** * On piece offer queue message, offer piece for aggregation. * - * @param {import('./api').PieceOfferMessageContext} context - * @param {import('./api').PieceOfferMessage} message + * @param {import('./api.js').PieceOfferMessageContext} context + * @param {import('./api.js').PieceOfferMessage} message */ export const handlePieceOfferMessage = async (context, message) => { const pieceOfferInv = await Aggregator.pieceOffer( @@ -69,7 +69,7 @@ export const handlePieceOfferMessage = async (context, message) => { /** * On piece inserted into store, invoke submit to queue piece to be offered for aggregate. * - * @param {import('./api').StorefrontClientContext} context + * @param {import('./api.js').StorefrontClientContext} context * @param {PieceRecord} record */ export const handlePieceInsert = async (context, record) => { @@ -90,7 +90,7 @@ export const handlePieceInsert = async (context, record) => { } /** - * @param {import('./api').StorefrontClientContext} context + * @param {import('./api.js').StorefrontClientContext} context * @param {PieceRecord} record */ export const handlePieceStatusUpdate = async (context, record) => { @@ -120,7 +120,7 @@ export const handlePieceStatusUpdate = async (context, record) => { } /** - * @param {import('./api').CronContext} context + * @param {import('./api.js').CronContext} context */ export const handleCronTick = async (context) => { const submittedPieces = await context.pieceStore.query({ diff --git a/packages/filecoin-api/src/storefront/service.js b/packages/filecoin-api/src/storefront/service.js index 3dd1b9210..e8fdd1f58 100644 --- a/packages/filecoin-api/src/storefront/service.js +++ b/packages/filecoin-api/src/storefront/service.js @@ -13,7 +13,7 @@ import { /** * @param {API.Input} input - * @param {import('./api').ServiceContext} context + * @param {import('./api.js').ServiceContext} context * @returns {Promise | API.UcantoInterface.JoinBuilder>} */ export const filecoinOffer = async ({ capability }, context) => { @@ -82,7 +82,7 @@ export const filecoinOffer = async ({ capability }, context) => { /** * @param {API.Input} input - * @param {import('./api').ServiceContext} context + * @param {import('./api.js').ServiceContext} context * @returns {Promise | API.UcantoInterface.JoinBuilder>} */ export const filecoinSubmit = async ({ capability }, context) => { @@ -123,7 +123,7 @@ export const filecoinSubmit = async ({ capability }, context) => { /** * @param {API.Input} input - * @param {import('./api').ServiceContext} context + * @param {import('./api.js').ServiceContext} context * @returns {Promise>} */ export const filecoinAccept = async ({ capability }, context) => { @@ -244,7 +244,7 @@ export class ProofNotFound extends Server.Failure { } /** - * @param {import('./api').ServiceContext} context + * @param {import('./api.js').ServiceContext} context */ export function createService(context) { return { @@ -266,7 +266,7 @@ export function createService(context) { } /** - * @param {API.UcantoServerContext & import('./api').ServiceContext} context + * @param {API.UcantoServerContext & import('./api.js').ServiceContext} context */ export const createServer = (context) => Server.create({ diff --git a/packages/filecoin-api/test/context/mocks.js b/packages/filecoin-api/test/context/mocks.js index fc17443eb..f554c7d77 100644 --- a/packages/filecoin-api/test/context/mocks.js +++ b/packages/filecoin-api/test/context/mocks.js @@ -6,10 +6,10 @@ const notImplemented = () => { /** * @param {Partial<{ - * filecoin: Partial - * piece: Partial - * aggregate: Partial - * deal: Partial + * filecoin: Partial + * piece: Partial + * aggregate: Partial + * deal: Partial * }>} impl */ export function mockService(impl) { diff --git a/packages/filecoin-api/test/types.ts b/packages/filecoin-api/test/types.ts index 03f9beb6e..423fa492d 100644 --- a/packages/filecoin-api/test/types.ts +++ b/packages/filecoin-api/test/types.ts @@ -15,10 +15,10 @@ export interface AggregatorTestEventsContext AggregatorInterface.BufferMessageContext { id: Signer service: Partial<{ - filecoin: Partial - piece: Partial - aggregate: Partial - deal: Partial + filecoin: Partial + piece: Partial + aggregate: Partial + deal: Partial }> } @@ -28,10 +28,10 @@ export interface DealerTestEventsContext DealerInterface.CronContext { id: Signer service: Partial<{ - filecoin: Partial - piece: Partial - aggregate: Partial - deal: Partial + filecoin: Partial + piece: Partial + aggregate: Partial + deal: Partial }> } @@ -42,9 +42,9 @@ export interface StorefrontTestEventsContext StorefrontInterface.CronContext { id: Signer service: Partial<{ - filecoin: Partial - piece: Partial - aggregate: Partial - deal: Partial + filecoin: Partial + piece: Partial + aggregate: Partial + deal: Partial }> } diff --git a/packages/filecoin-client/.attw.json b/packages/filecoin-client/.attw.json new file mode 120000 index 000000000..eb964d1d2 --- /dev/null +++ b/packages/filecoin-client/.attw.json @@ -0,0 +1 @@ +../../.attw.json \ No newline at end of file diff --git a/packages/filecoin-client/package.json b/packages/filecoin-client/package.json index 889aacca8..4e2ec5c8f 100644 --- a/packages/filecoin-client/package.json +++ b/packages/filecoin-client/package.json @@ -14,6 +14,7 @@ "types": "dist/src/index.d.ts", "main": "src/index.js", "scripts": { + "attw": "attw --pack .", "lint": "eslint '**/*.{js,ts}' && prettier --check '**/*.{js,ts,yml,json}' --ignore-path ../../.gitignore", "build": "tsc --build", "test": "npm run test:all", diff --git a/packages/upload-api/.attw.json b/packages/upload-api/.attw.json new file mode 120000 index 000000000..eb964d1d2 --- /dev/null +++ b/packages/upload-api/.attw.json @@ -0,0 +1 @@ +../../.attw.json \ No newline at end of file diff --git a/packages/upload-api/package.json b/packages/upload-api/package.json index 6a0198b7b..4127fc5f5 100644 --- a/packages/upload-api/package.json +++ b/packages/upload-api/package.json @@ -93,6 +93,7 @@ } }, "scripts": { + "attw": "attw --pack .", "build": "tsc --build", "check": "tsc --build", "lint": "tsc --build", diff --git a/packages/upload-client/.attw.json b/packages/upload-client/.attw.json new file mode 120000 index 000000000..eb964d1d2 --- /dev/null +++ b/packages/upload-client/.attw.json @@ -0,0 +1 @@ +../../.attw.json \ No newline at end of file diff --git a/packages/upload-client/package.json b/packages/upload-client/package.json index 462a3ca4a..81574f0e3 100644 --- a/packages/upload-client/package.json +++ b/packages/upload-client/package.json @@ -14,6 +14,7 @@ "types": "dist/src/index.d.ts", "main": "src/index.js", "scripts": { + "attw": "attw --pack .", "lint": "eslint '**/*.{js,ts}' && prettier --check '**/*.{js,ts,yml,json}' --ignore-path ../../.gitignore", "build": "tsc --build", "check": "tsc --build", diff --git a/packages/w3up-client/.attw.json b/packages/w3up-client/.attw.json new file mode 120000 index 000000000..eb964d1d2 --- /dev/null +++ b/packages/w3up-client/.attw.json @@ -0,0 +1 @@ +../../.attw.json \ No newline at end of file diff --git a/packages/w3up-client/package.json b/packages/w3up-client/package.json index 6fb38f219..152bcf1f5 100644 --- a/packages/w3up-client/package.json +++ b/packages/w3up-client/package.json @@ -58,6 +58,7 @@ "dist" ], "scripts": { + "attw": "attw --pack .", "lint": "tsc --build && eslint '**/*.{js,ts}' && prettier --check '**/*.{js,ts,yml,json}' --ignore-path ../../.gitignore", "build": "tsc --build", "check": "tsc --build", From 41ab164c936d1ee5e75f6b886afb8de99430850b Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 13:56:44 -0700 Subject: [PATCH 11/20] github workflows for access-client and w3up-client run attw --- .github/workflows/access-client.yml | 1 + .github/workflows/w3up-client.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/access-client.yml b/.github/workflows/access-client.yml index fe4b78979..549765e39 100644 --- a/.github/workflows/access-client.yml +++ b/.github/workflows/access-client.yml @@ -37,3 +37,4 @@ jobs: - run: pnpm -r --filter @web3-storage/access run lint - run: pnpm -r --filter @web3-storage/access run test - run: pnpm -r --filter @web3-storage/access exec depcheck + - run: pnpm --filter '@web3-storage/access' attw diff --git a/.github/workflows/w3up-client.yml b/.github/workflows/w3up-client.yml index ef53073df..04c290dc5 100644 --- a/.github/workflows/w3up-client.yml +++ b/.github/workflows/w3up-client.yml @@ -38,6 +38,7 @@ jobs: registry-url: https://registry.npmjs.org/ cache: 'pnpm' - run: pnpm --filter '@web3-storage/w3up-client...' install + - run: pnpm --filter '@web3-storage/w3up-client' attw - uses: ./packages/w3up-client/.github/actions/test with: w3up-client-dir: ./packages/w3up-client/ From 5f1920dbb59fa8dbdc1f7e8355627aa0483d45dd Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:07:57 -0700 Subject: [PATCH 12/20] prettier .attw.json --- .attw.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.attw.json b/.attw.json index 7aa79ea41..ac2579855 100644 --- a/.attw.json +++ b/.attw.json @@ -1,5 +1,3 @@ { - "ignoreRules": [ - "cjs-resolves-to-esm" - ] + "ignoreRules": ["cjs-resolves-to-esm"] } From f8652a5b5a37a1fa22a8e83c489f3a1d80593c68 Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:11:21 -0700 Subject: [PATCH 13/20] prettier --- packages/filecoin-client/tsconfig.json | 2 +- packages/upload-client/src/types.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/filecoin-client/tsconfig.json b/packages/filecoin-client/tsconfig.json index a7eb49b0b..ecf693439 100644 --- a/packages/filecoin-client/tsconfig.json +++ b/packages/filecoin-client/tsconfig.json @@ -4,7 +4,7 @@ "outDir": "dist", "lib": ["ESNext", "DOM"], "module": "NodeNext", - "moduleResolution": "NodeNext", + "moduleResolution": "NodeNext" }, "include": ["src", "test", "package.json"], "exclude": ["**/node_modules/**"], diff --git a/packages/upload-client/src/types.ts b/packages/upload-client/src/types.ts index 688b9ec76..16d963fae 100644 --- a/packages/upload-client/src/types.ts +++ b/packages/upload-client/src/types.ts @@ -201,7 +201,8 @@ export interface RequestOptions export interface ListRequestOptions extends RequestOptions, Pageable {} -export type DirectoryEntryLink = import('@ipld/unixfs/directory').DirectoryEntryLink +export type DirectoryEntryLink = + import('@ipld/unixfs/directory').DirectoryEntryLink export interface UnixFSDirectoryEncoderOptions { /** From 3b4156ce4cd5c4ada7f082bbaa3cd4c9f0f7ac0a Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:19:33 -0700 Subject: [PATCH 14/20] add atty as monorepo devDep --- package.json | 1 + pnpm-lock.yaml | 130 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 127 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 2c97afe92..5fccbc227 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "docs:markdown": "pnpm run build && docusaurus generate-typedoc" }, "devDependencies": { + "@arethetypeswrong/cli": "^0.12.2", "@docusaurus/core": "^2.3.1", "docusaurus-plugin-typedoc": "^0.18.0", "lint-staged": "^13.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a2d441712..a43e40e00 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,6 +18,9 @@ importers: specifier: ^2.1.0 version: 2.1.0(typedoc@0.25.2) devDependencies: + '@arethetypeswrong/cli': + specifier: ^0.12.2 + version: 0.12.2 '@docusaurus/core': specifier: ^2.3.1 version: 2.4.3(eslint@8.51.0)(typescript@5.2.2) @@ -587,6 +590,39 @@ packages: '@jridgewell/trace-mapping': 0.3.19 dev: true + /@andrewbranch/untar.js@1.0.3: + resolution: {integrity: sha512-Jh15/qVmrLGhkKJBdXlK1+9tY4lZruYjsgkDFj08ZmDiWVBLJcqkok7Z0/R0In+i1rScBpJlSvrTS2Lm41Pbnw==} + dev: true + + /@arethetypeswrong/cli@0.12.2: + resolution: {integrity: sha512-SE4Rqy8LM8zgRLeVXZqFIOg4w4TCDG2AMguuZDDRcrUmVQj7phW0tWJnKwsZtyJ6SdqXTIzWvGYiUJiHg2hb9w==} + hasBin: true + dependencies: + '@arethetypeswrong/core': 0.12.2 + chalk: 4.1.2 + cli-table3: 0.6.3 + commander: 10.0.1 + marked: 5.1.2 + marked-terminal: 5.2.0(marked@5.1.2) + node-fetch: 2.7.0 + semver: 7.5.4 + transitivePeerDependencies: + - encoding + dev: true + + /@arethetypeswrong/core@0.12.2: + resolution: {integrity: sha512-ez/quGfC6RVg7VrwCgMVreJ01jbkfJQRNxOG7Bpl4YGcPRs45ZE1AzpHiIdzqfwFg9EBVSaewaffrsK5MVbALw==} + dependencies: + '@andrewbranch/untar.js': 1.0.3 + fetch-ponyfill: 7.1.0 + fflate: 0.7.4 + semver: 7.5.4 + typescript: 5.2.2 + validate-npm-package-name: 5.0.0 + transitivePeerDependencies: + - encoding + dev: true + /@arr/every@1.0.1: resolution: {integrity: sha512-UQFQ6SgyJ6LX42W8rHCs8KVc0JS0tzVL9ct4XYedJukskYVWTo49tNiMEK9C2HTyarbNiT/RVIRSY82vH+6sTg==} engines: {node: '>=4'} @@ -3927,6 +3963,13 @@ packages: type-fest: 1.4.0 dev: true + /ansi-escapes@6.2.0: + resolution: {integrity: sha512-kzRaCqXnpzWs+3z5ABPQiVke+iq0KXkHo8xiWV4RPTi5Yli0l97BEQuhXV1s7+aSU/fu1kUuxgS4MsQ0fRuygw==} + engines: {node: '>=14.16'} + dependencies: + type-fest: 3.13.1 + dev: true + /ansi-html-community@0.0.8: resolution: {integrity: sha512-1APHAyr3+PCamwNw3bXCPp4HFLONZt/yIH0sZp0/469KWNTEy+qN5jQ3GVX6DMZ1UXAi34yVwtTeaG/HpBuuzw==} engines: {'0': node >= 0.8.0} @@ -3962,6 +4005,10 @@ packages: engines: {node: '>=12'} dev: true + /ansicolors@0.3.2: + resolution: {integrity: sha512-QXu7BPrP29VllRxH8GwB7x5iX5qWKAAMLqKQGWTeLWVlNHNOpVMJ91dsxQAIWXpjuW5wqvxu3Jd/nRjrJ+0pqg==} + dev: true + /any-signal@3.0.1: resolution: {integrity: sha512-xgZgJtKEa9YmDqXodIgl7Fl1C8yNXr8w6gXjqK3LW4GcEiYT+6AQfJSE/8SPsEpLLmcvbv8YU+qet94UewHxqg==} dev: false @@ -4490,6 +4537,14 @@ packages: resolution: {integrity: sha512-zvtSJwuQFpewSyRrI3AsftF6rM0X80mZkChIt1spBGEvRglCrjTniXvinc8JKRoqTwXAgvqTImaN9igfSMtUBw==} dev: true + /cardinal@2.1.1: + resolution: {integrity: sha512-JSr5eOgoEymtYHBjNWyjrMqet9Am2miJhlfKNdqLp6zoeAh0KN5dRAcxlecj5mAJrmQomgiOBj35xHLrFjqBpw==} + hasBin: true + dependencies: + ansicolors: 0.3.2 + redeyed: 2.1.1 + dev: true + /cborg@4.0.3: resolution: {integrity: sha512-poLvpK30KT5KI8gzDx3J/IuVCbsLqMT2fEbOrOuX0H7Hyj8yg5LezeWhRh9aLa5Z6MfPC5sriW3HVJF328M8LQ==} hasBin: true @@ -4694,6 +4749,11 @@ packages: resolution: {integrity: sha512-GHuDRO12Sypu2cV70d1dkA2EUmXHgntrzbpvOB+Qy+49ypNfGgFQIC2fhhXbnyrJRynDCAARsT7Ou0M6hirpfw==} dev: true + /commander@10.0.1: + resolution: {integrity: sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==} + engines: {node: '>=14'} + dev: true + /commander@11.0.0: resolution: {integrity: sha512-9HMlXtt/BNoYr8ooyjjNRdIilOTkVJXB+GhxMTtOKwk0R4j4lS4NpjuqmRxroBfnfTSHQIHQB7wryHhXarNjmQ==} engines: {node: '>=16'} @@ -6557,6 +6617,18 @@ packages: websocket-driver: 0.7.4 dev: true + /fetch-ponyfill@7.1.0: + resolution: {integrity: sha512-FhbbL55dj/qdVO3YNK7ZEkshvj3eQ7EuIGV2I6ic/2YiocvyWv+7jg2s4AyS0wdRU75s3tA8ZxI/xPigb0v5Aw==} + dependencies: + node-fetch: 2.6.13 + transitivePeerDependencies: + - encoding + dev: true + + /fflate@0.7.4: + resolution: {integrity: sha512-5u2V/CDW15QM1XbbgS+0DfPxVB+jUKhWEKuuFuHncbk3tEEqzmoXL+2KyOFuKGqOnmdIy0/davWF1CkuwtibCw==} + dev: true + /file-entry-cache@6.0.1: resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} engines: {node: ^10.12.0 || >=12.0.0} @@ -8547,11 +8619,32 @@ packages: resolution: {integrity: sha512-8z4efJYk43E0upd0NbVXwgSTQs6cT3T06etieCMEg7dRbzCbxUCK/GHlX8mhHRDcp+OLlHkPKsvqQTCvsRl2cg==} dev: true + /marked-terminal@5.2.0(marked@5.1.2): + resolution: {integrity: sha512-Piv6yNwAQXGFjZSaiNljyNFw7jKDdGrw70FSbtxEyldLsyeuV5ZHm/1wW++kWbrOF1VPnUgYOhB2oLL0ZpnekA==} + engines: {node: '>=14.13.1 || >=16.0.0'} + peerDependencies: + marked: ^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0 + dependencies: + ansi-escapes: 6.2.0 + cardinal: 2.1.1 + chalk: 5.3.0 + cli-table3: 0.6.3 + marked: 5.1.2 + node-emoji: 1.11.0 + supports-hyperlinks: 2.3.0 + dev: true + /marked@4.3.0: resolution: {integrity: sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==} engines: {node: '>= 12'} hasBin: true + /marked@5.1.2: + resolution: {integrity: sha512-ahRPGXJpjMjwSOlBoTMZAK7ATXkli5qCPxZ21TG44rx1KEo44bii4ekgTDQPNRQ4Kh7JMb9Ub1PVk1NxRSsorg==} + engines: {node: '>= 16'} + hasBin: true + dev: true + /matchit@1.1.0: resolution: {integrity: sha512-+nGYoOlfHmxe5BW5tE0EMJppXEwdSf8uBA1GTZC7Q77kbT35+VKLYJMzVNWCHSsga1ps1tPYFtFyvxvKzWVmMA==} engines: {node: '>=6'} @@ -8893,6 +8986,18 @@ packages: lodash: 4.17.21 dev: true + /node-fetch@2.6.13: + resolution: {integrity: sha512-StxNAxh15zr77QvvkmveSQ8uCQ4+v5FkvNTj0OESmiHu+VRi/gXArXtkWMElOsOUNLtUEvI4yS+rdtOHZTwlQA==} + engines: {node: 4.x || >=6.0.0} + peerDependencies: + encoding: ^0.1.0 + peerDependenciesMeta: + encoding: + optional: true + dependencies: + whatwg-url: 5.0.0 + dev: true + /node-fetch@2.7.0: resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==} engines: {node: 4.x || >=6.0.0} @@ -8903,7 +9008,6 @@ packages: optional: true dependencies: whatwg-url: 5.0.0 - dev: false /node-forge@1.3.1: resolution: {integrity: sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==} @@ -10323,6 +10427,12 @@ packages: minimatch: 3.1.2 dev: true + /redeyed@2.1.1: + resolution: {integrity: sha512-FNpGGo1DycYAdnrKFxCMmKYgo/mILAqtRYbkdQD8Ep/Hk2PQ5+aEAEx+IU713RTDmuBaH0c8P5ZozurNu5ObRQ==} + dependencies: + esprima: 4.0.1 + dev: true + /reflect.getprototypeof@1.0.4: resolution: {integrity: sha512-ECkTw8TmJwW60lOTR+ZkODISW6RQ8+2CL3COqtiJKLd6MmB45hN51HprHFziKLGkAuTGQhBb91V8cy+KHlaCjw==} engines: {node: '>= 0.4'} @@ -11288,6 +11398,14 @@ packages: dependencies: has-flag: 4.0.0 + /supports-hyperlinks@2.3.0: + resolution: {integrity: sha512-RpsAZlpWcDwOPQA22aCH4J0t7L8JmAvsCxfOSEwm7cQs3LshN36QaTkwd70DnBOXDWGssw2eUoc8CaRWT0XunA==} + engines: {node: '>=8'} + dependencies: + has-flag: 4.0.0 + supports-color: 7.2.0 + dev: true + /supports-preserve-symlinks-flag@1.0.0: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} @@ -11427,7 +11545,6 @@ packages: /tr46@0.0.3: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} - dev: false /trim-trailing-lines@1.1.4: resolution: {integrity: sha512-rjUWSqnfTNrjbB9NQWfPMH/xRK1deHeGsHoVfpxJ++XeYXE0d6B1En37AHfw3jtfTU7dzMzZL2jjpe8Qb5gLIQ==} @@ -11923,6 +12040,13 @@ packages: spdx-expression-parse: 3.0.1 dev: true + /validate-npm-package-name@5.0.0: + resolution: {integrity: sha512-YuKoXDAhBYxY7SfOKxHBDoSyENFeW5VvIIQp2TGQuit8gpK6MnWaQelBKxso72DoxTZfZdcP3W90LqpSkgPzLQ==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + dependencies: + builtins: 5.0.1 + dev: true + /value-equal@1.0.1: resolution: {integrity: sha512-NOJ6JZCAWr0zlxZt+xqCHNTEKOsrks2HQd4MqhP1qy4z1SkbEP467eNx6TgDKXMvUOb+OENfJCZwM+16n7fRfw==} dev: true @@ -12021,7 +12145,6 @@ packages: /webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} - dev: false /webpack-bundle-analyzer@4.9.1: resolution: {integrity: sha512-jnd6EoYrf9yMxCyYDPj8eutJvtjQNp8PHmni/e/ulydHBWhT5J3menXt3HEkScsu9YqMAcG4CfFjs3rj5pVU1w==} @@ -12200,7 +12323,6 @@ packages: dependencies: tr46: 0.0.3 webidl-conversions: 3.0.1 - dev: false /when-exit@2.1.1: resolution: {integrity: sha512-XLipGldz/UcleuGaoQjbYuWwD+ICRnzIjlldtwTaTWr7aZz8yQW49rXk6MHQnh+KxOiWiJpM1vIyaxprOnlW4g==} From 433ab1d3a57c5c249a76239cbe1d8463a46d7c77 Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:32:00 -0700 Subject: [PATCH 15/20] module=Node16 not NodeNext --- tsconfig.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 699aa11e8..8149e2560 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "allowJs": true, "checkJs": true, "target": "ES2022", - "module": "NodeNext", + "module": "Node16", "lib": ["ES2022", "DOM", "DOM.Iterable"], "noEmit": false, "noEmitOnError": true, @@ -20,7 +20,7 @@ "removeComments": false, // module resolution "esModuleInterop": true, - "moduleResolution": "NodeNext", + "moduleResolution": "Node16", // linter checks "noImplicitReturns": false, "noFallthroughCasesInSwitch": true, From cdf8b53b6da0995a9ca83a39405e89844e26eeb6 Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:36:09 -0700 Subject: [PATCH 16/20] rm this file now that I merged in another commits that moves it to a folder --- packages/capabilities/src/filecoin.js | 271 -------------------------- 1 file changed, 271 deletions(-) delete mode 100644 packages/capabilities/src/filecoin.js diff --git a/packages/capabilities/src/filecoin.js b/packages/capabilities/src/filecoin.js deleted file mode 100644 index 7306ccc20..000000000 --- a/packages/capabilities/src/filecoin.js +++ /dev/null @@ -1,271 +0,0 @@ -/** - * Filecoin Capabilities - * - * These can be imported directly with: - * ```js - * import * as Filecoin from '@web3-storage/capabilities/filecoin' - * ``` - * - * @module - */ - -import { capability, Schema, ok } from '@ucanto/validator' -import { equal, equalWith, checkLink, and } from './utils.js' - -/** - * @see https://github.com/filecoin-project/FIPs/pull/758/files - */ -const FR32_SHA2_256_TRUNC254_PADDED_BINARY_TREE = 0x1011 -/** - * @see https://github.com/filecoin-project/FIPs/pull/758/files - */ -const RAW_CODE = 0x55 - -const PIECE_LINK = Schema.link({ - code: RAW_CODE, - version: 1, - multihash: { - code: FR32_SHA2_256_TRUNC254_PADDED_BINARY_TREE, - }, -}) - -/** - * `filecoin/queue` capability allows agent to queue a filecoin piece to be aggregated - * so that it can be stored by a Storage provider on a future time. - */ -export const filecoinQueue = capability({ - can: 'filecoin/queue', - /** - * did:key identifier of the broker authority where offer is made available. - */ - with: Schema.did(), - nb: Schema.struct({ - /** - * CID of the content that resulted in Filecoin piece. - */ - content: Schema.link(), - /** - * CID of the piece. - */ - piece: /** @type {import('./types.js').PieceLinkSchema} */ (PIECE_LINK), - }), - derives: (claim, from) => { - return ( - and(equalWith(claim, from)) || - and(checkLink(claim.nb.content, from.nb.content, 'nb.content')) || - and(checkLink(claim.nb.piece, from.nb.piece, 'nb.piece')) || - ok({}) - ) - }, -}) - -/** - * `filecoin/add` capability allows storefront to add a filecoin piece to be aggregated - * so that it can be stored by a Storage provider on a future time. - */ -export const filecoinAdd = capability({ - can: 'filecoin/add', - /** - * did:key identifier of the broker authority where offer is made available. - */ - with: Schema.did(), - nb: Schema.struct({ - /** - * CID of the content that resulted in Filecoin piece. - */ - content: Schema.link(), - /** - * CID of the piece. - * - * @see https://github.com/filecoin-project/FIPs/pull/758/files - */ - piece: /** @type {import('./types.js').PieceLinkSchema} */ (PIECE_LINK), - }), - derives: (claim, from) => { - return ( - and(equalWith(claim, from)) || - and(checkLink(claim.nb.content, from.nb.content, 'nb.content')) || - and(checkLink(claim.nb.piece, from.nb.piece, 'nb.piece')) || - ok({}) - ) - }, -}) - -/** - * `aggregate/queue` capability allows storefront to queue a piece to be aggregated - * so that it can be stored by a Storage provider on a future time. - */ -export const aggregateQueue = capability({ - can: 'aggregate/queue', - /** - * did:key identifier of the broker authority where offer is made available. - */ - with: Schema.did(), - nb: Schema.struct({ - /** - * CID of the piece. - */ - piece: /** @type {import('./types.js').PieceLinkSchema} */ (PIECE_LINK), - /** - * Grouping for the piece to be aggregated - */ - group: Schema.text(), - }), - derives: (claim, from) => { - return ( - and(equalWith(claim, from)) || - and(checkLink(claim.nb.piece, from.nb.piece, 'nb.piece')) || - and(equal(claim.nb.group, from.nb.group, 'nb.group')) || - ok({}) - ) - }, -}) - -/** - * `aggregate/add` capability allows aggregator to add a piece to aggregate - * so that it can be stored by a Storage provider on a future time. - */ -export const aggregateAdd = capability({ - can: 'aggregate/add', - /** - * did:key identifier of the broker authority where offer is made available. - */ - with: Schema.did(), - nb: Schema.struct({ - /** - * CID of the piece. - * - * @see https://github.com/filecoin-project/FIPs/pull/758/files - */ - piece: /** @type {import('./types.js').PieceLinkSchema} */ (PIECE_LINK), - /** - * Storefront requesting piece to be aggregated - */ - storefront: Schema.text(), - /** - * Grouping for the piece to be aggregated - */ - group: Schema.text(), - }), - derives: (claim, from) => { - return ( - and(equalWith(claim, from)) || - and(checkLink(claim.nb.piece, from.nb.piece, 'nb.piece')) || - and(equal(claim.nb.storefront, from.nb.storefront, 'nb.storefront')) || - and(equal(claim.nb.group, from.nb.group, 'nb.group')) || - ok({}) - ) - }, -}) - -/** - * `deal/queue` capability allows storefront to create a deal offer to get an aggregate - * of CARs files in the market to be fetched and stored by a Storage provider. - */ -export const dealQueue = capability({ - can: 'deal/queue', - /** - * did:key identifier of the broker authority where offer is made available. - */ - with: Schema.did(), - nb: Schema.struct({ - /** - * CID of the DAG-CBOR encoded block with offer details. - * Service will queue given offer to be validated and handled. - */ - pieces: Schema.link(), - /** - * Commitment proof for the aggregate being offered. - * https://github.com/filecoin-project/go-state-types/blob/1e6cf0d47cdda75383ef036fc2725d1cf51dbde8/abi/piece.go#L47-L50 - */ - aggregate: /** @type {import('./types.js').PieceLinkSchema} */ (PIECE_LINK), - /** - * Storefront requesting deal - */ - storefront: Schema.text(), - /** - * arbitrary label to be added to the deal on chain - */ - label: Schema.text().optional(), - }), - derives: (claim, from) => { - return ( - and(equalWith(claim, from)) || - and(checkLink(claim.nb.aggregate, from.nb.aggregate, 'nb.aggregate')) || - and(checkLink(claim.nb.pieces, from.nb.pieces, 'nb.pieces')) || - and(equal(claim.nb.storefront, from.nb.storefront, 'nb.storefront')) || - and(equal(claim.nb.label, from.nb.label, 'nb.label')) || - ok({}) - ) - }, -}) - -/** - * `deal/add` capability allows Dealer to submit offer with an aggregate of - * Filecoin pieces in the market to be fetched and stored by a Storage provider. - */ -export const dealAdd = capability({ - can: 'deal/add', - /** - * did:key identifier of the broker authority where offer is made available. - */ - with: Schema.did(), - nb: Schema.struct({ - /** - * CID of the DAG-CBOR encoded block with offer details. - * Service will queue given offer to be validated and handled. - */ - pieces: Schema.link(), - /** - * Commitment proof for the aggregate being offered. - * - * @see https://github.com/filecoin-project/go-state-types/blob/1e6cf0d47cdda75383ef036fc2725d1cf51dbde8/abi/piece.go#L47-L50 - * @see https://github.com/filecoin-project/FIPs/pull/758/files - */ - aggregate: /** @type {import('./types.js').PieceLinkSchema} */ (PIECE_LINK), - /** - * Storefront requesting deal - */ - storefront: Schema.text(), - /** - * arbitrary label to be added to the deal on chain - */ - label: Schema.text().optional(), - }), - derives: (claim, from) => { - return ( - and(equalWith(claim, from)) || - and(checkLink(claim.nb.aggregate, from.nb.aggregate, 'nb.aggregate')) || - and(checkLink(claim.nb.pieces, from.nb.pieces, 'nb.pieces')) || - and(equal(claim.nb.storefront, from.nb.storefront, 'nb.storefront')) || - and(equal(claim.nb.label, from.nb.label, 'nb.label')) || - ok({}) - ) - }, -}) - -/** - * `chain-tracker/info` capability allows agent to get chain info of a given piece. - */ -export const chainTrackerInfo = capability({ - can: 'chain-tracker/info', - /** - * did:key identifier of the broker authority where offer is made available. - */ - with: Schema.did(), - nb: Schema.struct({ - /** - * CID of the piece. - * - * @see https://github.com/filecoin-project/FIPs/pull/758/files - */ - piece: /** @type {import('./types.js').PieceLinkSchema} */ (PIECE_LINK), - }), - derives: (claim, from) => { - return ( - and(equalWith(claim, from)) || - and(checkLink(claim.nb.piece, from.nb.piece, 'nb.piece')) || - ok({}) - ) - }, -}) From 7382e3df9de64953e82908d5b6894f792ba5390e Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:39:36 -0700 Subject: [PATCH 17/20] rm unused var --- packages/did-mailto/src/types.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/did-mailto/src/types.ts b/packages/did-mailto/src/types.ts index 6a8f431ed..51c2a45b5 100644 --- a/packages/did-mailto/src/types.ts +++ b/packages/did-mailto/src/types.ts @@ -10,5 +10,3 @@ export type PercentEncoded = string // did:mailto export type DidMailto = `did:mailto:${PercentEncoded}:${PercentEncoded}` - -export const test = 1; From 1b5a476c6baaee59ecf666ce296509d78b8a47cd Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:41:08 -0700 Subject: [PATCH 18/20] remove child tsconfig.json explicitly using module=NodeNext and instead just inheriting from /tsconfig.json --- packages/did-mailto/tsconfig.json | 4 +--- packages/filecoin-client/tsconfig.json | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/did-mailto/tsconfig.json b/packages/did-mailto/tsconfig.json index 5d3671bd9..ab5d5d625 100644 --- a/packages/did-mailto/tsconfig.json +++ b/packages/did-mailto/tsconfig.json @@ -1,9 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "outDir": "dist", - "moduleResolution": "NodeNext", - "module": "NodeNext" + "outDir": "dist" }, "include": ["src", "test"], "exclude": ["**/node_modules/**", "dist"], diff --git a/packages/filecoin-client/tsconfig.json b/packages/filecoin-client/tsconfig.json index ecf693439..09642303f 100644 --- a/packages/filecoin-client/tsconfig.json +++ b/packages/filecoin-client/tsconfig.json @@ -2,9 +2,7 @@ "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "dist", - "lib": ["ESNext", "DOM"], - "module": "NodeNext", - "moduleResolution": "NodeNext" + "lib": ["ESNext", "DOM"] }, "include": ["src", "test", "package.json"], "exclude": ["**/node_modules/**"], From df5995bbf679029a9a9a4f5c52984a9eacf1c67e Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:14:44 -0700 Subject: [PATCH 19/20] add rationale for ts-expect-error in unixfs.test.js import of blockstore-core/memory --- packages/upload-client/test/unixfs.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/upload-client/test/unixfs.test.js b/packages/upload-client/test/unixfs.test.js index 72ab04965..2a45be0ad 100644 --- a/packages/upload-client/test/unixfs.test.js +++ b/packages/upload-client/test/unixfs.test.js @@ -1,7 +1,7 @@ import assert from 'assert' import { decode, NodeType } from '@ipld/unixfs' import { exporter } from 'ipfs-unixfs-exporter' -// @ts-ignore +// @ts-expect-error this version of blockstore-core doesn't point to correct types file in package.json, and upgrading to latest version that fixes that leads to api changes import { MemoryBlockstore } from 'blockstore-core/memory' import * as raw from 'multiformats/codecs/raw' import path from 'path' From e9882a4c4a7507dcf22ea31e090d84dee376b999 Mon Sep 17 00:00:00 2001 From: bengo <171782+gobengo@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:34:02 -0700 Subject: [PATCH 20/20] rm unused ts-ignore --- packages/upload-api/src/consumer/has.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/upload-api/src/consumer/has.js b/packages/upload-api/src/consumer/has.js index ad1d85f3b..24718beae 100644 --- a/packages/upload-api/src/consumer/has.js +++ b/packages/upload-api/src/consumer/has.js @@ -6,7 +6,6 @@ import { Consumer } from '@web3-storage/capabilities' * @param {API.ConsumerServiceContext} context */ export const provide = (context) => - // @ts-ignore Provider.provide(Consumer.has, (input) => has(input, context)) /**