Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ee56b56
codegen metadata
stainless-app[bot] Feb 25, 2026
a382843
chore(internal): move stringifyQuery implementation to internal function
stainless-app[bot] Feb 27, 2026
c6204bd
chore(internal): codegen related update
stainless-app[bot] Mar 3, 2026
5d0b8ca
chore(internal): codegen related update
stainless-app[bot] Mar 6, 2026
3f4f137
chore(test): do not count install time for mock server timeout
stainless-app[bot] Mar 6, 2026
5ba5d28
chore(ci): skip uploading artifacts on stainless-internal branches
stainless-app[bot] Mar 7, 2026
aa35c3f
fix(client): preserve URL params already embedded in path
stainless-app[bot] Mar 7, 2026
cd210f0
chore(internal): update dependencies to address dependabot vulnerabil…
stainless-app[bot] Mar 10, 2026
37047f6
chore(internal): tweak CI branches
stainless-app[bot] Mar 17, 2026
3b6f5e4
refactor(tests): switch from prism to steady
stainless-app[bot] Mar 20, 2026
bce44ad
chore(tests): bump steady to v0.19.4
stainless-app[bot] Mar 21, 2026
1ecdf4a
chore(tests): bump steady to v0.19.5
stainless-app[bot] Mar 21, 2026
3f8fe21
chore(internal): update gitignore
stainless-app[bot] Mar 24, 2026
13a8f4a
chore(tests): bump steady to v0.19.6
stainless-app[bot] Mar 24, 2026
2ff6735
chore(ci): skip lint on metadata-only changes
stainless-app[bot] Mar 25, 2026
3944238
chore(tests): bump steady to v0.19.7
stainless-app[bot] Mar 25, 2026
eb9810b
chore(internal): update multipart form array serialization
stainless-app[bot] Mar 27, 2026
6dc4c88
chore(internal): codegen related update
stainless-app[bot] Mar 28, 2026
f058a02
chore(tests): bump steady to v0.20.1
stainless-app[bot] Apr 1, 2026
e312dc6
chore(tests): bump steady to v0.20.2
stainless-app[bot] Apr 1, 2026
7ce40c6
chore(internal): codegen related update
stainless-app[bot] Apr 9, 2026
740e1ae
chore(internal): codegen related update
stainless-app[bot] Apr 13, 2026
520f380
release: 0.1.1
stainless-app[bot] Apr 13, 2026
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
26 changes: 16 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: CI
on:
push:
branches-ignore:
- 'generated'
- 'codegen/**'
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'
branches:
- '**'
- '!integrated/**'
- '!stl-preview-head/**'
- '!stl-preview-base/**'
- '!generated'
- '!codegen/**'
- 'codegen/stl/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
Expand All @@ -17,7 +19,7 @@ jobs:
timeout-minutes: 10
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/unlayer-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
steps:
- uses: actions/checkout@v6

Expand All @@ -36,7 +38,7 @@ jobs:
timeout-minutes: 5
name: build
runs-on: ${{ github.repository == 'stainless-sdks/unlayer-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
permissions:
contents: read
id-token: write
Expand All @@ -55,14 +57,18 @@ jobs:
run: ./scripts/build

- name: Get GitHub OIDC Token
if: github.repository == 'stainless-sdks/unlayer-typescript'
if: |-
github.repository == 'stainless-sdks/unlayer-typescript' &&
!startsWith(github.ref, 'refs/heads/stl/')
id: github-oidc
uses: actions/github-script@v8
with:
script: core.setOutput('github_token', await core.getIDToken());

- name: Upload tarball
if: github.repository == 'stainless-sdks/unlayer-typescript'
if: |-
github.repository == 'stainless-sdks/unlayer-typescript' &&
!startsWith(github.ref, 'refs/heads/stl/')
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.prism.log
.stdy.log
node_modules
yarn-error.log
codegen.log
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0"
".": "0.1.1"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 7
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/unlayer%2Funlayer-48f00d1c04c23fb4d1cb7cf4af4f56b0c920d758c1f06e06e5373e5b15e9c27d.yml
openapi_spec_hash: 6ee2a94bb9840aceb4a6161c724ce46c
config_hash: 249869757b6eb98ae3d58f2a47ce21e2
config_hash: c8d97d58d67dad9eeb65eb58fc781724
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
# Changelog

## 0.1.1 (2026-04-13)

Full Changelog: [v0.1.0...v0.1.1](https://github.com/unlayer/unlayer-typescript/compare/v0.1.0...v0.1.1)

### Bug Fixes

* **client:** preserve URL params already embedded in path ([aa35c3f](https://github.com/unlayer/unlayer-typescript/commit/aa35c3f9daed566ab225bb5460667b55accfdec3))


### Chores

* **ci:** skip lint on metadata-only changes ([2ff6735](https://github.com/unlayer/unlayer-typescript/commit/2ff6735db5aee19634ac92a8f5903a2496b5d9fd))
* **ci:** skip uploading artifacts on stainless-internal branches ([5ba5d28](https://github.com/unlayer/unlayer-typescript/commit/5ba5d2871132cd901801f72d9d82ae8a0d03adc1))
* **internal:** codegen related update ([740e1ae](https://github.com/unlayer/unlayer-typescript/commit/740e1ae35ac61a36d7f1e109456844432d2bd6c6))
* **internal:** codegen related update ([7ce40c6](https://github.com/unlayer/unlayer-typescript/commit/7ce40c6dd2c9ff9f0442e6f89b60ca47c19a9351))
* **internal:** codegen related update ([6dc4c88](https://github.com/unlayer/unlayer-typescript/commit/6dc4c8844896dcc94667c0b7ff0d0ea37e886e1a))
* **internal:** codegen related update ([5d0b8ca](https://github.com/unlayer/unlayer-typescript/commit/5d0b8cae4d04648e5904edde4c4be65d2f22b144))
* **internal:** codegen related update ([c6204bd](https://github.com/unlayer/unlayer-typescript/commit/c6204bdf620e82a1b0de3859c74a0b04ddb220be))
* **internal:** move stringifyQuery implementation to internal function ([a382843](https://github.com/unlayer/unlayer-typescript/commit/a3828431e022b0c294eea5dd6d3dfec91dc50f3c))
* **internal:** tweak CI branches ([37047f6](https://github.com/unlayer/unlayer-typescript/commit/37047f64ad65e540363a5888057fb2031797fa89))
* **internal:** update dependencies to address dependabot vulnerabilities ([cd210f0](https://github.com/unlayer/unlayer-typescript/commit/cd210f0014bf4c6f91f96b0458b97b28b9b02004))
* **internal:** update gitignore ([3f8fe21](https://github.com/unlayer/unlayer-typescript/commit/3f8fe21e12dd47a7ec5381b1d01c4b3319d48f0d))
* **internal:** update multipart form array serialization ([eb9810b](https://github.com/unlayer/unlayer-typescript/commit/eb9810b160faa0c0eb5607a900d0bc3efe80c837))
* **test:** do not count install time for mock server timeout ([3f4f137](https://github.com/unlayer/unlayer-typescript/commit/3f4f1372bc0146d0abd93d289d1edf1a4c6ce864))
* **tests:** bump steady to v0.19.4 ([bce44ad](https://github.com/unlayer/unlayer-typescript/commit/bce44adfdaa4fca510a83d182fc9b4788ad454c1))
* **tests:** bump steady to v0.19.5 ([1ecdf4a](https://github.com/unlayer/unlayer-typescript/commit/1ecdf4a084af6afb151688f3d9ae50ed99d978cb))
* **tests:** bump steady to v0.19.6 ([13a8f4a](https://github.com/unlayer/unlayer-typescript/commit/13a8f4ab35b1f6487aaf4b2ae1f9fcc771df00f8))
* **tests:** bump steady to v0.19.7 ([3944238](https://github.com/unlayer/unlayer-typescript/commit/39442381621c93dbeed18b939de999606bcdf3f2))
* **tests:** bump steady to v0.20.1 ([f058a02](https://github.com/unlayer/unlayer-typescript/commit/f058a02837772b49e641ab186988c76aa4445695))
* **tests:** bump steady to v0.20.2 ([e312dc6](https://github.com/unlayer/unlayer-typescript/commit/e312dc60c1bf68b3faa91d94feee712f2ab22b60))


### Refactors

* **tests:** switch from prism to steady ([3b6f5e4](https://github.com/unlayer/unlayer-typescript/commit/3b6f5e4fe8b7e7df20f500d9191075331c56310e))

## 0.1.0 (2026-02-24)

Full Changelog: [v0.0.1...v0.1.0](https://github.com/unlayer/unlayer-typescript/compare/v0.0.1...v0.1.0)
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ $ pnpm link --global @unlayer/sdk

## Running tests

Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.
Most tests require you to [set up a mock server](https://github.com/dgellow/steady) against the OpenAPI spec to run the tests.

```sh
$ ./scripts/mock
Expand Down
13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@unlayer/sdk",
"version": "0.1.0",
"version": "0.1.1",
"description": "The official TypeScript library for the Unlayer API",
"author": "Unlayer <contact@example.com>",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -50,6 +50,17 @@
"typescript": "5.8.3",
"typescript-eslint": "8.31.1"
},
"overrides": {
"minimatch": "^9.0.5"
},
"pnpm": {
"overrides": {
"minimatch": "^9.0.5"
}
},
"resolutions": {
"minimatch": "^9.0.5"
},
"exports": {
".": {
"import": "./dist/index.mjs",
Expand Down
31 changes: 21 additions & 10 deletions scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,34 @@ fi

echo "==> Starting mock server with URL ${URL}"

# Run prism mock on the given spec
# Run steady mock on the given spec
if [ "$1" == "--daemon" ]; then
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log &
# Pre-install the package so the download doesn't eat into the startup timeout
npm exec --package=@stdy/cli@0.20.2 -- steady --version

# Wait for server to come online
npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log &

# Wait for server to come online via health endpoint (max 30s)
echo -n "Waiting for server"
while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do
attempts=0
while ! curl --silent --fail "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1; do
if ! kill -0 $! 2>/dev/null; then
echo
cat .stdy.log
exit 1
fi
attempts=$((attempts + 1))
if [ "$attempts" -ge 300 ]; then
echo
echo "Timed out waiting for Steady server to start"
cat .stdy.log
exit 1
fi
echo -n "."
sleep 0.1
done

if grep -q "✖ fatal" ".prism.log"; then
cat .prism.log
exit 1
fi

echo
else
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL"
npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL"
fi
16 changes: 8 additions & 8 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color

function prism_is_running() {
curl --silent "http://localhost:4010" >/dev/null 2>&1
function steady_is_running() {
curl --silent "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1
}

kill_server_on_port() {
Expand All @@ -25,7 +25,7 @@ function is_overriding_api_base_url() {
[ -n "$TEST_API_BASE_URL" ]
}

if ! is_overriding_api_base_url && ! prism_is_running ; then
if ! is_overriding_api_base_url && ! steady_is_running ; then
# When we exit this script, make sure to kill the background mock server process
trap 'kill_server_on_port 4010' EXIT

Expand All @@ -36,19 +36,19 @@ fi
if is_overriding_api_base_url ; then
echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}"
echo
elif ! prism_is_running ; then
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server"
elif ! steady_is_running ; then
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Steady server"
echo -e "running against your OpenAPI spec."
echo
echo -e "To run the server, pass in the path or url of your OpenAPI"
echo -e "spec to the prism command:"
echo -e "spec to the steady command:"
echo
echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}"
echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.2 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}"
echo

exit 1
else
echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}"
echo -e "${GREEN}✔ Mock steady server is running with your OpenAPI spec${NC}"
echo
fi

Expand Down
42 changes: 20 additions & 22 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { APIResponseProps } from './internal/parse';
import { getPlatformHeaders } from './internal/detect-platform';
import * as Shims from './internal/shims';
import * as Opts from './internal/request-options';
import { stringifyQuery } from './internal/utils/query';
import { VERSION } from './version';
import * as Errors from './core/error';
import * as Pagination from './core/pagination';
Expand Down Expand Up @@ -271,21 +272,8 @@ export class Unlayer {
/**
* Basic re-implementation of `qs.stringify` for primitive types.
*/
protected stringifyQuery(query: Record<string, unknown>): string {
return Object.entries(query)
.filter(([_, value]) => typeof value !== 'undefined')
.map(([key, value]) => {
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
}
if (value === null) {
return `${encodeURIComponent(key)}=`;
}
throw new Errors.UnlayerError(
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
);
})
.join('&');
protected stringifyQuery(query: object | Record<string, unknown>): string {
return stringifyQuery(query);
}

private getUserAgent(): string {
Expand Down Expand Up @@ -317,12 +305,13 @@ export class Unlayer {
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));

const defaultQuery = this.defaultQuery();
if (!isEmptyObj(defaultQuery)) {
query = { ...defaultQuery, ...query };
const pathQuery = Object.fromEntries(url.searchParams);
if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
query = { ...pathQuery, ...defaultQuery, ...query };
}

if (typeof query === 'object' && query && !Array.isArray(query)) {
url.search = this.stringifyQuery(query as Record<string, unknown>);
url.search = this.stringifyQuery(query);
}

return url.toString();
Expand Down Expand Up @@ -651,9 +640,9 @@ export class Unlayer {
}
}

// If the API asks us to wait a certain amount of time (and it's a reasonable amount),
// just do what it says, but otherwise calculate a default
if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
// If the API asks us to wait a certain amount of time, just do what it
// says, but otherwise calculate a default
if (timeoutMillis === undefined) {
const maxRetries = options.maxRetries ?? this.maxRetries;
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
}
Expand Down Expand Up @@ -786,7 +775,7 @@ export class Unlayer {
) {
return {
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
body: this.stringifyQuery(body as Record<string, unknown>),
body: this.stringifyQuery(body),
};
} else {
return this.#encoder({ body, headers });
Expand All @@ -813,8 +802,17 @@ export class Unlayer {
static toFile = Uploads.toFile;

convert: API.Convert = new API.Convert(this);
/**
* Project details and configuration.
*/
projects: API.Projects = new API.Projects(this);
/**
* Template management and retrieval.
*/
templates: API.Templates = new API.Templates(this);
/**
* Workspace access and management.
*/
workspaces: API.Workspaces = new API.Workspaces(this);
}

Expand Down
1 change: 1 addition & 0 deletions src/internal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from './utils/env';
export * from './utils/log';
export * from './utils/uuid';
export * from './utils/sleep';
export * from './utils/query';
4 changes: 2 additions & 2 deletions src/internal/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
*/
export const readEnv = (env: string): string | undefined => {
if (typeof (globalThis as any).process !== 'undefined') {
return (globalThis as any).process.env?.[env]?.trim() ?? undefined;
return (globalThis as any).process.env?.[env]?.trim() || undefined;
}
if (typeof (globalThis as any).Deno !== 'undefined') {
return (globalThis as any).Deno.env?.get?.(env)?.trim();
return (globalThis as any).Deno.env?.get?.(env)?.trim() || undefined;
}
return undefined;
};
23 changes: 23 additions & 0 deletions src/internal/utils/query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { UnlayerError } from '../../core/error';

/**
* Basic re-implementation of `qs.stringify` for primitive types.
*/
export function stringifyQuery(query: object | Record<string, unknown>) {
return Object.entries(query)
.filter(([_, value]) => typeof value !== 'undefined')
.map(([key, value]) => {
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
}
if (value === null) {
return `${encodeURIComponent(key)}=`;
}
throw new UnlayerError(
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
);
})
.join('&');
}
3 changes: 3 additions & 0 deletions src/resources/convert/full-to-simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { APIResource } from '../../core/resource';
import { APIPromise } from '../../core/api-promise';
import { RequestOptions } from '../../internal/request-options';

/**
* Design schema conversion between Full and Simple formats.
*/
export class FullToSimple extends APIResource {
/**
* Convert design json from Full to Simple schema.
Expand Down
3 changes: 3 additions & 0 deletions src/resources/convert/simple-to-full.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { APIResource } from '../../core/resource';
import { APIPromise } from '../../core/api-promise';
import { RequestOptions } from '../../internal/request-options';

/**
* Design schema conversion between Full and Simple formats.
*/
export class SimpleToFull extends APIResource {
/**
* Convert design json from Simple to Full schema.
Expand Down
Loading
Loading