Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Receipts PR #206

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
"plugins": [
"node-workspace"
],
"last-release-sha": "e6f8d809f4e06fc2920dcb28e1b5926bb73f4e46",
"bootstrap-sha": "f814e75a89d3ed7c3488a8cb7af8d94f0cfba440",
"packages": {
"packages/principal": {},
"packages/client": {},
"packages/core": {},
"packages/interface": {},
"packages/server": {},
"packages/transport": {},
"packages/validator": {}
"packages/transport": {}
}
}
9 changes: 8 additions & 1 deletion .github/release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
{"packages/client":"4.1.0","packages/core":"4.1.0","packages/interface":"4.1.0","packages/principal":"4.1.0","packages/server":"4.1.0","packages/transport":"4.1.0","packages/validator":"4.1.0"}
{
"packages/client": "4.1.0",
"packages/core": "4.1.0",
"packages/interface": "4.1.0",
"packages/principal": "4.1.0",
"packages/server": "4.1.0",
"packages/transport": "4.1.0"
}
2 changes: 0 additions & 2 deletions .github/workflows/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ on:
- 'packages/core/**'
- 'packages/transport/**'
- 'packages/client/**'
- 'packages/validator/**'
- 'packages/server/**'
pull_request:
branches:
Expand All @@ -20,7 +19,6 @@ on:
- 'packages/core/**'
- 'packages/transport/**'
- 'packages/client/**'
- 'packages/validator/**'
- 'packages/server/**'
- '.github/workflows/server.yml'
jobs:
Expand Down
88 changes: 0 additions & 88 deletions .github/workflows/validator.yml

This file was deleted.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"packages/client",
"packages/server",
"packages/transport",
"packages/principal",
"packages/validator"
"packages/principal"
],
"scripts": {
"format": "prettier --write '**/*.{js,ts,yml,json}' --ignore-path .gitignore",
Expand Down
18 changes: 18 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
"devDependencies": {
"@types/chai": "^4.3.3",
"@types/mocha": "^9.1.0",
"@types/chai-subset": "^1.3.3",
"@ucanto/principal": "^4.1.0",
"c8": "^7.11.0",
"chai": "^4.3.6",
"chai-subset": "^1.6.0",
"mocha": "^10.1.0",
"nyc": "^15.1.0",
"playwright-test": "^8.1.1",
Expand Down Expand Up @@ -75,6 +77,22 @@
"./delegation": {
"types": "./dist/src/delegation.d.ts",
"import": "./src/delegation.js"
},
"./schema": {
"types": "./dist/src/schema.d.ts",
"import": "./src/schema.js"
},
"./capability": {
"types": "./dist/src/capability.d.ts",
"import": "./src/capability.js"
},
"./validator": {
"types": "./dist/src/validator.d.ts",
"import": "./src/validator.js"
},
"./error": {
"types": "./dist/src/error.d.ts",
"import": "./src/error.js"
}
},
"c8": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
DelegationError as MatchError,
Failure,
} from './error.js'
import { invoke, delegate } from '@ucanto/core'
import { invoke } from './invocation.js'
import { delegate } from './delegation.js'

/**
* @template {API.Ability} A
Expand Down Expand Up @@ -114,6 +115,27 @@ class Capability extends Unit {
this.descriptor = { derives, ...descriptor }
}

/**
* @type {API.Reader<R>}
*/
get with() {
return this.descriptor.with
}

/**
* @param {unknown} source
*/
read(source) {
try {
const result = this.create(/** @type {any} */ (source))
return /** @type {API.Result<API.ParsedCapability<A, R, API.InferCaveats<C>>, API.Failure>} */ (
result
)
} catch (error) {
return /** @type {any} */ (error)
}
}

/**
* @param {API.InferCreateOptions<R, API.InferCaveats<C>>} options
*/
Expand Down Expand Up @@ -344,6 +366,13 @@ class Derive extends Unit {
this.derives = derives
}

/**
* @param {unknown} source
*/
read(source) {
return this.to.read(source)
}

/**
* @type {typeof this.to['create']}
*/
Expand All @@ -365,6 +394,10 @@ class Derive extends Unit {
get can() {
return this.to.can
}
get with() {
return this.to.with
}

/**
* @param {API.Source} capability
* @returns {API.MatchResult<API.DerivedMatch<T, M>>}
Expand Down
Loading