Skip to content
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
11 changes: 10 additions & 1 deletion .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
"generatorName": "fernapi/fern-typescript-sdk",
"generatorVersion": "3.87.2",
"generatorConfig": {
"naming": {
"namespace": "CloudPDF",
"client": "CloudPDFClient",
"error": "CloudPDFError",
"timeoutError": "CloudPDFTimeoutError",
"environment": "CloudPDFEnvironment",
"environmentUrls": "CloudPDFEnvironmentUrls",
"version": "CloudPDFVersion"
},
"packageJson": {
"name": "@cloudpdf/sdk",
"description": "The official TypeScript SDK for the CloudPDF API.",
Expand All @@ -13,7 +22,7 @@
}
}
},
"originGitCommit": "232d5e0240d5673a73c9ea7c7ae9e7b937fdd5b3",
"originGitCommit": "a0adb9e77ef16feaef2358d71b247b4f5a98fd23",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"requestedVersion": "3.0.0-next.1",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/sdk-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ jobs:
- run: corepack enable
- run: pnpm install --lockfile=false --ignore-scripts
- run: pnpm build
- run: npm pack --dry-run
125 changes: 125 additions & 0 deletions .github/workflows/sdk-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: SDK Release

on:
push:
branches: [main]
paths-ignore:
- '.github/**'
workflow_dispatch:

permissions:
contents: read

concurrency:
group: sdk-release
cancel-in-progress: false

jobs:
release:
name: Publish @cloudpdf/sdk
if: github.event_name == 'workflow_dispatch' || vars.SDK_AUTO_PUBLISH_ENABLED == 'true'
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: pnpm/action-setup@v5

- uses: actions/setup-node@v4
with:
node-version: 24

- name: Verify generated release version
id: version
run: |
node <<'NODE'
const fs = require('node:fs');
const manifest = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const generation = JSON.parse(fs.readFileSync('cloudpdf-generation.json', 'utf8'));
if (generation.language !== 'typescript') throw new Error('generation language is not typescript');
if (manifest.name !== '@cloudpdf/sdk') throw new Error(`unexpected npm package ${manifest.name}`);
if (manifest.version !== generation.sdkVersion) {
throw new Error(`package version ${manifest.version} does not match generated version ${generation.sdkVersion}`);
}
const prerelease = generation.canonicalVersion.includes('-');
fs.appendFileSync(process.env.GITHUB_OUTPUT, `version=${manifest.version}\n`);
fs.appendFileSync(process.env.GITHUB_OUTPUT, `tag=v${manifest.version}\n`);
fs.appendFileSync(process.env.GITHUB_OUTPUT, `dist_tag=${prerelease ? 'next' : 'latest'}\n`);
fs.appendFileSync(process.env.GITHUB_OUTPUT, `prerelease=${prerelease}\n`);
NODE

- name: Install, build, and pack
run: |
pnpm install --lockfile=false --ignore-scripts
pnpm build
npm pack --dry-run

- name: Protect immutable release tag
id: release-tag
env:
RELEASE_TAG: ${{ steps.version.outputs.tag }}
run: |
git fetch --force --tags origin
if git rev-parse --quiet --verify "refs/tags/$RELEASE_TAG" >/dev/null; then
tagged_commit="$(git rev-list -n 1 "$RELEASE_TAG")"
if [ "$tagged_commit" != "$GITHUB_SHA" ]; then
if git diff --quiet "$RELEASE_TAG" "$GITHUB_SHA" -- . ':(exclude).github/**'; then
echo "::notice::Reusing $RELEASE_TAG after a workflow-only change."
else
echo "::error::Release tag $RELEASE_TAG already points to different package source at $tagged_commit; bump the SDK version."
exit 1
fi
fi
echo "existed=true" >> "$GITHUB_OUTPUT"
else
git config user.name cloudpdf-sdk-bot
git config user.email hello@cloudpdf.com
git tag -a "$RELEASE_TAG" -m "CloudPDF TypeScript SDK $RELEASE_TAG"
git push origin "refs/tags/$RELEASE_TAG"
echo "existed=false" >> "$GITHUB_OUTPUT"
fi

- name: Check npm publication state
id: registry
env:
VERSION: ${{ steps.version.outputs.version }}
TAG_EXISTED: ${{ steps.release-tag.outputs.existed }}
run: |
npm_view_output="$(mktemp)"
if npm view "@cloudpdf/sdk@$VERSION" version --json >"$npm_view_output" 2>&1; then
if [ "$TAG_EXISTED" != 'true' ]; then
echo "::error::@cloudpdf/sdk@$VERSION already exists on npm but its release tag did not exist."
exit 1
fi
echo "publish=false" >> "$GITHUB_OUTPUT"
elif grep -Eiq 'E404|not found' "$npm_view_output"; then
echo "publish=true" >> "$GITHUB_OUTPUT"
else
cat "$npm_view_output"
echo "::error::Could not determine whether @cloudpdf/sdk@$VERSION exists on npm."
exit 1
fi

- name: Publish to npm
if: steps.registry.outputs.publish == 'true'
env:
DIST_TAG: ${{ steps.version.outputs.dist_tag }}
run: npm publish --access public --tag "$DIST_TAG"

- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ steps.version.outputs.tag }}
PRERELEASE: ${{ steps.version.outputs.prerelease }}
run: |
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
exit 0
fi
args=(--verify-tag --generate-notes --title "CloudPDF TypeScript SDK $RELEASE_TAG")
if [ "$PRERELEASE" = 'true' ]; then args+=(--prerelease); fi
gh release create "$RELEASE_TAG" "${args[@]}"
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Cloudpdf TypeScript Library
# CloudPDF TypeScript SDK

[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=Cloudpdf%2FTypeScript)
[![npm shield](https://img.shields.io/npm/v/@cloudpdf/sdk)](https://www.npmjs.com/package/@cloudpdf/sdk)

The Cloudpdf TypeScript library provides convenient access to the Cloudpdf APIs from TypeScript.
The official TypeScript SDK for the CloudPDF API.

## Table of Contents

Expand Down Expand Up @@ -42,9 +42,9 @@ A full reference for this library is available [here](./reference.md).
Instantiate and use the client with the following:

```typescript
import { CloudpdfApiClient } from "@cloudpdf/sdk";
import { CloudPDFClient } from "@cloudpdf/sdk";

const client = new CloudpdfApiClient({ baseUrl: "YOUR_BASE_URL", token: "YOUR_TOKEN" });
const client = new CloudPDFClient({ baseUrl: "YOUR_BASE_URL", token: "YOUR_TOKEN" });
await client.tenants.create({
id: "id"
});
Expand All @@ -56,9 +56,9 @@ The SDK exports all request and response types as TypeScript interfaces. Simply
following namespace:

```typescript
import { CloudpdfApi } from "@cloudpdf/sdk";
import { CloudPDF } from "@cloudpdf/sdk";

const request: CloudpdfApi.HeadDocRequest = {
const request: CloudPDF.HeadDocRequest = {
...
};
```
Expand All @@ -69,12 +69,12 @@ When the API returns a non-success status code (4xx or 5xx response), a subclass
will be thrown.

```typescript
import { CloudpdfApiError } from "@cloudpdf/sdk";
import { CloudPDFError } from "@cloudpdf/sdk";

try {
await client.tenants.create(...);
} catch (err) {
if (err instanceof CloudpdfApiError) {
if (err instanceof CloudPDFError) {
console.log(err.statusCode);
console.log(err.message);
console.log(err.body);
Expand Down Expand Up @@ -534,9 +534,9 @@ const client = new DeploymentClient({...});
If you would like to send additional headers as part of the request, use the `headers` request option.

```typescript
import { CloudpdfApiClient } from "@cloudpdf/sdk";
import { CloudPDFClient } from "@cloudpdf/sdk";

const client = new CloudpdfApiClient({
const client = new CloudPDFClient({
...
headers: {
'X-Custom-Header': 'custom value'
Expand Down Expand Up @@ -629,9 +629,9 @@ console.log(rawResponse.headers['X-My-Header']);
The SDK supports logging. You can configure the logger by passing in a `logging` object to the client options.

```typescript
import { CloudpdfApiClient, logging } from "@cloudpdf/sdk";
import { CloudPDFClient, logging } from "@cloudpdf/sdk";

const client = new CloudpdfApiClient({
const client = new CloudPDFClient({
...
logging: {
level: logging.LogLevel.Debug, // defaults to logging.LogLevel.Info
Expand Down
2 changes: 1 addition & 1 deletion cloudpdf-generation.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"repository": "embedpdf/embed-pdf-viewer",
"openapi": "cloudpdf/contract/openapi.json",
"openapiSha256": "6858ce7912e9063d8fb171ade95fc473db01c5971a3af241a612dda79cc05100",
"gitCommit": "232d5e0240d5673a73c9ea7c7ae9e7b937fdd5b3",
"gitCommit": "a0adb9e77ef16feaef2358d71b247b4f5a98fd23",
"gitCommitIsDirty": false
},
"fern": {
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,8 @@
"repository": {
"type": "git",
"url": "git+https://github.com/embedpdf/cloudpdf-sdk-typescript.git"
},
"publishConfig": {
"access": "public"
}
}
Loading
Loading