@orbit-app/functions 0.5.0 → 0.6.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/README.md +3 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.js +9 -0
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -22,9 +22,11 @@ export default defineFunction({
|
|
|
22
22
|
});
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
A function can also map a provider account to the store member who connected it, such as the reviewers of a GitLab event: `await orbit.connections.members("gitlab", { accountIds })` gives `{ userId, accountId, username, team }` for each match, and `team` keeps only one Slack workspace or Grid org (0.6.0 and later).
|
|
26
|
+
|
|
25
27
|
Declare each function under `functions` in `orbit.json`. `orbit publish` and `orbit pack` bundle each entry with esbuild and `serve()`, the wrapper of this package. Do not call `serve()` yourself.
|
|
26
28
|
|
|
27
|
-
The full guide (triggers, limits, org connections, the run log) is `functions.md` of the Orbit MCP server's docs. In this repository it is `api/docs/functions.md`.
|
|
29
|
+
The full guide (triggers, limits, org connections, the run log) is `functions.md` of the Orbit MCP server's docs. In this repository it is `api/public-docs/functions.md`.
|
|
28
30
|
|
|
29
31
|
## Develop this package
|
|
30
32
|
|
package/dist/index.d.ts
CHANGED
|
@@ -105,6 +105,12 @@ export type OrgConnection = {
|
|
|
105
105
|
body?: string | Uint8Array | null;
|
|
106
106
|
}): Promise<Response>;
|
|
107
107
|
};
|
|
108
|
+
export type ConnectionMember = {
|
|
109
|
+
userId: string;
|
|
110
|
+
accountId: string;
|
|
111
|
+
username: string | null;
|
|
112
|
+
team: string | null;
|
|
113
|
+
};
|
|
108
114
|
export interface OrbitSecretNames {
|
|
109
115
|
}
|
|
110
116
|
export type OrbitSecretName = [keyof OrbitSecretNames] extends [never] ? string : Extract<keyof OrbitSecretNames, string>;
|
|
@@ -115,6 +121,10 @@ export type FunctionOrbit = {
|
|
|
115
121
|
} = {}>(options?: ObjectsOptions): ObjectsClient<Types, Required>;
|
|
116
122
|
connections: {
|
|
117
123
|
get(provider: string): Promise<OrgConnection | null>;
|
|
124
|
+
members(provider: string, opts?: {
|
|
125
|
+
accountIds?: readonly string[];
|
|
126
|
+
team?: string;
|
|
127
|
+
}): Promise<ConnectionMember[]>;
|
|
118
128
|
};
|
|
119
129
|
defineDelegates<M extends Record<string, DelegateTypes> = Record<string, DelegateTypes>>(): Delegates<M>;
|
|
120
130
|
org(): OrbitOrg;
|
package/dist/index.js
CHANGED
|
@@ -204,6 +204,15 @@ function createOrbit(req) {
|
|
|
204
204
|
const c = list.connections.find((x) => x.provider === provider && x.status === "active");
|
|
205
205
|
return c ? connection(c) : null;
|
|
206
206
|
},
|
|
207
|
+
async members(provider, opts = {}) {
|
|
208
|
+
const ids = opts.accountIds ? [...opts.accountIds] : undefined;
|
|
209
|
+
if (ids?.length === 0)
|
|
210
|
+
return [];
|
|
211
|
+
const params = [...(ids ?? []).map((id) => `accountId=${enc(String(id))}`), ...(opts.team ? [`team=${enc(opts.team)}`] : [])];
|
|
212
|
+
const query = params.length ? `?${params.join("&")}` : "";
|
|
213
|
+
const reply = (await call("GET", `/v1/connections/${enc(provider)}/members${query}`));
|
|
214
|
+
return reply.members.map((m) => Object.freeze({ userId: m.userId, accountId: m.accountId, username: m.username ?? null, team: m.team ?? null }));
|
|
215
|
+
},
|
|
207
216
|
},
|
|
208
217
|
defineDelegates: () => ({
|
|
209
218
|
sign: (name, opts) => call("POST", "/v1/delegates", { name, ...opts }, delegateError),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbit-app/functions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Write Orbit Functions: publisher code that runs in Orbit's sandbox as the store's org.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -12,6 +12,12 @@
|
|
|
12
12
|
"files": [
|
|
13
13
|
"dist"
|
|
14
14
|
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc -p tsconfig.build.json",
|
|
17
|
+
"typecheck": "tsc --noEmit",
|
|
18
|
+
"test": "tsc --noEmit && vitest run",
|
|
19
|
+
"prepack": "pnpm build"
|
|
20
|
+
},
|
|
15
21
|
"dependencies": {
|
|
16
22
|
"@orbit-app/web": "^0.1.1"
|
|
17
23
|
},
|
|
@@ -21,10 +27,5 @@
|
|
|
21
27
|
},
|
|
22
28
|
"publishConfig": {
|
|
23
29
|
"access": "public"
|
|
24
|
-
},
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "tsc -p tsconfig.build.json",
|
|
27
|
-
"typecheck": "tsc --noEmit",
|
|
28
|
-
"test": "tsc --noEmit && vitest run"
|
|
29
30
|
}
|
|
30
|
-
}
|
|
31
|
+
}
|