@myapihq/sdk 2.11.2 → 2.13.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/dist/feedback.d.ts +23 -0
- package/dist/feedback.js +28 -0
- package/dist/function.d.ts +4 -0
- package/dist/function.js +16 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/feedback.d.ts
CHANGED
|
@@ -33,6 +33,13 @@ export interface Widget {
|
|
|
33
33
|
name: string;
|
|
34
34
|
key: string;
|
|
35
35
|
allowed_origins?: string[];
|
|
36
|
+
routes?: string[];
|
|
37
|
+
theme?: {
|
|
38
|
+
accent?: string;
|
|
39
|
+
position?: string;
|
|
40
|
+
label?: string;
|
|
41
|
+
};
|
|
42
|
+
script_tag?: string;
|
|
36
43
|
created_at: string;
|
|
37
44
|
}
|
|
38
45
|
export declare function listFeedback(apiKey: string, orgId: string, opts?: ListFeedbackOptions): Promise<FeedbackPage>;
|
|
@@ -47,5 +54,21 @@ export interface CreateFeedbackInput {
|
|
|
47
54
|
}
|
|
48
55
|
export declare function createFeedback(apiKey: string, orgId: string, input: CreateFeedbackInput): Promise<FeedbackItem>;
|
|
49
56
|
export declare function resolveFeedback(apiKey: string, orgId: string, id: string): Promise<void>;
|
|
57
|
+
export declare function deleteFeedback(apiKey: string, orgId: string, id: string): Promise<void>;
|
|
50
58
|
export declare function createWidget(apiKey: string, orgId: string, name: string, allowedOrigins?: string[]): Promise<Widget>;
|
|
59
|
+
/** Where the button appears and how it looks. Routes are compiled into the
|
|
60
|
+
* hosted widget.js, which is why changing them here reaches browsers within
|
|
61
|
+
* ~5 minutes without the customer redeploying their site. */
|
|
62
|
+
export interface WidgetUpdate {
|
|
63
|
+
name?: string;
|
|
64
|
+
allowed_origins?: string[];
|
|
65
|
+
routes?: string[];
|
|
66
|
+
theme?: {
|
|
67
|
+
accent?: string;
|
|
68
|
+
position?: string;
|
|
69
|
+
label?: string;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export declare function updateWidget(apiKey: string, orgId: string, id: string, patch: WidgetUpdate): Promise<Widget>;
|
|
73
|
+
export declare function listWidgets(apiKey: string, orgId: string): Promise<Widget[]>;
|
|
51
74
|
export declare function revokeWidget(apiKey: string, orgId: string, id: string): Promise<void>;
|
package/dist/feedback.js
CHANGED
|
@@ -4,7 +4,10 @@ exports.EXPOSES = void 0;
|
|
|
4
4
|
exports.listFeedback = listFeedback;
|
|
5
5
|
exports.createFeedback = createFeedback;
|
|
6
6
|
exports.resolveFeedback = resolveFeedback;
|
|
7
|
+
exports.deleteFeedback = deleteFeedback;
|
|
7
8
|
exports.createWidget = createWidget;
|
|
9
|
+
exports.updateWidget = updateWidget;
|
|
10
|
+
exports.listWidgets = listWidgets;
|
|
8
11
|
exports.revokeWidget = revokeWidget;
|
|
9
12
|
const client_1 = require("./client");
|
|
10
13
|
const config_1 = require("./config");
|
|
@@ -13,9 +16,12 @@ const config_1 = require("./config");
|
|
|
13
16
|
exports.EXPOSES = [
|
|
14
17
|
'POST /feedback/orgs/{org_id}/widgets',
|
|
15
18
|
'DELETE /feedback/orgs/{org_id}/widgets/{id}',
|
|
19
|
+
'GET /feedback/orgs/{org_id}/widgets',
|
|
20
|
+
'PATCH /feedback/orgs/{org_id}/widgets/{id}',
|
|
16
21
|
'GET /feedback/orgs/{org_id}/items',
|
|
17
22
|
'POST /feedback/orgs/{org_id}/items',
|
|
18
23
|
'POST /feedback/orgs/{org_id}/items/{id}/resolve',
|
|
24
|
+
'DELETE /feedback/orgs/{org_id}/items/{id}',
|
|
19
25
|
];
|
|
20
26
|
function orgBase(orgId) {
|
|
21
27
|
return `${config_1.FEEDBACK_BASE}/feedback/orgs/${encodeURIComponent(orgId)}`;
|
|
@@ -41,6 +47,16 @@ async function createFeedback(apiKey, orgId, input) {
|
|
|
41
47
|
async function resolveFeedback(apiKey, orgId, id) {
|
|
42
48
|
return (0, client_1.request)('POST', `${orgBase(orgId)}/items/${encodeURIComponent(id)}/resolve`, apiKey, {});
|
|
43
49
|
}
|
|
50
|
+
// Erases an item, as opposed to resolveFeedback which closes it and keeps it.
|
|
51
|
+
// Submissions arrive through a public endpoint, so an inbox collects spam and
|
|
52
|
+
// the occasional message where somebody typed personal details into a bug
|
|
53
|
+
// report — this is the way those come out.
|
|
54
|
+
//
|
|
55
|
+
// Idempotent, and like resolve it answers the same for an unknown id, so a
|
|
56
|
+
// success is not proof the item existed.
|
|
57
|
+
async function deleteFeedback(apiKey, orgId, id) {
|
|
58
|
+
return (0, client_1.request)('DELETE', `${orgBase(orgId)}/items/${encodeURIComponent(id)}`, apiKey);
|
|
59
|
+
}
|
|
44
60
|
// Mints a PUBLIC widget key. It ships in your page source and authenticates
|
|
45
61
|
// nobody — it names an org so a page can submit without a credential. Set
|
|
46
62
|
// `allowed_origins` so another site cannot post through it, and revoke it if
|
|
@@ -51,6 +67,18 @@ async function createWidget(apiKey, orgId, name, allowedOrigins) {
|
|
|
51
67
|
body.allowed_origins = allowedOrigins;
|
|
52
68
|
return (0, client_1.request)('POST', `${orgBase(orgId)}/widgets`, apiKey, body);
|
|
53
69
|
}
|
|
70
|
+
// Every field optional, and an omitted field keeps its value — so this is a
|
|
71
|
+
// partial update, not a replace. That is the opposite of setFunctionScopes,
|
|
72
|
+
// which replaces; the difference is the backend's and worth not guessing at.
|
|
73
|
+
async function updateWidget(apiKey, orgId, id, patch) {
|
|
74
|
+
return (0, client_1.request)('PATCH', `${orgBase(orgId)}/widgets/${encodeURIComponent(id)}`, apiKey, patch);
|
|
75
|
+
}
|
|
76
|
+
// Keys come back in full. That is not a leak: a widget key is public by
|
|
77
|
+
// construction and ships in page source, so hiding it here would only make the
|
|
78
|
+
// thing harder to paste.
|
|
79
|
+
async function listWidgets(apiKey, orgId) {
|
|
80
|
+
return (0, client_1.request)('GET', `${orgBase(orgId)}/widgets`, apiKey);
|
|
81
|
+
}
|
|
54
82
|
async function revokeWidget(apiKey, orgId, id) {
|
|
55
83
|
return (0, client_1.request)('DELETE', `${orgBase(orgId)}/widgets/${encodeURIComponent(id)}`, apiKey);
|
|
56
84
|
}
|
package/dist/function.d.ts
CHANGED
|
@@ -40,6 +40,10 @@ export declare function listFunctions(apiKey: string, orgId: string): Promise<Fn
|
|
|
40
40
|
export declare function getFunction(apiKey: string, orgId: string, fnId: string): Promise<Fn>;
|
|
41
41
|
export declare function deleteFunction(apiKey: string, orgId: string, fnId: string): Promise<void>;
|
|
42
42
|
export declare function uploadBundle(apiKey: string, orgId: string, fnId: string, bundle: Blob | Buffer | string, filename?: string): Promise<DeployResponse>;
|
|
43
|
+
export declare function setFunctionScopes(apiKey: string, orgId: string, fnId: string, scopes: string[]): Promise<Fn & {
|
|
44
|
+
scopes?: string[];
|
|
45
|
+
scoped_api_key?: string;
|
|
46
|
+
}>;
|
|
43
47
|
export declare function setFunctionEnv(apiKey: string, orgId: string, fnId: string, name: string, value: string): Promise<void>;
|
|
44
48
|
export declare function setFunctionEnvBulk(apiKey: string, orgId: string, fnId: string, env: Record<string, string>): Promise<{
|
|
45
49
|
set: number;
|
package/dist/function.js
CHANGED
|
@@ -6,6 +6,7 @@ exports.listFunctions = listFunctions;
|
|
|
6
6
|
exports.getFunction = getFunction;
|
|
7
7
|
exports.deleteFunction = deleteFunction;
|
|
8
8
|
exports.uploadBundle = uploadBundle;
|
|
9
|
+
exports.setFunctionScopes = setFunctionScopes;
|
|
9
10
|
exports.setFunctionEnv = setFunctionEnv;
|
|
10
11
|
exports.setFunctionEnvBulk = setFunctionEnvBulk;
|
|
11
12
|
exports.listFunctionRuns = listFunctionRuns;
|
|
@@ -22,6 +23,7 @@ exports.EXPOSES = [
|
|
|
22
23
|
'POST /function/orgs/{org_id}/functions/{id}/bundle',
|
|
23
24
|
'POST /function/orgs/{org_id}/functions/{id}/env',
|
|
24
25
|
'GET /function/orgs/{org_id}/functions/{id}/runs',
|
|
26
|
+
'PATCH /function/orgs/{org_id}/functions/{id}/scopes',
|
|
25
27
|
];
|
|
26
28
|
async function createFunction(apiKey, orgId, payload) {
|
|
27
29
|
return (0, client_1.request)('POST', `${config_1.FUNCTION_BASE}/function/orgs/${encodeURIComponent(orgId)}/functions`, apiKey, payload);
|
|
@@ -56,6 +58,20 @@ async function uploadBundle(apiKey, orgId, fnId, bundle, filename = 'bundle.js')
|
|
|
56
58
|
}
|
|
57
59
|
return result.data;
|
|
58
60
|
}
|
|
61
|
+
// Widens or narrows what slots a deployed function may call, WITHOUT
|
|
62
|
+
// recreating it. The id and invocation URL are unchanged, which is the whole
|
|
63
|
+
// point: the previous route to a new slot was delete + recreate, and that
|
|
64
|
+
// minted a new URL, breaking every reference already handed out.
|
|
65
|
+
//
|
|
66
|
+
// Two properties worth carrying to the caller:
|
|
67
|
+
// - `scopes` REPLACES the list. It is a set, not an add, so send the slots
|
|
68
|
+
// you want to end up with.
|
|
69
|
+
// - the scoped key is replaced and pushed to the running function, exactly
|
|
70
|
+
// as a deploy does. A narrowing that left the old key alive would narrow
|
|
71
|
+
// nothing, so this is deliberate rather than incidental.
|
|
72
|
+
async function setFunctionScopes(apiKey, orgId, fnId, scopes) {
|
|
73
|
+
return (0, client_1.request)('PATCH', `${config_1.FUNCTION_BASE}/function/orgs/${encodeURIComponent(orgId)}/functions/${encodeURIComponent(fnId)}/scopes`, apiKey, { scopes });
|
|
74
|
+
}
|
|
59
75
|
// setFunctionEnv writes a secret (Stripe key, etc.) as a Cloudflare Worker
|
|
60
76
|
// Secret on the deployed script (Story 5). The function must already be
|
|
61
77
|
// deployed. The value is never stored in MyAPI Postgres or returned.
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.
|
|
1
|
+
export declare const SDK_VERSION = "2.13.0";
|
package/dist/version.js
CHANGED
|
@@ -8,4 +8,4 @@ exports.SDK_VERSION = void 0;
|
|
|
8
8
|
// Why a constant and not a package.json read: the SDK runs inside edge
|
|
9
9
|
// functions (Cloudflare Workers), so it must not import node:fs. A literal
|
|
10
10
|
// is the only version source that works in every runtime we ship to.
|
|
11
|
-
exports.SDK_VERSION = '2.
|
|
11
|
+
exports.SDK_VERSION = '2.13.0';
|