@picked/delivery-api-client 0.0.117-next.2 → 0.0.117
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/dist/cjs/action-response.d.ts +75 -0
- package/dist/cjs/action-response.d.ts.map +1 -0
- package/dist/cjs/actions.d.ts +73 -0
- package/dist/cjs/actions.d.ts.map +1 -0
- package/dist/cjs/client-headers.d.ts +20 -0
- package/dist/cjs/client-headers.d.ts.map +1 -0
- package/dist/cjs/fetch-utils-internal.d.ts +22 -0
- package/dist/cjs/fetch-utils-internal.d.ts.map +1 -0
- package/dist/cjs/fetch.d.ts +36 -0
- package/dist/cjs/fetch.d.ts.map +1 -0
- package/dist/cjs/http.d.ts +30 -0
- package/dist/cjs/http.d.ts.map +1 -0
- package/dist/cjs/index.d.ts +10 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/project-config.d.ts +255 -0
- package/dist/cjs/project-config.d.ts.map +1 -0
- package/dist/cjs/types.d.ts +81 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/types/fetch-utils-internal.d.ts +1 -1
- package/dist/types/fetch.d.ts +1 -1
- package/dist/types/index.d.ts +8 -8
- package/dist/types/types.d.ts +1 -1
- package/package.json +11 -6
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** The longest the SDK looks for one run's action response unless told otherwise: an hour. */
|
|
2
|
+
export declare const DEFAULT_ACTION_RESPONSE_TIMEOUT_MS = 3600000;
|
|
3
|
+
/** The run whose response to wait for. */
|
|
4
|
+
export type WaitForActionResponseParams = {
|
|
5
|
+
/** The run `runAction` returned with `status: 'pending'`. */
|
|
6
|
+
workflowRunId: string;
|
|
7
|
+
/** The project the action belongs to. */
|
|
8
|
+
projectId: string;
|
|
9
|
+
} & ({
|
|
10
|
+
/** The Picked ID of the visitor who started the action. */
|
|
11
|
+
pickedId: string;
|
|
12
|
+
} | {
|
|
13
|
+
/** @deprecated Use `pickedId`. */
|
|
14
|
+
sessionId: string;
|
|
15
|
+
});
|
|
16
|
+
/** Options for `waitForActionResponse`. */
|
|
17
|
+
export interface WaitForActionResponseOptions {
|
|
18
|
+
/** The longest to wait for the response; an hour unless set. */
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
/** Stops the wait. */
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
/** Extra request headers. */
|
|
23
|
+
headers?: Record<string, string>;
|
|
24
|
+
}
|
|
25
|
+
/** How the wait ended: with the response, or with none coming. */
|
|
26
|
+
export type ActionResponse = {
|
|
27
|
+
status: 'succeeded';
|
|
28
|
+
response: unknown;
|
|
29
|
+
} | {
|
|
30
|
+
status: 'no_response';
|
|
31
|
+
};
|
|
32
|
+
/** Raised when the response has not arrived within the time allowed. */
|
|
33
|
+
export declare class ActionResponseTimeoutError extends Error {
|
|
34
|
+
readonly workflowRunId: string;
|
|
35
|
+
/**
|
|
36
|
+
* Builds the error for one run.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} workflowRunId - The run waited on.
|
|
39
|
+
* @example throw new ActionResponseTimeoutError('wkrun_1')
|
|
40
|
+
*/
|
|
41
|
+
constructor(workflowRunId: string);
|
|
42
|
+
}
|
|
43
|
+
/** Raised when the run failed before it responded. */
|
|
44
|
+
export declare class ActionRunFailedError extends Error {
|
|
45
|
+
readonly workflowRunId: string;
|
|
46
|
+
/**
|
|
47
|
+
* Builds the error for one run.
|
|
48
|
+
*
|
|
49
|
+
* @param {string} workflowRunId - The run that failed.
|
|
50
|
+
* @example throw new ActionRunFailedError('wkrun_1')
|
|
51
|
+
*/
|
|
52
|
+
constructor(workflowRunId: string);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Waits for the response of an action run whose workflow carries on after the request.
|
|
56
|
+
*
|
|
57
|
+
* A pending poll is followed at once by the next. A poll that errors — a network failure, a
|
|
58
|
+
* timeout, a 5xx or an unreadable body — is retried after a wait that doubles from one
|
|
59
|
+
* second to thirty, up to 14 times in a row.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} apiUrl - Base URL for the Picked API.
|
|
62
|
+
* @param {WaitForActionResponseParams} params - The run, its project, and the visitor's session.
|
|
63
|
+
* @param {WaitForActionResponseOptions} [options] - Ceiling, signal and headers.
|
|
64
|
+
* @returns {Promise<ActionResponse>} The response, or that none is coming.
|
|
65
|
+
* @throws {ActionRunFailedError} When the run failed before it responded.
|
|
66
|
+
* @throws {ActionResponseTimeoutError} When the ceiling passes first.
|
|
67
|
+
* @throws {Error} When the API refuses a poll (4xx), a poll errors more than 14 times in a row, or the signal aborts.
|
|
68
|
+
* @example
|
|
69
|
+
* const result = await runAction(apiUrl, payload)
|
|
70
|
+
* if (result.status === 'pending' && result.workflowRunId) {
|
|
71
|
+
* await waitForActionResponse(apiUrl, { workflowRunId: result.workflowRunId, projectId, pickedId })
|
|
72
|
+
* }
|
|
73
|
+
*/
|
|
74
|
+
export declare function waitForActionResponse(apiUrl: string, params: WaitForActionResponseParams, options?: WaitForActionResponseOptions): Promise<ActionResponse>;
|
|
75
|
+
//# sourceMappingURL=action-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-response.d.ts","sourceRoot":"","sources":["../../src/action-response.ts"],"names":[],"mappings":"AAeA,8FAA8F;AAC9F,eAAO,MAAM,kCAAkC,UAAY,CAAA;AAE3D,0CAA0C;AAC1C,MAAM,MAAM,2BAA2B,GAAG;IACxC,6DAA6D;IAC7D,aAAa,EAAE,MAAM,CAAA;IACrB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAA;CAClB,GAAG,CACA;IACE,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAA;CACjB,GACD;IACE,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAA;CAClB,CACJ,CAAA;AAED,2CAA2C;AAC3C,MAAM,WAAW,4BAA4B;IAC3C,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,sBAAsB;IACtB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACjC;AAED,kEAAkE;AAClE,MAAM,MAAM,cAAc,GAAG;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,aAAa,CAAA;CAAE,CAAA;AAEnG,wEAAwE;AACxE,qBAAa,0BAA2B,SAAQ,KAAK;IAOvC,QAAQ,CAAC,aAAa,EAAE,MAAM;IAN1C;;;;;OAKG;IACH,YAAqB,aAAa,EAAE,MAAM,EAGzC;CACF;AAED,sDAAsD;AACtD,qBAAa,oBAAqB,SAAQ,KAAK;IAOjC,QAAQ,CAAC,aAAa,EAAE,MAAM;IAN1C;;;;;OAKG;IACH,YAAqB,aAAa,EAAE,MAAM,EAGzC;CACF;AAoID;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,2BAA2B,EACnC,OAAO,CAAC,EAAE,4BAA4B,GACrC,OAAO,CAAC,cAAc,CAAC,CA6BzB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/** Payload for the action run endpoint. The action's key goes in the path. */
|
|
2
|
+
export type RunActionPayload = RunActionFields & ({
|
|
3
|
+
/** The visitor's Picked ID. */
|
|
4
|
+
pickedId: string;
|
|
5
|
+
} | {
|
|
6
|
+
/** @deprecated Use `pickedId`. */
|
|
7
|
+
session: {
|
|
8
|
+
id: string;
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
/** The fields of {@link RunActionPayload} beside the visitor's Picked ID. */
|
|
12
|
+
export interface RunActionFields {
|
|
13
|
+
/** The action's workspace-scoped key. */
|
|
14
|
+
key: string;
|
|
15
|
+
/** The project the caller belongs to. */
|
|
16
|
+
projectId: string;
|
|
17
|
+
/**
|
|
18
|
+
* Responses for the fields the action requests, keyed by field key. The API
|
|
19
|
+
* discards any key the action does not request, so sending more than the
|
|
20
|
+
* contract names widens nothing.
|
|
21
|
+
*/
|
|
22
|
+
responses: Record<string, unknown>;
|
|
23
|
+
/**
|
|
24
|
+
* The published version the caller read the action's contract from. Advisory:
|
|
25
|
+
* the API resolves the contract itself and reports a mismatch rather than
|
|
26
|
+
* refusing the call.
|
|
27
|
+
*/
|
|
28
|
+
versionId?: string | null;
|
|
29
|
+
}
|
|
30
|
+
/** Options for {@link runAction}. */
|
|
31
|
+
export interface RunActionOptions {
|
|
32
|
+
headers?: Record<string, string>;
|
|
33
|
+
/** Preview token, which names the workspace to act on and forces the preview surface. */
|
|
34
|
+
previewToken?: string;
|
|
35
|
+
signal?: AbortSignal;
|
|
36
|
+
/** The longest the post may take; 10 seconds unless set. */
|
|
37
|
+
timeoutMs?: number;
|
|
38
|
+
}
|
|
39
|
+
/** Whether the API has the action's response: in hand, still to come, or not coming. */
|
|
40
|
+
export type ActionRunStatus = 'succeeded' | 'pending' | 'no_response';
|
|
41
|
+
/** What the API returns when it accepts a run. */
|
|
42
|
+
export interface RunActionResult {
|
|
43
|
+
actionRunId: string;
|
|
44
|
+
/** The run to give `waitForActionResponse`; set when `status` is `pending`. */
|
|
45
|
+
workflowRunId: string | null;
|
|
46
|
+
/** Whether the API has the action's response. */
|
|
47
|
+
status: ActionRunStatus;
|
|
48
|
+
/** The action's response, present when `status` is `succeeded`. */
|
|
49
|
+
response?: unknown;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Starts a server-side action run.
|
|
53
|
+
*
|
|
54
|
+
* Rejects when the API refuses the call, so a caller inside an experience flow
|
|
55
|
+
* routes to its failure edge on a refusal and its success edge otherwise.
|
|
56
|
+
* A `202` means the run was recorded. Its `status` says whether the response is in
|
|
57
|
+
* `response`, still to come from `waitForActionResponse`, or not coming.
|
|
58
|
+
*
|
|
59
|
+
* @param {string} apiUrl - Base URL for the Picked API.
|
|
60
|
+
* @param {RunActionPayload} payload - The run to start.
|
|
61
|
+
* @param {RunActionOptions} [options] - Optional headers, preview token, abort signal and timeout.
|
|
62
|
+
* @returns {Promise<RunActionResult>} The recorded run's id, whether the API has its response, and the response or the run to poll.
|
|
63
|
+
* @throws {Error} When the API responds with a non-2xx status, or a `TimeoutError` when the post outlasts its timeout.
|
|
64
|
+
* @example
|
|
65
|
+
* await runAction('https://api.picked.app', {
|
|
66
|
+
* key: 'submit-lead',
|
|
67
|
+
* projectId: 'proj_1',
|
|
68
|
+
* pickedId: '3f2a9c1e-5b7d-4e1a-9c2b-8d6f0a4e7b13',
|
|
69
|
+
* responses: { email: 'a@b.c' },
|
|
70
|
+
* })
|
|
71
|
+
*/
|
|
72
|
+
export declare function runAction(apiUrl: string, payload: RunActionPayload, options?: RunActionOptions): Promise<RunActionResult>;
|
|
73
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/actions.ts"],"names":[],"mappings":"AAGA,8EAA8E;AAC9E,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAC5C,CACI;IACE,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAA;CACjB,GACD;IACE,kCAAkC;IAClC,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAA;CACxB,CACJ,CAAA;AAEH,6EAA6E;AAC7E,MAAM,WAAW,eAAe;IAC9B,yCAAyC;IACzC,GAAG,EAAE,MAAM,CAAA;IACX,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1B;AAED,qCAAqC;AACrC,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,yFAAyF;IACzF,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wFAAwF;AACxF,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,SAAS,GAAG,aAAa,CAAA;AAKrE,kDAAkD;AAClD,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAA;IACnB,+EAA+E;IAC/E,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,iDAAiD;IACjD,MAAM,EAAE,eAAe,CAAA;IACvB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAeD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,EACzB,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,eAAe,CAAC,CA2C1B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** @file Default Picked API client identification headers. */
|
|
2
|
+
/**
|
|
3
|
+
* Builds the standard Picked client identification headers.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} name - Client name (for example `sdk` or `vite-plugin`).
|
|
6
|
+
* @param {string} version - Semantic version string.
|
|
7
|
+
* @returns {Record<string, string>} Header map including `Picked-Client` and `Picked-Version`.
|
|
8
|
+
* @example
|
|
9
|
+
* createClientHeaders('sdk', '1.0.0')
|
|
10
|
+
*/
|
|
11
|
+
export declare function createClientHeaders(name: string, version: string): Record<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the package version injected at build time.
|
|
14
|
+
*
|
|
15
|
+
* @returns {string} The semver string.
|
|
16
|
+
* @example
|
|
17
|
+
* getPackageVersion()
|
|
18
|
+
*/
|
|
19
|
+
export declare function getPackageVersion(): string;
|
|
20
|
+
//# sourceMappingURL=client-headers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-headers.d.ts","sourceRoot":"","sources":["../../src/client-headers.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAK9D;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKzF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FetchProjectOptions } from './types.js';
|
|
2
|
+
interface FetchJsonParams<T> {
|
|
3
|
+
apiUrl: string;
|
|
4
|
+
path: string;
|
|
5
|
+
options?: FetchProjectOptions;
|
|
6
|
+
failureMessage: string;
|
|
7
|
+
parseFailureMessage: string;
|
|
8
|
+
invalidShapeMessage: string;
|
|
9
|
+
isValid: (data: unknown) => data is T;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Performs a GET request, parses JSON, and validates the response shape.
|
|
13
|
+
*
|
|
14
|
+
* @template T
|
|
15
|
+
* @param {FetchJsonParams<T>} params - Request and validation parameters.
|
|
16
|
+
* @returns {Promise<T | null>} Parsed payload or `null` on failure.
|
|
17
|
+
* @example
|
|
18
|
+
* const config = await fetchJson({ apiUrl, path: '/config', failureMessage, parseFailureMessage, invalidShapeMessage, isValid })
|
|
19
|
+
*/
|
|
20
|
+
declare function fetchJson<T>(params: FetchJsonParams<T>): Promise<T | null>;
|
|
21
|
+
export { fetchJson };
|
|
22
|
+
//# sourceMappingURL=fetch-utils-internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-utils-internal.d.ts","sourceRoot":"","sources":["../../src/fetch-utils-internal.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAgFlD,UAAU,eAAe,CAAC,CAAC;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,mBAAmB,CAAA;IAC7B,cAAc,EAAE,MAAM,CAAA;IACtB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,mBAAmB,EAAE,MAAM,CAAA;IAC3B,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,IAAI,CAAC,CAAA;CACtC;AAED;;;;;;;;GAQG;AACH,iBAAe,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAkDzE;AAED,OAAO,EAAE,SAAS,EAAE,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ExperienceContentResponse, FetchProjectOptions, FetchSchemaOptions, ProjectConfig, WorkspaceSchema } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Fetches the project configuration from the Picked REST API.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} apiUrl - Base URL for the Picked API.
|
|
6
|
+
* @param {string} projectId - Project ID to fetch config for.
|
|
7
|
+
* @param {FetchProjectOptions} [options] - Optional headers and preview token.
|
|
8
|
+
* @returns {Promise<ProjectConfig | null>} Validated project config, or `null` on any failure.
|
|
9
|
+
* @example
|
|
10
|
+
* const config = await fetchProject('https://api.picked.app', 'proj_123')
|
|
11
|
+
*/
|
|
12
|
+
export declare function fetchProject(apiUrl: string, projectId: string, options?: FetchProjectOptions): Promise<ProjectConfig | null>;
|
|
13
|
+
/**
|
|
14
|
+
* Fetches per-experience content from the Picked API.
|
|
15
|
+
*
|
|
16
|
+
* @param {string} apiUrl - Base URL for the Picked API.
|
|
17
|
+
* @param {string} projectId - Project ID to fetch content for.
|
|
18
|
+
* @param {string} experienceId - Experience ID whose content to fetch.
|
|
19
|
+
* @param {FetchProjectOptions} [options] - Optional headers, preview token, and abort signal.
|
|
20
|
+
* @returns {Promise<ExperienceContentResponse | null>} Validated content response, or `null` on failure.
|
|
21
|
+
* @example
|
|
22
|
+
* const content = await fetchExperienceContent('https://api.picked.app', 'proj_1', 'exp_1')
|
|
23
|
+
*/
|
|
24
|
+
export declare function fetchExperienceContent(apiUrl: string, projectId: string, experienceId: string, options?: FetchProjectOptions): Promise<ExperienceContentResponse | null>;
|
|
25
|
+
/**
|
|
26
|
+
* Fetches the workspace schema document from the Picked API.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} apiUrl - Base URL for the Picked API.
|
|
29
|
+
* @param {string} projectId - Project ID whose schema to fetch.
|
|
30
|
+
* @param {FetchSchemaOptions} [options] - Optional preview token and headers.
|
|
31
|
+
* @returns {Promise<WorkspaceSchema | null>} Validated schema document, or `null` on failure.
|
|
32
|
+
* @example
|
|
33
|
+
* const schema = await fetchSchema('https://api.picked.app', 'proj_1')
|
|
34
|
+
*/
|
|
35
|
+
export declare function fetchSchema(apiUrl: string, projectId: string, options?: FetchSchemaOptions): Promise<WorkspaceSchema | null>;
|
|
36
|
+
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/fetch.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,yBAAyB,EACzB,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,eAAe,EAChB,MAAM,SAAS,CAAA;AAgChB;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAc/B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAc3C;AAED;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAcjC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performs a GET request against the Picked API.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} baseUrl - The API origin.
|
|
5
|
+
* @param {string} path - The path relative to `/api/v1/`.
|
|
6
|
+
* @param {string} clientName - Value for the `Picked-Client` header.
|
|
7
|
+
* @param {Record<string, string>} [headers] - Optional header overrides.
|
|
8
|
+
* @param {AbortSignal} [signal] - Optional abort signal.
|
|
9
|
+
* @param {number} [timeoutMs] - The longest the request may take; 10 seconds unless set.
|
|
10
|
+
* @returns {Promise<Response>} The fetch response.
|
|
11
|
+
* @example
|
|
12
|
+
* const response = await apiGet('https://api.picked.app', 'projects/p1', 'sdk')
|
|
13
|
+
*/
|
|
14
|
+
export declare function apiGet(baseUrl: string, path: string, clientName: string, headers?: Record<string, string>, signal?: AbortSignal, timeoutMs?: number): Promise<Response>;
|
|
15
|
+
/**
|
|
16
|
+
* Performs a POST request against the Picked API.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} baseUrl - The API origin.
|
|
19
|
+
* @param {string} path - The path relative to `/api/v1/`.
|
|
20
|
+
* @param {unknown} body - JSON-serialisable request body.
|
|
21
|
+
* @param {string} clientName - Value for the `Picked-Client` header.
|
|
22
|
+
* @param {Record<string, string>} [headers] - Optional header overrides.
|
|
23
|
+
* @param {AbortSignal} [signal] - Optional abort signal, combined with the timeout.
|
|
24
|
+
* @param {number} [timeoutMs] - The longest the request may take; 10 seconds unless set.
|
|
25
|
+
* @returns {Promise<Response>} The fetch response.
|
|
26
|
+
* @example
|
|
27
|
+
* const response = await apiPost('https://api.picked.app', 'action/welcome/run', body, 'sdk')
|
|
28
|
+
*/
|
|
29
|
+
export declare function apiPost(baseUrl: string, path: string, body: unknown, clientName: string, headers?: Record<string, string>, signal?: AbortSignal, timeoutMs?: number): Promise<Response>;
|
|
30
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":"AAiDA;;;;;;;;;;;;GAYG;AACH,wBAAsB,MAAM,CAC1B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,MAAM,CAAC,EAAE,WAAW,EACpB,SAAS,SAA6B,GACrC,OAAO,CAAC,QAAQ,CAAC,CAOnB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,OAAO,CAC3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,MAAM,CAAC,EAAE,WAAW,EACpB,SAAS,SAA6B,GACrC,OAAO,CAAC,QAAQ,CAAC,CAYnB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @file Public exports for `\@picked/delivery-api-client`. */
|
|
2
|
+
export { createClientHeaders, getPackageVersion } from './client-headers.js';
|
|
3
|
+
export { fetchExperienceContent, fetchProject, fetchSchema } from './fetch.js';
|
|
4
|
+
export { runAction } from './actions.js';
|
|
5
|
+
export type { ActionRunStatus, RunActionPayload, RunActionOptions, RunActionResult, } from './actions.js';
|
|
6
|
+
export { ActionResponseTimeoutError, ActionRunFailedError, DEFAULT_ACTION_RESPONSE_TIMEOUT_MS, waitForActionResponse, } from './action-response.js';
|
|
7
|
+
export type { ActionResponse, WaitForActionResponseOptions, WaitForActionResponseParams, } from './action-response.js';
|
|
8
|
+
export { isWorkspaceSchema } from './types.js';
|
|
9
|
+
export type * from './types.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GAChB,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,kCAAkC,EAClC,qBAAqB,GACtB,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EACV,cAAc,EACd,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,mBAAmB,SAAS,CAAA"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`Picked-Client`,t=`Picked-Version`;function n(n,r){return{[e]:n,[t]:r}}function r(){return`0.0.117
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`Picked-Client`,t=`Picked-Version`;function n(n,r){return{[e]:n,[t]:r}}function r(){return`0.0.117`}var i=`v1`,a=1e4;function o(e,t){let n=AbortSignal.timeout(t);return e?AbortSignal.any([e,n]):n}function s(e,t){return new URL(`/api/${i}/${t}`,e).toString()}function c(e,t){return{...n(e,r()),...t}}async function l(e,t,n,r,i,l=a){let u=s(e,t);return fetch(u,{headers:c(n,r),signal:o(i,l)})}async function u(e,t,n,r,i,l,u=a){let d=s(e,t);return fetch(d,{method:`POST`,headers:{"Content-Type":`application/json`,...c(r,i)},body:JSON.stringify(n),signal:o(l,u)})}function d(e){try{let t=new URL(e).hostname;return t===`localhost`||t===`127.0.0.1`||t===`::1`}catch{return!1}}function f(e){if(typeof e!=`object`||!e||!(`cause`in e))return!1;let{cause:t}=e;return typeof t!=`object`||!t||!(`code`in t)?!1:t.code===`ECONNREFUSED`}function p(e,t,n){e?.onWarn?.(t,n)}async function m(e){try{let t=await e.json();if(typeof t==`object`&&t&&`error`in t){let{error:e}=t;return typeof e==`string`&&e.length>0?e:null}}catch{return null}return null}async function h(e){let{apiUrl:t,path:n,options:r,failureMessage:i,parseFailureMessage:a,invalidShapeMessage:o,isValid:s}=e,c;try{c=await l(t,n,`sdk`,r?.headers,r?.signal)}catch(e){return d(t)&&f(e)||p(r,i,e),r?.onFailure?.(`network`,e),null}if(r?.onResponse?.(c.status),!c.ok){let e=await m(c),t=`status ${c.status.toString()}`;return p(r,`${i} (${e===null?t:`${t}: ${e}`})`),r?.onFailure?.(`status`),null}let u;try{u=await c.json()}catch(e){return p(r,a),r?.onFailure?.(`parse`,e),null}return s(u)?u:(p(r,o),r?.onFailure?.(`shape`),null)}function g(e){if(typeof e!=`object`||!e||!(`$defs`in e)||!(`x-picked-step-content-models`in e))return!1;let t=e.$defs;return typeof t!=`object`||!t?!1:`contentModels`in t}function _(e){return typeof e==`object`&&!!e&&`features`in e&&Array.isArray(e.features)}function v(e){return typeof e!=`object`||!e||!(`experienceId`in e)||!(`content`in e)?!1:Array.isArray(e.content)}async function y(e,t,n){return h({apiUrl:e,path:n?.previewToken?`projects/${t}?preview_token=${encodeURIComponent(n.previewToken)}`:`projects/${t}`,options:n,failureMessage:`Failed to fetch project config`,parseFailureMessage:`Failed to parse project config response`,invalidShapeMessage:`Invalid project config response shape`,isValid:_})}async function b(e,t,n,r){return h({apiUrl:e,path:r?.previewToken?`projects/${t}/experiences/${n}/content?preview_token=${encodeURIComponent(r.previewToken)}`:`projects/${t}/experiences/${n}/content`,options:r,failureMessage:`Failed to fetch experience content for ${n}`,parseFailureMessage:`Failed to parse experience content response for ${n}`,invalidShapeMessage:`Invalid experience content response shape for ${n}`,isValid:v})}async function x(e,t,n){return h({apiUrl:e,path:n?.previewToken?`projects/${t}/schema?preview_token=${encodeURIComponent(n.previewToken)}`:`projects/${t}/schema`,options:n,failureMessage:`Failed to fetch workspace schema`,parseFailureMessage:`Failed to parse schema response`,invalidShapeMessage:`Invalid schema response shape`,isValid:g})}var S=[`succeeded`,`pending`,`no_response`];function C(e){return`pickedId`in e?e.pickedId:e.session.id}async function w(e,t,n){let r=C(t),i={projectId:t.projectId,pickedId:r,session:{id:r},responses:t.responses,...t.versionId===void 0?{}:{versionId:t.versionId}},a=`action/${encodeURIComponent(t.key)}/run`,o=await u(e,n?.previewToken?`${a}?preview_token=${encodeURIComponent(n.previewToken)}`:a,i,`sdk`,n?.headers,n?.signal,n?.timeoutMs);if(!o.ok)throw Error(`Action '${t.key}' failed: ${o.status} ${o.statusText}`);let s=await o.json();if(typeof s!=`object`||!s)return{actionRunId:``,workflowRunId:null,status:`no_response`};let c=`actionRunId`in s?String(s.actionRunId):``,l=`workflowRunId`in s&&typeof s.workflowRunId==`string`?s.workflowRunId:null,d=S.find(e=>`status`in s&&e===s.status)??`no_response`;return d===`succeeded`&&`response`in s?{actionRunId:c,workflowRunId:l,status:d,response:s.response}:{actionRunId:c,workflowRunId:l,status:d}}var T=35e3,E=1e3,D=3e4,O=14,k=36e5,A=class extends Error{workflowRunId;constructor(e){super(`No response from run '${e}' within the time allowed`),this.workflowRunId=e,this.name=`ActionResponseTimeoutError`}},j=class extends Error{workflowRunId;constructor(e){super(`Run '${e}' failed before it responded`),this.workflowRunId=e,this.name=`ActionRunFailedError`}};function M(e){return`pickedId`in e?e.pickedId:e.sessionId}function N(e){let t=M(e);return new URLSearchParams({projectId:e.projectId,pickedId:t,session:t})}async function P(e,t,n,r){let i=N(t),a=`action/run/${encodeURIComponent(t.workflowRunId)}/response?${i.toString()}`,o;try{o=await l(e,a,`sdk`,r?.headers,r?.signal,n)}catch(e){if(r?.signal?.aborted)throw e;return{kind:`retry`,error:e instanceof Error?e:Error(String(e))}}if(!o.ok){let e=Error(`Action response for '${t.workflowRunId}' failed: ${o.status} ${o.statusText}`);if(o.status>=500)return{kind:`retry`,error:e};throw e}let s=await o.json().catch(e=>{if(r?.signal?.aborted)throw e;return null}),c=typeof s==`object`&&!!s;switch(c&&`status`in s?s.status:void 0){case`succeeded`:return{kind:`settled`,result:{status:`succeeded`,response:c&&`response`in s?s.response:null}};case`no_response`:return{kind:`settled`,result:{status:`no_response`}};case`failed`:return{kind:`failed`};case`pending`:return{kind:`pending`};default:return{kind:`retry`,error:Error(`Action response for '${t.workflowRunId}' could not be read`)}}}function F(e,t){return new Promise(n=>{let r=()=>{t?.removeEventListener(`abort`,r),n()};setTimeout(r,e),t?.addEventListener(`abort`,r,{once:!0})})}async function I(e,t,n){let r=n?.signal,i=Date.now()+(n?.timeoutMs??36e5),a=0;for(;Date.now()<i;){r?.throwIfAborted();let o=await P(e,t,Math.max(1,Math.min(T,i-Date.now())),n);if(o.kind===`settled`)return o.result;if(o.kind===`failed`)throw new j(t.workflowRunId);if(o.kind===`pending`){a=0;continue}if(a+=1,a>O)throw o.error;r?.throwIfAborted();let s=Math.min(E*2**(a-1),D);await F(Math.max(0,Math.min(s,i-Date.now())),r),r?.throwIfAborted()}throw new A(t.workflowRunId)}exports.ActionResponseTimeoutError=A,exports.ActionRunFailedError=j,exports.DEFAULT_ACTION_RESPONSE_TIMEOUT_MS=k,exports.createClientHeaders=n,exports.fetchExperienceContent=b,exports.fetchProject=y,exports.fetchSchema=x,exports.getPackageVersion=r,exports.isWorkspaceSchema=g,exports.runAction=w,exports.waitForActionResponse=I;
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Wire-format types for Delivery API project config responses.
|
|
3
|
+
*
|
|
4
|
+
* These describe the JSON the API returns. The SDK accepts them structurally at
|
|
5
|
+
* registration time — no runtime conversion layer is required when shapes match.
|
|
6
|
+
*/
|
|
7
|
+
/** JSON-serialisable value. */
|
|
8
|
+
type JsonValue = string | number | boolean | null | {
|
|
9
|
+
[key: string]: JsonValue;
|
|
10
|
+
} | JsonValue[];
|
|
11
|
+
/** JSON Logic leaf/primitive operand. */
|
|
12
|
+
type JsonLogicPrimitive = string | number | boolean | null;
|
|
13
|
+
/** JSON Logic value as returned on the wire. */
|
|
14
|
+
type JsonLogicValue = JsonLogicPrimitive | JsonLogicValue[] | {
|
|
15
|
+
[key: string]: JsonLogicValue;
|
|
16
|
+
};
|
|
17
|
+
/** JSON Logic rule object controlling experience/field behaviour. */
|
|
18
|
+
type LogicRule = Record<string, JsonLogicValue>;
|
|
19
|
+
interface BaseExperienceNodeWire {
|
|
20
|
+
id: string;
|
|
21
|
+
type: string;
|
|
22
|
+
}
|
|
23
|
+
interface StepNodeWire extends BaseExperienceNodeWire {
|
|
24
|
+
type: 'step';
|
|
25
|
+
stepId: string;
|
|
26
|
+
stepKey?: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
}
|
|
29
|
+
interface ConditionNodeWire extends BaseExperienceNodeWire {
|
|
30
|
+
type: 'condition';
|
|
31
|
+
conditionId: string;
|
|
32
|
+
conditionKey?: string;
|
|
33
|
+
}
|
|
34
|
+
interface LaunchExperienceNodeWire extends BaseExperienceNodeWire {
|
|
35
|
+
type: 'experience';
|
|
36
|
+
experienceId: string;
|
|
37
|
+
experienceKey: string;
|
|
38
|
+
}
|
|
39
|
+
interface OriginNodeWire extends BaseExperienceNodeWire {
|
|
40
|
+
type: 'origin';
|
|
41
|
+
}
|
|
42
|
+
interface ActionNodeWire extends BaseExperienceNodeWire {
|
|
43
|
+
type: 'action';
|
|
44
|
+
actionId?: string;
|
|
45
|
+
actionKey?: string;
|
|
46
|
+
name?: string;
|
|
47
|
+
/** Key of the field the action's resolved value is stored in. */
|
|
48
|
+
successFieldKey?: string;
|
|
49
|
+
/** Key of the field the action's failure, `{ code, message }`, is stored in. */
|
|
50
|
+
failureFieldKey?: string;
|
|
51
|
+
}
|
|
52
|
+
/** Union of experience-graph node shapes as returned by the Delivery API. */
|
|
53
|
+
export type ProjectConfigNode = StepNodeWire | ConditionNodeWire | LaunchExperienceNodeWire | OriginNodeWire | ActionNodeWire;
|
|
54
|
+
interface ExperienceEdgeWire {
|
|
55
|
+
id: string;
|
|
56
|
+
sourceNodeId: string;
|
|
57
|
+
destinationNodeId: string;
|
|
58
|
+
sourceHandle?: string;
|
|
59
|
+
}
|
|
60
|
+
interface ExperienceTargetWire {
|
|
61
|
+
selector: string;
|
|
62
|
+
placement: 'replace' | 'append' | 'prepend' | 'before' | 'after';
|
|
63
|
+
}
|
|
64
|
+
export interface FieldWire {
|
|
65
|
+
id: string;
|
|
66
|
+
key: string;
|
|
67
|
+
name: string;
|
|
68
|
+
label?: string;
|
|
69
|
+
type: 'text' | 'number' | 'object' | 'boolean';
|
|
70
|
+
multiple?: boolean;
|
|
71
|
+
required?: boolean;
|
|
72
|
+
defaultValue?: JsonValue | JsonValue[];
|
|
73
|
+
placeholder?: string;
|
|
74
|
+
description?: string;
|
|
75
|
+
helpText?: string;
|
|
76
|
+
options?: Array<{
|
|
77
|
+
id: string;
|
|
78
|
+
label: string;
|
|
79
|
+
value: JsonValue;
|
|
80
|
+
description?: string;
|
|
81
|
+
}> | null;
|
|
82
|
+
validation?: LogicRule;
|
|
83
|
+
condition?: LogicRule;
|
|
84
|
+
/**
|
|
85
|
+
* Privacy policies governing what leaves the page. Both are opt-in: a value is
|
|
86
|
+
* tracked only under `doNotTrackValue: false` and persisted only under
|
|
87
|
+
* `doNotStoreValue: false`, so an absent policy captures nothing.
|
|
88
|
+
*/
|
|
89
|
+
policies?: {
|
|
90
|
+
doNotTrackValue?: boolean;
|
|
91
|
+
doNotStoreValue?: boolean;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export interface ConditionWire {
|
|
95
|
+
id: string;
|
|
96
|
+
key: string;
|
|
97
|
+
name: string;
|
|
98
|
+
logic: LogicRule;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Wire-format step as returned by the Delivery API. Fields are referenced by ID;
|
|
102
|
+
* the SDK plugin resolves them to keys against `ProjectConfig.fields` at registration.
|
|
103
|
+
*/
|
|
104
|
+
export interface ApiExperienceStep {
|
|
105
|
+
id: string;
|
|
106
|
+
key: string;
|
|
107
|
+
name: string;
|
|
108
|
+
fieldIds?: string[];
|
|
109
|
+
layoutName?: string | null;
|
|
110
|
+
layoutContentId?: string | null;
|
|
111
|
+
}
|
|
112
|
+
/** One arm of a text-valued feature, as frozen into a published config. */
|
|
113
|
+
export interface ProjectConfigFeatureVariant {
|
|
114
|
+
/**
|
|
115
|
+
* Stable identity, and the order allocation runs in. `true` and `false` name a
|
|
116
|
+
* boolean feature's structural arms; anything else is author-defined.
|
|
117
|
+
*/
|
|
118
|
+
key: string;
|
|
119
|
+
/** What the site receives when a visitor lands in this arm. */
|
|
120
|
+
value: boolean | string;
|
|
121
|
+
/**
|
|
122
|
+
* Share of traffic relative to the other arms, already reduced by their
|
|
123
|
+
* greatest common divisor, so `1, 1, 2` and `10, 10, 20` arrive identically.
|
|
124
|
+
*/
|
|
125
|
+
weight: number;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Feature payload as returned by the Delivery API.
|
|
129
|
+
*
|
|
130
|
+
* `id` holds the feature's KEY, not its id — it has since features were first
|
|
131
|
+
* published, and the `features.<key>` condition namespace depends on it. The SDK
|
|
132
|
+
* normalises it to `key` on read rather than adding a field here: a boolean
|
|
133
|
+
* feature's row has to stay byte-identical to the one it has always published.
|
|
134
|
+
*
|
|
135
|
+
* `variants` is present only for a text feature. Its absence means "boolean",
|
|
136
|
+
* including for every config published before variants existed, so there is no
|
|
137
|
+
* legacy branch to carry: `weight` is the split whenever `variants` is missing.
|
|
138
|
+
*
|
|
139
|
+
* Variant NAMES are deliberately absent. Allocation runs on keys and weights,
|
|
140
|
+
* storage holds the key and analytics reports the key, so names would be bytes
|
|
141
|
+
* inlined into every customer bundle that no visitor ever reads.
|
|
142
|
+
*/
|
|
143
|
+
export interface ProjectConfigFeature {
|
|
144
|
+
id: string;
|
|
145
|
+
name: string;
|
|
146
|
+
enabled: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Share of visitors outside the control arm, 0-100. The allocation input for a
|
|
149
|
+
* boolean feature. Carried for a text feature too, so a client that predates
|
|
150
|
+
* variants still puts the right share in control, but ignored by clients that
|
|
151
|
+
* understand `variants`.
|
|
152
|
+
*/
|
|
153
|
+
weight: number;
|
|
154
|
+
version: number;
|
|
155
|
+
valueType?: 'boolean' | 'text';
|
|
156
|
+
variants?: ProjectConfigFeatureVariant[];
|
|
157
|
+
}
|
|
158
|
+
/** Experience payload as returned by the Delivery API. */
|
|
159
|
+
export interface ProjectConfigExperience {
|
|
160
|
+
id: string;
|
|
161
|
+
key: string;
|
|
162
|
+
name: string;
|
|
163
|
+
componentName: string;
|
|
164
|
+
nodes: ProjectConfigNode[];
|
|
165
|
+
edges: ExperienceEdgeWire[];
|
|
166
|
+
condition: LogicRule | JsonLogicValue;
|
|
167
|
+
initializeOpen: LogicRule | JsonLogicValue;
|
|
168
|
+
targets: ExperienceTargetWire[];
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Action payload as returned by the Delivery API.
|
|
172
|
+
*
|
|
173
|
+
* `fieldIds` names the fields whose responses the SDK sends when the action
|
|
174
|
+
* runs, the same way a step names its fields. The SDK resolves them to keys on
|
|
175
|
+
* registration, because a response is recorded under its field's key.
|
|
176
|
+
*
|
|
177
|
+
* It is also the grant the API filters against, so a field absent here is a
|
|
178
|
+
* value the action never receives, whatever a client sends.
|
|
179
|
+
*
|
|
180
|
+
* Optional: a config published before it existed carries none, and such an
|
|
181
|
+
* action posts no responses.
|
|
182
|
+
*/
|
|
183
|
+
export interface ProjectConfigAction {
|
|
184
|
+
id: string;
|
|
185
|
+
name: string;
|
|
186
|
+
key: string;
|
|
187
|
+
fieldIds?: string[];
|
|
188
|
+
}
|
|
189
|
+
/** Project configuration returned by the Delivery API. */
|
|
190
|
+
export interface ProjectConfig {
|
|
191
|
+
id: string;
|
|
192
|
+
name: string;
|
|
193
|
+
status: string;
|
|
194
|
+
versionId: string;
|
|
195
|
+
workspaceId: string;
|
|
196
|
+
features: ProjectConfigFeature[];
|
|
197
|
+
experiences: ProjectConfigExperience[];
|
|
198
|
+
steps: ApiExperienceStep[];
|
|
199
|
+
fields: FieldWire[];
|
|
200
|
+
conditions: ConditionWire[];
|
|
201
|
+
actions: ProjectConfigAction[];
|
|
202
|
+
/**
|
|
203
|
+
* Origins permitted to push live-preview content patches into this page, issued by the API on the
|
|
204
|
+
* preview surface only. The preview receiver validates every inbound message against this list;
|
|
205
|
+
* absent or empty means no embedder is trusted and the channel stays closed.
|
|
206
|
+
*/
|
|
207
|
+
previewEmbedderOrigins?: string[];
|
|
208
|
+
}
|
|
209
|
+
/** Content blob as returned by the experience content endpoint. */
|
|
210
|
+
export interface ContentBlob {
|
|
211
|
+
id: string;
|
|
212
|
+
/** The `key` of the Content Model that produced this entry, or `null` when unresolved. */
|
|
213
|
+
contentModelKey: string | null;
|
|
214
|
+
data: Record<string, unknown>;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Response shape for `GET /api/v1/projects/:projectId/experiences/:experienceId/content`.
|
|
218
|
+
* The response is agnostic of step structure — step ↔ content mapping is encoded in the
|
|
219
|
+
* project blob via `ApiExperienceStep.layoutContentId`.
|
|
220
|
+
*
|
|
221
|
+
* `versionId` is the published workspace version id on the published surface and `null` on
|
|
222
|
+
* the preview surface, where there is no published version.
|
|
223
|
+
*/
|
|
224
|
+
export interface ExperienceContentResponse {
|
|
225
|
+
experienceId: string;
|
|
226
|
+
versionId: string | null;
|
|
227
|
+
/** The Content records the experience's steps point at, via `ApiExperienceStep.layoutContentId`. */
|
|
228
|
+
content: ContentBlob[];
|
|
229
|
+
/**
|
|
230
|
+
* Content records reached from `content` through a `reference` field, deduped and
|
|
231
|
+
* excluding the step blobs. Registered into the content registry the same way, so a
|
|
232
|
+
* `{ contentEntryId }` pointer resolves through `contents.getById`.
|
|
233
|
+
*
|
|
234
|
+
* Optional: a response produced before this field existed — notably a build-time cache
|
|
235
|
+
* written by an older `@picked/vite-plugin-picked` — omits it entirely.
|
|
236
|
+
*/
|
|
237
|
+
references?: ContentBlob[];
|
|
238
|
+
}
|
|
239
|
+
export interface FetchProjectOptions {
|
|
240
|
+
previewToken?: string;
|
|
241
|
+
headers?: Record<string, string>;
|
|
242
|
+
signal?: AbortSignal;
|
|
243
|
+
onWarn?: (message: string, error?: unknown) => void;
|
|
244
|
+
/** Receives the HTTP status once the server answers, whatever the status is. */
|
|
245
|
+
onResponse?: (status: number) => void;
|
|
246
|
+
/** Receives the stage a request failed at, with the error when the stage threw one. */
|
|
247
|
+
onFailure?: (stage: FetchFailureStage, error?: unknown) => void;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Where a delivery API fetch failed: the request itself (`network`), a non-OK status
|
|
251
|
+
* (`status`), reading the body as JSON (`parse`), or the body's shape (`shape`).
|
|
252
|
+
*/
|
|
253
|
+
export type FetchFailureStage = 'network' | 'status' | 'parse' | 'shape';
|
|
254
|
+
export {};
|
|
255
|
+
//# sourceMappingURL=project-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-config.d.ts","sourceRoot":"","sources":["../../src/project-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,+BAA+B;AAC/B,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,SAAS,EAAE,CAAA;AAE9F,yCAAyC;AACzC,KA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IAChC,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IACnD,gFAAgF;IAChF,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC,uFAAuF;IACvF,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CAChE;AAED;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAA"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Wire-format types for workspace schema documents. This is the single
|
|
3
|
+
* source of truth for the `WorkspaceSchema` shape on the SDK side; it mirrors
|
|
4
|
+
* (and should be kept in sync with) the API's own `WorkspaceSchema` type in
|
|
5
|
+
* `apps/api/src/usecases/workspace/build-workspace-schema-snapshot.ts`.
|
|
6
|
+
*/
|
|
7
|
+
/** JSON Schema object fragment used in workspace schema `$defs`. */
|
|
8
|
+
export interface JsonSchemaObject {
|
|
9
|
+
type?: 'object' | 'array' | 'string' | 'number' | 'boolean' | 'null';
|
|
10
|
+
title?: string;
|
|
11
|
+
properties?: Record<string, JsonSchemaObject>;
|
|
12
|
+
required?: string[];
|
|
13
|
+
additionalProperties?: boolean;
|
|
14
|
+
items?: JsonSchemaObject;
|
|
15
|
+
enum?: string[];
|
|
16
|
+
const?: string;
|
|
17
|
+
$ref?: string;
|
|
18
|
+
oneOf?: JsonSchemaObject[];
|
|
19
|
+
}
|
|
20
|
+
/** Stable key-set enum schema used for feature/experience/step keys. */
|
|
21
|
+
export interface KeyEnumSchema {
|
|
22
|
+
type: 'string';
|
|
23
|
+
enum?: string[];
|
|
24
|
+
}
|
|
25
|
+
/** Workspace schema document served by `GET /projects/:projectId/schema`. */
|
|
26
|
+
export interface WorkspaceSchema {
|
|
27
|
+
'$schema': string;
|
|
28
|
+
'$id': string;
|
|
29
|
+
'x-picked-schema-version': number;
|
|
30
|
+
'x-picked-source': 'published' | 'preview';
|
|
31
|
+
'x-picked-version-id': string | null;
|
|
32
|
+
'x-picked-step-content-models': Record<string, string>;
|
|
33
|
+
'x-picked-step-fields'?: Record<string, string[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Optional: values each text feature can serve, keyed by feature key. A
|
|
36
|
+
* workspace of boolean features omits it entirely, and so does any schema
|
|
37
|
+
* frozen before text features existed. Absent means every feature resolves
|
|
38
|
+
* to `boolean | string`.
|
|
39
|
+
*/
|
|
40
|
+
'x-picked-feature-values'?: Record<string, (boolean | string)[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Keys of the actions a workflow is triggered by. Absent when there are none, and in a
|
|
43
|
+
* schema frozen before the field existed.
|
|
44
|
+
*/
|
|
45
|
+
'x-picked-workflow-action-keys'?: string[];
|
|
46
|
+
'$defs': {
|
|
47
|
+
contentModels: Record<string, JsonSchemaObject>;
|
|
48
|
+
contentBlocks: Record<string, JsonSchemaObject>;
|
|
49
|
+
fields: JsonSchemaObject;
|
|
50
|
+
featureKeys: KeyEnumSchema;
|
|
51
|
+
experienceKeys: KeyEnumSchema;
|
|
52
|
+
stepKeys: KeyEnumSchema;
|
|
53
|
+
/**
|
|
54
|
+
* Optional: a workspace published before action keys were added to the snapshot
|
|
55
|
+
* serves a frozen `schema_json` that omits this. Such a schema generates
|
|
56
|
+
* `ActionKey = string` until the workspace is republished.
|
|
57
|
+
*/
|
|
58
|
+
actionKeys?: KeyEnumSchema;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns whether `data` has the minimum shape of a {@link WorkspaceSchema}
|
|
63
|
+
* document. The single canonical guard for this shape, shared by every SDK
|
|
64
|
+
* consumer (the fetch client and the codegen library) instead of each
|
|
65
|
+
* redefining its own copy.
|
|
66
|
+
*
|
|
67
|
+
* @param {unknown} data - Unknown value to validate.
|
|
68
|
+
* @returns {data is WorkspaceSchema} Whether `data` has the minimum required shape.
|
|
69
|
+
* @example
|
|
70
|
+
* isWorkspaceSchema(JSON.parse(schemaJson))
|
|
71
|
+
*/
|
|
72
|
+
export declare function isWorkspaceSchema(data: unknown): data is WorkspaceSchema;
|
|
73
|
+
/** Options for `fetchSchema`: preview token, header overrides, abort signal, and a warn hook. */
|
|
74
|
+
export interface FetchSchemaOptions {
|
|
75
|
+
previewToken?: string;
|
|
76
|
+
headers?: Record<string, string>;
|
|
77
|
+
signal?: AbortSignal;
|
|
78
|
+
onWarn?: (message: string, error?: unknown) => void;
|
|
79
|
+
}
|
|
80
|
+
export type { ApiExperienceStep, ContentBlob, ExperienceContentResponse, FetchFailureStage, FetchProjectOptions, ProjectConfig, ProjectConfigExperience, ProjectConfigFeature, ProjectConfigFeatureVariant, ProjectConfigNode, } from './project-config.js';
|
|
81
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,oEAAoE;AACpE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAA;IACpE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IAC7C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,KAAK,CAAC,EAAE,gBAAgB,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAA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,EAAE,MAAM,CAAC,CAAA;IAChC,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CACpD;AAED,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,yBAAyB,EACzB,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,uBAAuB,EACvB,oBAAoB,EACpB,2BAA2B,EAC3B,iBAAiB,GAClB,MAAM,kBAAkB,CAAA"}
|
package/dist/esm/index.js
CHANGED
package/dist/types/fetch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExperienceContentResponse, FetchProjectOptions, FetchSchemaOptions, ProjectConfig, WorkspaceSchema } from './types';
|
|
1
|
+
import type { ExperienceContentResponse, FetchProjectOptions, FetchSchemaOptions, ProjectConfig, WorkspaceSchema } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Fetches the project configuration from the Picked REST API.
|
|
4
4
|
*
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** @file Public exports for `\@picked/delivery-api-client`. */
|
|
2
|
-
export { createClientHeaders, getPackageVersion } from './client-headers';
|
|
3
|
-
export { fetchExperienceContent, fetchProject, fetchSchema } from './fetch';
|
|
4
|
-
export { runAction } from './actions';
|
|
5
|
-
export type { ActionRunStatus, RunActionPayload, RunActionOptions, RunActionResult, } from './actions';
|
|
6
|
-
export { ActionResponseTimeoutError, ActionRunFailedError, DEFAULT_ACTION_RESPONSE_TIMEOUT_MS, waitForActionResponse, } from './action-response';
|
|
7
|
-
export type { ActionResponse, WaitForActionResponseOptions, WaitForActionResponseParams, } from './action-response';
|
|
8
|
-
export { isWorkspaceSchema } from './types';
|
|
9
|
-
export type * from './types';
|
|
2
|
+
export { createClientHeaders, getPackageVersion } from './client-headers.js';
|
|
3
|
+
export { fetchExperienceContent, fetchProject, fetchSchema } from './fetch.js';
|
|
4
|
+
export { runAction } from './actions.js';
|
|
5
|
+
export type { ActionRunStatus, RunActionPayload, RunActionOptions, RunActionResult, } from './actions.js';
|
|
6
|
+
export { ActionResponseTimeoutError, ActionRunFailedError, DEFAULT_ACTION_RESPONSE_TIMEOUT_MS, waitForActionResponse, } from './action-response.js';
|
|
7
|
+
export type { ActionResponse, WaitForActionResponseOptions, WaitForActionResponseParams, } from './action-response.js';
|
|
8
|
+
export { isWorkspaceSchema } from './types.js';
|
|
9
|
+
export type * from './types.js';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/types/types.d.ts
CHANGED
|
@@ -77,5 +77,5 @@ export interface FetchSchemaOptions {
|
|
|
77
77
|
signal?: AbortSignal;
|
|
78
78
|
onWarn?: (message: string, error?: unknown) => void;
|
|
79
79
|
}
|
|
80
|
-
export type { ApiExperienceStep, ContentBlob, ExperienceContentResponse, FetchFailureStage, FetchProjectOptions, ProjectConfig, ProjectConfigExperience, ProjectConfigFeature, ProjectConfigFeatureVariant, ProjectConfigNode, } from './project-config';
|
|
80
|
+
export type { ApiExperienceStep, ContentBlob, ExperienceContentResponse, FetchFailureStage, FetchProjectOptions, ProjectConfig, ProjectConfigExperience, ProjectConfigFeature, ProjectConfigFeatureVariant, ProjectConfigNode, } from './project-config.js';
|
|
81
81
|
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picked/delivery-api-client",
|
|
3
3
|
"description": "Browser-safe Picked delivery API client for project config, experience content, and workspace schema",
|
|
4
|
-
"version": "0.0.117
|
|
4
|
+
"version": "0.0.117",
|
|
5
5
|
"dependencies": {},
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@repo/eslint-config": "workspace:*",
|
|
@@ -16,9 +16,14 @@
|
|
|
16
16
|
},
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
"import": {
|
|
20
|
+
"types": "./dist/types/index.d.ts",
|
|
21
|
+
"default": "./dist/esm/index.js"
|
|
22
|
+
},
|
|
23
|
+
"require": {
|
|
24
|
+
"types": "./dist/cjs/index.d.ts",
|
|
25
|
+
"default": "./dist/cjs/index.js"
|
|
26
|
+
},
|
|
22
27
|
"default": "./dist/esm/index.js"
|
|
23
28
|
}
|
|
24
29
|
},
|
|
@@ -52,7 +57,7 @@
|
|
|
52
57
|
"access": "public"
|
|
53
58
|
},
|
|
54
59
|
"scripts": {
|
|
55
|
-
"build": "vite build && tsgo -p tsconfig.build.json",
|
|
60
|
+
"build": "vite build && tsgo -p tsconfig.build.json && node ../../scripts/sdk-dist.mjs",
|
|
56
61
|
"check": "pnpm type-check && pnpm lint && pnpm knip && pnpm jscpd",
|
|
57
62
|
"dev": "node ../../scripts/sdk-watch-build.mjs",
|
|
58
63
|
"jscpd": "jscpd src",
|
|
@@ -63,7 +68,7 @@
|
|
|
63
68
|
"lint:report": "eslint . -o './.reports/eslint.json' -f json || true",
|
|
64
69
|
"test": "vitest run",
|
|
65
70
|
"test:coverage": "../../scripts/vitest-coverage.sh",
|
|
66
|
-
"test:packaged-types": "attw --pack",
|
|
71
|
+
"test:packaged-types": "attw --pack --profile node16",
|
|
67
72
|
"test:watch": "vitest",
|
|
68
73
|
"type-check": "tsgo -p . --noEmit"
|
|
69
74
|
},
|