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

Only take runtime defs as passed to client instantiation functions #35

Merged
merged 1 commit into from
Jan 16, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
check-latest: false
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish
- run: npm --workspace packages/lib publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions packages/lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@desci-labs/desci-codex-lib",
"version": "1.0.0",
"version": "1.0.1",
"description": "Codex interaction primitives",
"license": "MIT",
"author": "Edvard Hübinette",
Expand All @@ -19,13 +19,12 @@
"vitest-github-actions-reporter": "^0.10.0"
},
"dependencies": {
"@desci-labs/desci-codex-composedb": "^1.0.0",
"uint8arrays": "^4.0.6",
"@composedb/client": "^0.6.0",
"dids": "^4.0.4",
"gql-query-builder": "^3.8.0",
"graphql": "^16.8.0",
"key-did-provider-ed25519": "^3.0.2",
"key-did-resolver": "^3.0.0",
"@composedb/client": "^0.6.0",
"gql-query-builder": "^3.8.0",
"graphql": "^16.8.0"
"uint8arrays": "^4.0.6"
}
}
11 changes: 6 additions & 5 deletions packages/lib/src/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
CeramicClient,
type CeramicClientConfig,
} from "@ceramicnetwork/http-client";
import { definition } from "@desci-labs/desci-codex-composedb/src/__generated__/definition.js";
import type { Optional } from "./types.js";

const DEFAULT_LOCAL_CERAMIC = "http://localhost:7007";

Expand Down Expand Up @@ -35,8 +35,10 @@ export const newCeramicClient = (
return new CeramicClient(endpoint ?? DEFAULT_LOCAL_CERAMIC, config);
};

export const newComposeClient = (params?: Partial<ComposeClientParams>) => {
if (!params?.ceramic) {
export const newComposeClient = (
params: Optional<ComposeClientParams, "ceramic">,
) => {
if (!params.ceramic) {
console.log(
"[codex] ceramic client not provided; defaulting to",
DEFAULT_LOCAL_CERAMIC,
Expand All @@ -45,8 +47,7 @@ export const newComposeClient = (params?: Partial<ComposeClientParams>) => {

return new ComposeClient({
ceramic: DEFAULT_LOCAL_CERAMIC,
definition,
// Let passed config overwrite, if present
// Let passed config overwrite ceramic, if present
...params,
});
};
Expand Down
5 changes: 5 additions & 0 deletions packages/lib/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,8 @@ export type UnionKeys<T> = T extends unknown ? keyof T : never;
export type DistributiveOmit<T, K extends UnionKeys<T>> = T extends unknown
? Omit<T, Extract<keyof T, K>>
: never;

/**
* Make one key optional in a record type
*/
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
Loading