@templr/sdk 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -6
- package/README.md +5 -1
- package/dist/index.d.ts +1 -1
- package/dist/resources/templates.d.ts +11 -4
- package/dist/resources/templates.js +4 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,20 +7,23 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.0] - 2026-12-03
|
|
11
|
+
|
|
10
12
|
### Added
|
|
11
13
|
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
- `UploadError`, thrown when the storage bucket rejects the file of an upload.
|
|
14
|
+
- `order` option (`'desc'`, the default, or `'asc'`) in `templates.list` and `templates.listDrafts` to list the
|
|
15
|
+
oldest templates first, with the `SortOrder` and `ListTemplatesOptions` types.
|
|
15
16
|
|
|
16
|
-
## [0.1.0]
|
|
17
|
+
## [0.1.0] - 2026-12-03
|
|
17
18
|
|
|
18
19
|
### Added
|
|
19
20
|
|
|
20
21
|
- `Templr` client for the Templr REST API v1, authenticated with a workspace API key. It runs anywhere
|
|
21
22
|
`fetch` exists: Node.js 20.19+, Bun, Deno and edge runtimes.
|
|
22
|
-
- Templates: `list`, `listDrafts`, `get`, `getDraft` and `
|
|
23
|
-
- Assets: `list`, `createUpload`, `confirm` and `delete`.
|
|
23
|
+
- Templates: `list`, `listDrafts`, `get`, `getDraft`, `render`, `listVariables` and `updateVariable`.
|
|
24
|
+
- Assets: `list`, `upload`, `createUpload`, `confirm` and `delete`. `upload` starts an upload, sends the file
|
|
25
|
+
to the storage bucket and confirms it in one call.
|
|
24
26
|
- `getOpenApiDocument` to read the OpenAPI document served by an instance.
|
|
25
27
|
- Responses validated with Zod, returned as frozen objects with `Date` timestamps.
|
|
26
28
|
- Typed errors with a machine-readable `code`, one class per HTTP status family.
|
|
29
|
+
- `UploadError`, thrown when the storage bucket rejects the file of an upload.
|
package/README.md
CHANGED
|
@@ -74,6 +74,9 @@ for (const version of page.items) {
|
|
|
74
74
|
// Every template with its draft, most recently updated first
|
|
75
75
|
const drafts = await templr.templates.listDrafts();
|
|
76
76
|
|
|
77
|
+
// Oldest first: `order: 'asc'` (the default is 'desc')
|
|
78
|
+
const oldest = await templr.templates.list({ order: 'asc' });
|
|
79
|
+
|
|
77
80
|
// One template, with its document
|
|
78
81
|
const version = await templr.templates.get(templateId); // latest published version
|
|
79
82
|
const draft = await templr.templates.getDraft(templateId); // draft
|
|
@@ -101,7 +104,8 @@ const variable = await templr.templates.updateVariable(templateId, 'name', { fal
|
|
|
101
104
|
### Pagination
|
|
102
105
|
|
|
103
106
|
Lists return a `Page` with `items`, `total` (the size of the whole list) and `nextCursor`, which is
|
|
104
|
-
`null` on the last page.
|
|
107
|
+
`null` on the last page. When listing templates with `order`, pass the same `order` with each
|
|
108
|
+
`cursor`.
|
|
105
109
|
|
|
106
110
|
```ts
|
|
107
111
|
let cursor: string | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
export { Templr, type TemplrOptions } from './client.js';
|
|
16
16
|
export { APIConnectionError, APIError, type APIErrorDetails, APITimeoutError, AuthenticationError, BadRequestError, ConflictError, InternalServerError, NotFoundError, PayloadTooLargeError, PermissionDeniedError, RateLimitError, TemplrError, UnexpectedResponseError, UploadError, } from './errors.js';
|
|
17
17
|
export type { Assets, CreateUploadOptions, UploadOptions } from './resources/assets.js';
|
|
18
|
-
export type { ListOptions, ListVariablesOptions, RenderOptions, Templates, UpdateVariableOptions } from './resources/templates.js';
|
|
18
|
+
export type { ListOptions, ListTemplatesOptions, ListVariablesOptions, RenderOptions, SortOrder, Templates, UpdateVariableOptions } from './resources/templates.js';
|
|
19
19
|
export type { Asset, AssetUpload, Deleted, ImageContentType, JsonValue, OpenApiDocument, Page, PresignedUpload, RenderedTemplate, Template, TemplateDocument, TemplateMark, TemplateNode, TemplateSummary, TemplateVariable, TemplateVersion, TemplateVersionSummary, } from './schemas.js';
|
|
20
20
|
export type { Fetch } from './transport.js';
|
|
21
21
|
export { VERSION } from './version.js';
|
|
@@ -12,6 +12,13 @@ export interface ListOptions {
|
|
|
12
12
|
/** Items per page, from 1 to 100 (the API defaults to 20). */
|
|
13
13
|
readonly limit?: number;
|
|
14
14
|
}
|
|
15
|
+
/** The order of the template lists: newest first (`desc`, the default) or oldest first (`asc`). */
|
|
16
|
+
export type SortOrder = 'desc' | 'asc';
|
|
17
|
+
/** Options of {@link Templates.list} and {@link Templates.listDrafts}. */
|
|
18
|
+
export interface ListTemplatesOptions extends ListOptions {
|
|
19
|
+
/** `asc` lists the oldest first; keep the same order when passing `cursor`. The API defaults to `desc`. */
|
|
20
|
+
readonly order?: SortOrder;
|
|
21
|
+
}
|
|
15
22
|
/** Options of {@link Templates.render}. */
|
|
16
23
|
export interface RenderOptions {
|
|
17
24
|
/** Render the draft instead of the latest published version. */
|
|
@@ -41,10 +48,10 @@ export declare class Templates {
|
|
|
41
48
|
#private;
|
|
42
49
|
/** @internal */
|
|
43
50
|
constructor(transport: Transport);
|
|
44
|
-
/** Lists the published templates, each with its latest version, most recently published first. */
|
|
45
|
-
list(options?:
|
|
46
|
-
/** Lists every template with its draft, most recently updated first. */
|
|
47
|
-
listDrafts(options?:
|
|
51
|
+
/** Lists the published templates, each with its latest version, most recently published first (oldest first with `order: 'asc'`). */
|
|
52
|
+
list(options?: ListTemplatesOptions): Promise<Page<TemplateVersionSummary>>;
|
|
53
|
+
/** Lists every template with its draft, most recently updated first (oldest first with `order: 'asc'`). */
|
|
54
|
+
listDrafts(options?: ListTemplatesOptions): Promise<Page<TemplateSummary>>;
|
|
48
55
|
/**
|
|
49
56
|
* Gets the latest published version of a template, with its document.
|
|
50
57
|
*
|
|
@@ -19,13 +19,13 @@ export class Templates {
|
|
|
19
19
|
constructor(transport) {
|
|
20
20
|
this.#transport = transport;
|
|
21
21
|
}
|
|
22
|
-
/** Lists the published templates, each with its latest version, most recently published first. */
|
|
22
|
+
/** Lists the published templates, each with its latest version, most recently published first (oldest first with `order: 'asc'`). */
|
|
23
23
|
list(options = {}) {
|
|
24
|
-
return this.#transport.send({ method: 'GET', path: '/api/v1/templates', query: { cursor: options.cursor, limit: options.limit } }, versionPage);
|
|
24
|
+
return this.#transport.send({ method: 'GET', path: '/api/v1/templates', query: { cursor: options.cursor, limit: options.limit, order: options.order } }, versionPage);
|
|
25
25
|
}
|
|
26
|
-
/** Lists every template with its draft, most recently updated first. */
|
|
26
|
+
/** Lists every template with its draft, most recently updated first (oldest first with `order: 'asc'`). */
|
|
27
27
|
listDrafts(options = {}) {
|
|
28
|
-
return this.#transport.send({ method: 'GET', path: '/api/v1/templates', query: { cursor: options.cursor, draft: 'true', limit: options.limit } }, draftPage);
|
|
28
|
+
return this.#transport.send({ method: 'GET', path: '/api/v1/templates', query: { cursor: options.cursor, draft: 'true', limit: options.limit, order: options.order } }, draftPage);
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Gets the latest published version of a template, with its document.
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The version of this SDK; kept equal to `package.json` by a test. */
|
|
2
|
-
export declare const VERSION = "0.
|
|
2
|
+
export declare const VERSION = "0.2.0";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The version of this SDK; kept equal to `package.json` by a test. */
|
|
2
|
-
export const VERSION = '0.
|
|
2
|
+
export const VERSION = '0.2.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@templr/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Official TypeScript SDK for the Templr REST API.",
|
|
5
5
|
"keywords": ["templr", "email", "email-templates", "react-email", "sdk", "api-client"],
|
|
6
6
|
"homepage": "https://github.com/SebastianUrdaneguiBisalaya/templr/tree/main/sdks/typescript#readme",
|