Skip to content

Commit

Permalink
Merge pull request #35 from desci-labs/m0ar/fix-runtime-definitions
Browse files Browse the repository at this point in the history
Only take runtime defs as passed to client instantiation functions
  • Loading branch information
m0ar authored Jan 16, 2024
2 parents 67d5f60 + 327caf2 commit 937ce92
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
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>;

0 comments on commit 937ce92

Please sign in to comment.