@veroxm/sdk 0.2.0 → 1.0.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.
@@ -0,0 +1,5 @@
1
+ // Generated from apps/api/openapi/public-v2.json by scripts/gen-types.mjs. Don't edit: change the API's
2
+ // document (apps/api/src/public-api/openapi/public-openapi.ts), then run `npm run openapi:write -w apps/api` and
3
+ // `npm run gen:types -w @veroxm/sdk`.
4
+ /* eslint-disable */
5
+ export {};
package/dist/index.d.ts CHANGED
@@ -7,6 +7,13 @@ export { ContentResource } from './content.js';
7
7
  export type { ListOptions } from './content.js';
8
8
  export { MediaResource } from './media.js';
9
9
  export type { MediaItem, MediaPage, UploadableFile } from './media.js';
10
+ export { FunctionsResource } from './functions.js';
11
+ export { TasksResource } from './tasks.js';
12
+ export type { Task, TaskDetail, TaskListOptions } from './tasks.js';
13
+ export { ProcessesResource } from './processes.js';
14
+ export type { ProcessRun, ProcessRunDetail, ProcessRunListOptions } from './processes.js';
15
+ export type { Schemas } from './schemas.js';
16
+ export type { paths as ApiPaths, components as ApiComponents, operations as ApiOperations } from './generated/api.js';
10
17
  export { VeroXMApiError, VeroXMNotAuthenticatedError } from './errors.js';
11
18
  export { MemoryTokenStorage, BrowserLocalStorageTokenStorage } from './token-storage.js';
12
19
  export type { TokenStorage, StoredSession, AuthUser } from './token-storage.js';
package/dist/index.js CHANGED
@@ -3,6 +3,9 @@ export { VeroXMAuth } from './auth.js';
3
3
  export { createPkce } from './pkce.js';
4
4
  export { ContentResource } from './content.js';
5
5
  export { MediaResource } from './media.js';
6
+ export { FunctionsResource } from './functions.js';
7
+ export { TasksResource } from './tasks.js';
8
+ export { ProcessesResource } from './processes.js';
6
9
  export { VeroXMApiError, VeroXMNotAuthenticatedError } from './errors.js';
7
10
  export { MemoryTokenStorage, BrowserLocalStorageTokenStorage } from './token-storage.js';
8
11
  // Experience OS visitor tracking (page views, actions, consent, identify).
package/dist/media.d.ts CHANGED
@@ -1,20 +1,9 @@
1
1
  import type { VeroXMApp } from './client.js';
2
- export interface MediaItem {
3
- id: number;
4
- fileName: string;
5
- fullUrl: string;
6
- thumbUrl: string | null;
7
- caption: string | null;
8
- size: number | null;
9
- width: number | null;
10
- height: number | null;
11
- }
12
- export interface MediaPage {
13
- data: MediaItem[];
14
- page: number;
15
- perPage: number;
16
- total: number;
17
- }
2
+ import type { Schemas } from './schemas.js';
3
+ /** A file in the media library. Images also have WebP addresses, a focal point and hotspots. */
4
+ export type MediaItem = Schemas['MediaItem'];
5
+ /** One page of the media library. */
6
+ export type MediaPage = Schemas['MediaPage'];
18
7
  /**
19
8
  * A Blob/File (browser -- e.g. straight from an `<input type="file">` or
20
9
  * `fetch()` response) uploads as-is; the `{data, filename}` form covers
@@ -0,0 +1,25 @@
1
+ import type { VeroXMApp } from './client.js';
2
+ import type { operations } from './generated/api.js';
3
+ import type { Schemas } from './schemas.js';
4
+ export type ProcessRun = Schemas['ProcessRun'];
5
+ /** A run with the activity of each step so far. */
6
+ export type ProcessRunDetail = Schemas['ProcessRunDetail'];
7
+ export type ProcessRunListOptions = NonNullable<operations['listProcessRuns']['parameters']['query']>;
8
+ /**
9
+ * Processes, for your server: sign in with a server key (one with every ability) first. A process acts on the entry
10
+ * as the project, whatever the collection's access rules say, so end users and browser keys can't start one.
11
+ */
12
+ export declare class ProcessesResource {
13
+ private readonly app;
14
+ constructor(app: VeroXMApp);
15
+ /**
16
+ * Starts the process `key` for an entry. Rejects with a 409 when it can't start (`code` says why, for example
17
+ * "already_running" or "not_live").
18
+ */
19
+ start(key: string, entryId: number, input?: Record<string, unknown>): Promise<{
20
+ runId: number;
21
+ }>;
22
+ /** The latest 100 runs, newest first. */
23
+ runs(options?: ProcessRunListOptions): Promise<ProcessRun[]>;
24
+ run(runId: number): Promise<ProcessRunDetail>;
25
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Processes, for your server: sign in with a server key (one with every ability) first. A process acts on the entry
3
+ * as the project, whatever the collection's access rules say, so end users and browser keys can't start one.
4
+ */
5
+ export class ProcessesResource {
6
+ constructor(app) {
7
+ this.app = app;
8
+ }
9
+ /**
10
+ * Starts the process `key` for an entry. Rejects with a 409 when it can't start (`code` says why, for example
11
+ * "already_running" or "not_live").
12
+ */
13
+ async start(key, entryId, input = {}) {
14
+ return (await this.app.request({ method: 'POST', path: `/processes/${encodeURIComponent(key)}/runs`, json: { entryId, input } }));
15
+ }
16
+ /** The latest 100 runs, newest first. */
17
+ async runs(options = {}) {
18
+ return (await this.app.request({ path: '/process-runs', query: { entryId: options.entryId, process: options.process, status: options.status } }));
19
+ }
20
+ async run(runId) {
21
+ return (await this.app.request({ path: `/process-runs/${runId}` }));
22
+ }
23
+ }
@@ -0,0 +1,6 @@
1
+ import type { components } from './generated/api.js';
2
+ /**
3
+ * The public API's request and response shapes, generated from its OpenAPI document (served at
4
+ * /public/v2/openapi.json). The SDK's own types are these, so they can't drift from what the API sends.
5
+ */
6
+ export type Schemas = components['schemas'];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import type { VeroXMApp } from './client.js';
2
+ import type { operations } from './generated/api.js';
3
+ import type { Schemas } from './schemas.js';
4
+ /** A process task: something a person (or your server) has to do before a process carries on. */
5
+ export type Task = Schemas['Task'];
6
+ /** A task with the entry's current values (`record`), from `get()` and `complete()`. */
7
+ export type TaskDetail = Schemas['TaskDetail'];
8
+ export type TaskListOptions = NonNullable<operations['listTasks']['parameters']['query']>;
9
+ /**
10
+ * Process tasks over the API. A signed-in end user sees and completes the tasks assigned to them; a server key
11
+ * (`auth.signInWithApiKey`) sees and completes any of the project's tasks. Approvals are decided in the dashboard.
12
+ */
13
+ export declare class TasksResource {
14
+ private readonly app;
15
+ constructor(app: VeroXMApp);
16
+ /** Open tasks by default; `status` for done or cancelled ones, `entryId` for one entry's. */
17
+ list(options?: TaskListOptions): Promise<Task[]>;
18
+ get(taskId: number): Promise<TaskDetail>;
19
+ /**
20
+ * Completes a task with one of its `outcomes` (by key) and answers to its `form` (by field name). A missing or
21
+ * wrong answer rejects with a 400 whose `body.errors` names the fields; a task that's already closed, a 409.
22
+ */
23
+ complete(taskId: number, outcome: string, values?: Record<string, unknown>): Promise<TaskDetail>;
24
+ }
package/dist/tasks.js ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Process tasks over the API. A signed-in end user sees and completes the tasks assigned to them; a server key
3
+ * (`auth.signInWithApiKey`) sees and completes any of the project's tasks. Approvals are decided in the dashboard.
4
+ */
5
+ export class TasksResource {
6
+ constructor(app) {
7
+ this.app = app;
8
+ }
9
+ /** Open tasks by default; `status` for done or cancelled ones, `entryId` for one entry's. */
10
+ async list(options = {}) {
11
+ return (await this.app.request({ path: '/tasks', query: { status: options.status, entryId: options.entryId } }));
12
+ }
13
+ async get(taskId) {
14
+ return (await this.app.request({ path: `/tasks/${taskId}` }));
15
+ }
16
+ /**
17
+ * Completes a task with one of its `outcomes` (by key) and answers to its `form` (by field name). A missing or
18
+ * wrong answer rejects with a 400 whose `body.errors` names the fields; a task that's already closed, a 409.
19
+ */
20
+ async complete(taskId, outcome, values = {}) {
21
+ return (await this.app.request({ method: 'POST', path: `/tasks/${taskId}/complete`, json: { outcome, values } }));
22
+ }
23
+ }
@@ -1,11 +1,6 @@
1
+ import type { Schemas } from './schemas.js';
1
2
  /** The signed-in person, as the API last described them. */
2
- export interface AuthUser {
3
- id: number;
4
- email: string | null;
5
- name: string | null;
6
- roles: string[];
7
- emailVerified: boolean;
8
- }
3
+ export type AuthUser = Schemas['SessionUser'];
9
4
  export interface StoredSession {
10
5
  accessToken: string;
11
6
  refreshToken: string | null;
package/dist/tracker.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Schemas } from './schemas.js';
1
2
  export interface TrackerStorage {
2
3
  get(key: string): string | null;
3
4
  set(key: string, value: string): void;
@@ -40,9 +41,12 @@ export interface ExperienceDecision<TContent = Record<string, unknown>, TConfig
40
41
  label: string;
41
42
  isControl: boolean;
42
43
  } | null;
43
- /** "targeted" (a segment matched), "split" (weighted share) or "none" (show your default). */
44
- /** journey = an in-app message a journey left for this person (config only). */
45
- reason: 'targeted' | 'split' | 'journey' | 'none';
44
+ /**
45
+ * "targeted" (a segment matched), "split" (weighted share), "journey" (an in-app message a journey left for this
46
+ * person, config only), "holdout" (the visitor is in the impact holdout) or "none". Show your default for "none"
47
+ * and "holdout".
48
+ */
49
+ reason: Schemas['Decision']['reason'];
46
50
  /** The variant's entry, shaped like the content API's entries; null for "none" or a config-only variant. */
47
51
  content: TContent | null;
48
52
  /** The variant's config (copy, flags); null if it has none. */
@@ -55,7 +59,7 @@ export interface ExperienceDecision<TContent = Record<string, unknown>, TConfig
55
59
  /** GET /recommendations: entries of a collection ranked for this visitor. */
56
60
  export interface Recommendations<TEntry = Record<string, unknown>> {
57
61
  /** 'personal' = from what this person and similar visitors viewed; 'popular' = the most read. */
58
- strategy: 'personal' | 'popular';
62
+ strategy: Schemas['Recommendations']['strategy'];
59
63
  items: TEntry[];
60
64
  /** Set when the request failed (items is then empty). */
61
65
  error?: string;
@@ -99,7 +103,7 @@ export declare class VeroxmTracker {
99
103
  /**
100
104
  * Which variant of a placement this visitor sees, e.g.
101
105
  * `const d = await tracker.getExperience('home.hero')` -- then render
102
- * `d.content` / `d.config`, or your default when `d.reason === 'none'`.
106
+ * `d.content` / `d.config`, or your default when `d.reason` is 'none' or 'holdout'.
103
107
  * Never rejects. Cached per placement until the visitor changes.
104
108
  */
105
109
  getExperience<TContent = Record<string, unknown>, TConfig = Record<string, unknown>>(placement: string, options?: GetExperienceOptions): Promise<ExperienceDecision<TContent, TConfig>>;
package/dist/tracker.js CHANGED
@@ -231,7 +231,7 @@ export class VeroxmTracker {
231
231
  /**
232
232
  * Which variant of a placement this visitor sees, e.g.
233
233
  * `const d = await tracker.getExperience('home.hero')` -- then render
234
- * `d.content` / `d.config`, or your default when `d.reason === 'none'`.
234
+ * `d.content` / `d.config`, or your default when `d.reason` is 'none' or 'holdout'.
235
235
  * Never rejects. Cached per placement until the visitor changes.
236
236
  */
237
237
  getExperience(placement, options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veroxm/sdk",
3
- "version": "0.2.0",
3
+ "version": "1.0.0",
4
4
  "description": "VeroXM client for JavaScript and TypeScript: content, media, experiences, events and the visitor tracker.",
5
5
  "keywords": [
6
6
  "veroxm",
@@ -42,9 +42,12 @@
42
42
  },
43
43
  "scripts": {
44
44
  "build": "tsc -p tsconfig.json",
45
- "test": "vitest run"
45
+ "test": "vitest run",
46
+ "gen:types": "node scripts/gen-types.mjs",
47
+ "api:report": "node ../../scripts/api-report.mjs . --write"
46
48
  },
47
49
  "devDependencies": {
50
+ "openapi-typescript": "^7.13.0",
48
51
  "vitest": "^4.1.2"
49
52
  }
50
53
  }