@madewithremy/admin 0.1.24 → 0.1.25

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/index.d.ts CHANGED
@@ -11,6 +11,18 @@ interface AdminContext {
11
11
  apiKey: string;
12
12
  /** The app every operation is scoped to. */
13
13
  appId: string;
14
+ /**
15
+ * Who is acting, when that is not `appId` itself — set only when the caller
16
+ * has retargeted at another app (`--app`, or `forApp()`), and carrying the
17
+ * app they came FROM.
18
+ *
19
+ * Writes that record authorship attach it, so a cross-app issue says which
20
+ * app filed it without the caller having to remember a second flag. That
21
+ * matters more than it sounds: the information was always available here and
22
+ * being optional at the call site is precisely how it came to be omitted
23
+ * everywhere.
24
+ */
25
+ originAppId?: string;
14
26
  /** API origin, no trailing slash. */
15
27
  baseUrl: string;
16
28
  }
@@ -5226,9 +5238,10 @@ interface IssuesCreateParams {
5226
5238
  /** Labels to file it under. Open set, at most 20, 64 chars each. */
5227
5239
  labels?: string[];
5228
5240
  /**
5229
- * The app filing this, when it isn't the app the issue lands in. Set it when
5230
- * targeting another app (`forApp`) so the thread records who wrote — the
5231
- * recipient's reply comes back as a comment on this same issue.
5241
+ * The app filing this, when it isn't the app the issue lands in. Defaults to
5242
+ * `ctx.originAppId` — set whenever the caller retargeted at another app — so
5243
+ * cross-app authorship is recorded without anyone opting in. Pass it
5244
+ * explicitly only to override that.
5232
5245
  */
5233
5246
  originAppId?: string;
5234
5247
  }
@@ -7531,7 +7544,14 @@ type BoundOps<T> = {
7531
7544
  declare function buildClient(ctx: AdminContext): {
7532
7545
  /** The resolved context this client is bound to. */
7533
7546
  context: Readonly<AdminContext>;
7534
- /** A sibling client for another app, sharing credentials. */
7547
+ /**
7548
+ * A sibling client for another app, sharing credentials.
7549
+ *
7550
+ * The app we came from becomes the origin, so a write through the returned
7551
+ * client records which app acted — the same rule the CLI's `--app` follows.
7552
+ * Chaining `forApp` twice keeps the FIRST app as the origin, since that is
7553
+ * the one whose workspace this code is running in.
7554
+ */
7535
7555
  forApp(appId: string): /*elided*/ any;
7536
7556
  agent: BoundOps<typeof agent>;
7537
7557
  analytics: BoundOps<typeof analytics>;
package/dist/index.js CHANGED
@@ -2116,6 +2116,9 @@ __export(issues_exports, {
2116
2116
  list: () => list8,
2117
2117
  reopen: () => reopen
2118
2118
  });
2119
+ function authorship(ctx) {
2120
+ return ctx.originAppId ? { originAppId: ctx.originAppId } : {};
2121
+ }
2119
2122
  function listQuery(params) {
2120
2123
  return qs({
2121
2124
  status: params.status,
@@ -2157,8 +2160,9 @@ function create2(ctx, params) {
2157
2160
  if (params.labels !== void 0) {
2158
2161
  requestBody.labels = params.labels;
2159
2162
  }
2160
- if (params.originAppId !== void 0) {
2161
- requestBody.originAppId = params.originAppId;
2163
+ const originAppId = params.originAppId ?? ctx.originAppId;
2164
+ if (originAppId !== void 0) {
2165
+ requestBody.originAppId = originAppId;
2162
2166
  }
2163
2167
  return call(
2164
2168
  ctx,
@@ -2172,13 +2176,14 @@ function comment(ctx, number, body) {
2172
2176
  ctx,
2173
2177
  "POST",
2174
2178
  `/_internal/v2/apps/${ctx.appId}/issues/${seg(number)}/comments`,
2175
- { body, authorKind: "agent" }
2179
+ { body, authorKind: "agent", ...authorship(ctx) }
2176
2180
  );
2177
2181
  }
2178
2182
  function close(ctx, number, comment2) {
2179
2183
  const requestBody = {
2180
2184
  status: "closed",
2181
- authorKind: "agent"
2185
+ authorKind: "agent",
2186
+ ...authorship(ctx)
2182
2187
  };
2183
2188
  if (comment2 !== void 0) {
2184
2189
  requestBody.comment = comment2;
@@ -2195,11 +2200,14 @@ function reopen(ctx, number) {
2195
2200
  ctx,
2196
2201
  "POST",
2197
2202
  `/_internal/v2/apps/${ctx.appId}/issues/${seg(number)}/update`,
2198
- { status: "open", authorKind: "agent" }
2203
+ { status: "open", authorKind: "agent", ...authorship(ctx) }
2199
2204
  );
2200
2205
  }
2201
2206
  function edit(ctx, number, params) {
2202
- const requestBody = { authorKind: "agent" };
2207
+ const requestBody = {
2208
+ authorKind: "agent",
2209
+ ...authorship(ctx)
2210
+ };
2203
2211
  if (params.title !== void 0) {
2204
2212
  requestBody.title = params.title;
2205
2213
  }
@@ -2694,9 +2702,20 @@ function buildClient(ctx) {
2694
2702
  return {
2695
2703
  /** The resolved context this client is bound to. */
2696
2704
  context: ctx,
2697
- /** A sibling client for another app, sharing credentials. */
2705
+ /**
2706
+ * A sibling client for another app, sharing credentials.
2707
+ *
2708
+ * The app we came from becomes the origin, so a write through the returned
2709
+ * client records which app acted — the same rule the CLI's `--app` follows.
2710
+ * Chaining `forApp` twice keeps the FIRST app as the origin, since that is
2711
+ * the one whose workspace this code is running in.
2712
+ */
2698
2713
  forApp(appId) {
2699
- return buildClient({ ...ctx, appId });
2714
+ return buildClient({
2715
+ ...ctx,
2716
+ appId,
2717
+ originAppId: appId === ctx.appId ? ctx.originAppId : ctx.originAppId ?? ctx.appId
2718
+ });
2700
2719
  },
2701
2720
  agent: bindOps(agent_exports, ctx),
2702
2721
  analytics: bindOps(analytics_exports, ctx),