@myapihq/sdk 2.12.0 → 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 +22 -0
- package/dist/feedback.js +16 -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>;
|
|
@@ -49,4 +56,19 @@ export declare function createFeedback(apiKey: string, orgId: string, input: Cre
|
|
|
49
56
|
export declare function resolveFeedback(apiKey: string, orgId: string, id: string): Promise<void>;
|
|
50
57
|
export declare function deleteFeedback(apiKey: string, orgId: string, id: string): Promise<void>;
|
|
51
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[]>;
|
|
52
74
|
export declare function revokeWidget(apiKey: string, orgId: string, id: string): Promise<void>;
|
package/dist/feedback.js
CHANGED
|
@@ -6,6 +6,8 @@ exports.createFeedback = createFeedback;
|
|
|
6
6
|
exports.resolveFeedback = resolveFeedback;
|
|
7
7
|
exports.deleteFeedback = deleteFeedback;
|
|
8
8
|
exports.createWidget = createWidget;
|
|
9
|
+
exports.updateWidget = updateWidget;
|
|
10
|
+
exports.listWidgets = listWidgets;
|
|
9
11
|
exports.revokeWidget = revokeWidget;
|
|
10
12
|
const client_1 = require("./client");
|
|
11
13
|
const config_1 = require("./config");
|
|
@@ -14,6 +16,8 @@ const config_1 = require("./config");
|
|
|
14
16
|
exports.EXPOSES = [
|
|
15
17
|
'POST /feedback/orgs/{org_id}/widgets',
|
|
16
18
|
'DELETE /feedback/orgs/{org_id}/widgets/{id}',
|
|
19
|
+
'GET /feedback/orgs/{org_id}/widgets',
|
|
20
|
+
'PATCH /feedback/orgs/{org_id}/widgets/{id}',
|
|
17
21
|
'GET /feedback/orgs/{org_id}/items',
|
|
18
22
|
'POST /feedback/orgs/{org_id}/items',
|
|
19
23
|
'POST /feedback/orgs/{org_id}/items/{id}/resolve',
|
|
@@ -63,6 +67,18 @@ async function createWidget(apiKey, orgId, name, allowedOrigins) {
|
|
|
63
67
|
body.allowed_origins = allowedOrigins;
|
|
64
68
|
return (0, client_1.request)('POST', `${orgBase(orgId)}/widgets`, apiKey, body);
|
|
65
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
|
+
}
|
|
66
82
|
async function revokeWidget(apiKey, orgId, id) {
|
|
67
83
|
return (0, client_1.request)('DELETE', `${orgBase(orgId)}/widgets/${encodeURIComponent(id)}`, apiKey);
|
|
68
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';
|