exponential-sdk 1.11.0 → 1.12.1
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 +789 -8
- package/dist/index.js +197 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -259,6 +259,181 @@ var GoalCommentsApi = class {
|
|
|
259
259
|
}
|
|
260
260
|
};
|
|
261
261
|
|
|
262
|
+
// src/goals.ts
|
|
263
|
+
var GoalsApi = class {
|
|
264
|
+
constructor(client, keyResults) {
|
|
265
|
+
this.client = client;
|
|
266
|
+
this.keyResults = keyResults;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* List objectives. Pass `workspaceId` for the workspace-wide list (every
|
|
270
|
+
* member's), omit it for your own. Includes each objective's linked
|
|
271
|
+
* `projects`, which is the join that maps day-to-day work back to an OKR:
|
|
272
|
+
* every action carries a `projectId`.
|
|
273
|
+
*
|
|
274
|
+
* `period` and `status` are sent to the server *and* re-applied here. The
|
|
275
|
+
* server grew those filters recently; against an instance that predates them
|
|
276
|
+
* zod strips the unknown keys and hands back **every** objective — a filter
|
|
277
|
+
* that silently matches everything is worse than one that errors. Re-applying
|
|
278
|
+
* is a no-op once the server has done the work. Same reasoning as the
|
|
279
|
+
* client-side `branchName`/`prUrl` filters in `tickets.ts`.
|
|
280
|
+
*/
|
|
281
|
+
async list(options = {}) {
|
|
282
|
+
const goals = await this.client.goal.getAllMyGoals.query(options);
|
|
283
|
+
return goals.filter(
|
|
284
|
+
(g) => (options.period === void 0 || g.period === options.period) && (options.status === void 0 || g.status === options.status)
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* The same objectives nested parent → child (up to 5 levels), each with its
|
|
289
|
+
* projects and key results. One call for the whole annual → quarterly cascade.
|
|
290
|
+
*/
|
|
291
|
+
async tree(options = {}) {
|
|
292
|
+
return await this.client.goal.getGoalTree.query(
|
|
293
|
+
options
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
async get(id) {
|
|
297
|
+
return await this.client.goal.getById.query({ id });
|
|
298
|
+
}
|
|
299
|
+
/** Objectives linked to a given project. */
|
|
300
|
+
async listByProject(projectId) {
|
|
301
|
+
return await this.client.goal.getProjectGoals.query({ projectId });
|
|
302
|
+
}
|
|
303
|
+
async create(input) {
|
|
304
|
+
return await this.client.goal.createGoal.mutate(input);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Partial update — see {@link GoalUpdateInput}. Fields you omit are left
|
|
308
|
+
* alone; pass an explicit `null` to clear one.
|
|
309
|
+
*/
|
|
310
|
+
async update(input) {
|
|
311
|
+
return await this.client.goal.updateGoal.mutate(input);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Status-only write. Never touches another field, and is the only path that
|
|
315
|
+
* accepts `on-hold`. Moving an objective to `completed` also records a
|
|
316
|
+
* workspace milestone.
|
|
317
|
+
*/
|
|
318
|
+
async setStatus(input) {
|
|
319
|
+
return await this.client.goal.updateGoalStatus.mutate(input);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Re-parent an objective, or detach it with `parentGoalId: null`. Writes only
|
|
323
|
+
* `parentGoalId`, and validates the no-self / no-cycle / depth-5 rules.
|
|
324
|
+
*/
|
|
325
|
+
async setParent(input) {
|
|
326
|
+
return await this.client.goal.setParent.mutate(input);
|
|
327
|
+
}
|
|
328
|
+
async delete(id) {
|
|
329
|
+
return await this.client.goal.deleteGoal.mutate({ id });
|
|
330
|
+
}
|
|
331
|
+
/** The conventional period strings (quarters, halves, annual) for this year and next. */
|
|
332
|
+
async periods() {
|
|
333
|
+
return await this.client.okr.getPeriods.query();
|
|
334
|
+
}
|
|
335
|
+
/** Aggregate objective/key-result counts and average progress. */
|
|
336
|
+
async stats(options = {}) {
|
|
337
|
+
return await this.client.okr.getStats.query(options);
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
// src/keyResults.ts
|
|
342
|
+
var KeyResultsApi = class {
|
|
343
|
+
constructor(client) {
|
|
344
|
+
this.client = client;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* List key results. Pass `workspaceId` for the workspace-wide list (every
|
|
348
|
+
* member's), omit it for your own.
|
|
349
|
+
*
|
|
350
|
+
* ⚠️ Workspace scoping here depends on a server-side fix to `okr.getAll`,
|
|
351
|
+
* which previously accepted a `workspaceId` while still filtering on the
|
|
352
|
+
* caller's `userId` — so against an older instance this returns only your own
|
|
353
|
+
* key results, or `[]`, rather than the workspace's. Unlike the filters in
|
|
354
|
+
* `goals.list()` that cannot be repaired here: the other members' rows never
|
|
355
|
+
* reach the client. {@link KeyResultsApi.byObjective} is workspace-correct on
|
|
356
|
+
* every server version and is the safer read when that matters.
|
|
357
|
+
*/
|
|
358
|
+
async list(options = {}) {
|
|
359
|
+
return await this.client.okr.getAll.query(options);
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Objectives with their key results nested — the richest OKR read, and the
|
|
363
|
+
* one to reach for when rendering "here is the quarter".
|
|
364
|
+
*/
|
|
365
|
+
async byObjective(options = {}) {
|
|
366
|
+
return await this.client.okr.getByObjective.query(
|
|
367
|
+
options
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
async get(id) {
|
|
371
|
+
return await this.client.okr.getById.query({ id });
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Create a key result on an objective.
|
|
375
|
+
*
|
|
376
|
+
* When `workspaceId` is omitted it is resolved from the objective first,
|
|
377
|
+
* rather than left to the server. `okr.create` writes the input through as-is
|
|
378
|
+
* on older instances, so an absent workspace persists as `null` — and a key
|
|
379
|
+
* result with no workspace is invisible to every workspace-scoped read and
|
|
380
|
+
* unwritable by teammates once owner-OR-member authz applies. That is the
|
|
381
|
+
* same orphaning that has already cost a goal; one extra read on a mutation
|
|
382
|
+
* is a cheap way not to repeat it.
|
|
383
|
+
*/
|
|
384
|
+
async create(input) {
|
|
385
|
+
let workspaceId = input.workspaceId;
|
|
386
|
+
if (workspaceId === void 0) {
|
|
387
|
+
const goal = await this.client.goal.getById.query({
|
|
388
|
+
id: input.goalId
|
|
389
|
+
});
|
|
390
|
+
workspaceId = goal.workspaceId ?? void 0;
|
|
391
|
+
}
|
|
392
|
+
return await this.client.okr.create.mutate({
|
|
393
|
+
...input,
|
|
394
|
+
workspaceId
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
async update(input) {
|
|
398
|
+
return await this.client.okr.update.mutate(input);
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Record a progress check-in. The server derives the new status from where
|
|
402
|
+
* `value` lands between `startValue` and `targetValue`, so a check-in both
|
|
403
|
+
* moves the number and re-colours the key result.
|
|
404
|
+
*/
|
|
405
|
+
async checkIn(input) {
|
|
406
|
+
return await this.client.okr.checkIn.mutate({
|
|
407
|
+
keyResultId: input.id,
|
|
408
|
+
newValue: input.value,
|
|
409
|
+
notes: input.note
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
async delete(id) {
|
|
413
|
+
return await this.client.okr.delete.mutate({ id });
|
|
414
|
+
}
|
|
415
|
+
/** Link a project to a key result as executing work. Idempotent. */
|
|
416
|
+
async linkProject(input) {
|
|
417
|
+
return await this.client.okr.linkProject.mutate(input);
|
|
418
|
+
}
|
|
419
|
+
async unlinkProject(input) {
|
|
420
|
+
return await this.client.okr.unlinkProject.mutate(input);
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Link a feature to a key result as executing work. Idempotent. The feature's
|
|
424
|
+
* product must live in the key result's workspace. A feature with no
|
|
425
|
+
* objective alignment inherits the key result's objective; one that already
|
|
426
|
+
* has an objective is never overwritten.
|
|
427
|
+
*/
|
|
428
|
+
async linkFeature(input) {
|
|
429
|
+
return await this.client.okr.linkFeature.mutate(input);
|
|
430
|
+
}
|
|
431
|
+
/** Removes only the link row — never the feature's objective alignment. */
|
|
432
|
+
async unlinkFeature(input) {
|
|
433
|
+
return await this.client.okr.unlinkFeature.mutate(input);
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
|
|
262
437
|
// src/projects.ts
|
|
263
438
|
var ProjectsApi = class {
|
|
264
439
|
constructor(client) {
|
|
@@ -384,8 +559,24 @@ var TicketsApi = class {
|
|
|
384
559
|
constructor(client) {
|
|
385
560
|
this.client = client;
|
|
386
561
|
}
|
|
562
|
+
/**
|
|
563
|
+
* List tickets in one product.
|
|
564
|
+
*
|
|
565
|
+
* `prUrl` and `branchName` are filtered here rather than on the server. The
|
|
566
|
+
* `product.ticket.list` tRPC input schema accepts neither, and zod strips
|
|
567
|
+
* unknown keys, so forwarding them was silently a no-op: a lookup by a branch
|
|
568
|
+
* that matched nothing came back as *every ticket in the product*. Filtering
|
|
569
|
+
* locally makes them mean what they say. Move them server-side once
|
|
570
|
+
* `product.ticket.list` grows the matching input fields.
|
|
571
|
+
*/
|
|
387
572
|
async list(options) {
|
|
388
|
-
|
|
573
|
+
const { prUrl, branchName, ...serverQuery } = options;
|
|
574
|
+
const tickets = await this.client.product.ticket.list.query(
|
|
575
|
+
serverQuery
|
|
576
|
+
);
|
|
577
|
+
return tickets.filter(
|
|
578
|
+
(t) => (prUrl === void 0 || t.prUrl === prUrl) && (branchName === void 0 || t.branchName === branchName)
|
|
579
|
+
);
|
|
389
580
|
}
|
|
390
581
|
async get(id) {
|
|
391
582
|
return await this.client.product.ticket.getById.query({
|
|
@@ -802,6 +993,8 @@ var ExponentialClient = class {
|
|
|
802
993
|
this.featureComments = new FeatureCommentsApi(this.client);
|
|
803
994
|
this.pageComments = new PageCommentsApi(this.client);
|
|
804
995
|
this.goalComments = new GoalCommentsApi(this.client);
|
|
996
|
+
this.keyResults = new KeyResultsApi(this.client);
|
|
997
|
+
this.goals = new GoalsApi(this.client, this.keyResults);
|
|
805
998
|
this.projects = new ProjectsApi(this.client);
|
|
806
999
|
this.workspaces = new WorkspacesApi(this.client);
|
|
807
1000
|
this.contacts = new ContactsApi(this.client);
|
|
@@ -825,6 +1018,9 @@ var ExponentialClient = class {
|
|
|
825
1018
|
featureComments;
|
|
826
1019
|
pageComments;
|
|
827
1020
|
goalComments;
|
|
1021
|
+
goals;
|
|
1022
|
+
/** Same instance as `goals.keyResults`. */
|
|
1023
|
+
keyResults;
|
|
828
1024
|
projects;
|
|
829
1025
|
workspaces;
|
|
830
1026
|
contacts;
|