Skip to content

Commit

Permalink
Merge pull request #153 from us3r-network/F-sdkWithDefinition-ttang
Browse files Browse the repository at this point in the history
F sdk with definition ttang
  • Loading branch information
sin-bufan authored Jul 5, 2023
2 parents b35d2c1 + 3967473 commit 4dfedde
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
17 changes: 17 additions & 0 deletions packages/client/dashboard/src/components/ModelSDK.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ export default function ModelSDK({
throw new Error('no graphql')
}

const runtimeComposite = data.find(
(item) => item.filename === 'runtime-composite.ts'
)
if (!runtimeComposite) {
throw new Error('no runtime-composite')
}

runtimeComposite.content = `// This is an auto-generated file, do not edit manually
export const definition = ${JSON.stringify(
JSON.parse(runtimeComposite.content),
null,
2
)}
`

const sdkContent = sdkTemplate
.replaceAll('<%= modelName %>', modelName)
.replaceAll('<%= modelNameCamelcase %>', camelCase(modelName))
Expand All @@ -87,6 +103,7 @@ export default function ModelSDK({
filename: `S3${modelName}Model.ts`,
content: sdkContent,
},
runtimeComposite,
graphql,
].map((item, i) => ({
title: item.filename,
Expand Down
6 changes: 4 additions & 2 deletions packages/client/dashboard/src/components/sdkTemplate.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
export const sdkTemplate = `
/**
export const sdkTemplate = `/**
* How to use this model:
*
* export const CERAMIC_TESTNET_HOST = "https://gcp-ceramic-testnet-dev.s3.xyz";
* const <%= modelNameCamelcase %>Model = new S3<%= modelName %>Model(CERAMIC_TESTNET_HOST);
*
* // auth with didSession
* <%= modelNameCamelcase %>Model.authComposeClient(didSession);
*
* // createNew
* const resp = await <%= modelNameCamelcase %>Model.create<%= modelName %>({...});
*
Expand Down

0 comments on commit 4dfedde

Please sign in to comment.