Skip to content

Commit 5fb04b1

Browse files
Automatically update NodeJS SDK
1 parent 63cd6ca commit 5fb04b1

29 files changed

Lines changed: 315 additions & 3 deletions

api/errors/ForbiddenError.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
import * as errors from "../../errors";
5+
import * as TrophyApi from "..";
6+
export declare class ForbiddenError extends errors.TrophyApiError {
7+
constructor(body: TrophyApi.ErrorBody);
8+
}

api/errors/ForbiddenError.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"use strict";
2+
/**
3+
* This file was auto-generated by Fern from our API Definition.
4+
*/
5+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6+
if (k2 === undefined) k2 = k;
7+
var desc = Object.getOwnPropertyDescriptor(m, k);
8+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9+
desc = { enumerable: true, get: function() { return m[k]; } };
10+
}
11+
Object.defineProperty(o, k2, desc);
12+
}) : (function(o, m, k, k2) {
13+
if (k2 === undefined) k2 = k;
14+
o[k2] = m[k];
15+
}));
16+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17+
Object.defineProperty(o, "default", { enumerable: true, value: v });
18+
}) : function(o, v) {
19+
o["default"] = v;
20+
});
21+
var __importStar = (this && this.__importStar) || function (mod) {
22+
if (mod && mod.__esModule) return mod;
23+
var result = {};
24+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25+
__setModuleDefault(result, mod);
26+
return result;
27+
};
28+
Object.defineProperty(exports, "__esModule", { value: true });
29+
exports.ForbiddenError = void 0;
30+
const errors = __importStar(require("../../errors"));
31+
class ForbiddenError extends errors.TrophyApiError {
32+
constructor(body) {
33+
super({
34+
message: "ForbiddenError",
35+
statusCode: 403,
36+
body: body,
37+
});
38+
Object.setPrototypeOf(this, ForbiddenError.prototype);
39+
}
40+
}
41+
exports.ForbiddenError = ForbiddenError;

api/errors/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from "./UnauthorizedError";
22
export * from "./UnprocessableEntityError";
33
export * from "./NotFoundError";
44
export * from "./BadRequestError";
5+
export * from "./ForbiddenError";

api/errors/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ __exportStar(require("./UnauthorizedError"), exports);
1818
__exportStar(require("./UnprocessableEntityError"), exports);
1919
__exportStar(require("./NotFoundError"), exports);
2020
__exportStar(require("./BadRequestError"), exports);
21+
__exportStar(require("./ForbiddenError"), exports);

api/resources/users/client/Client.d.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ export declare class Users {
8686
*/
8787
getPreferences(id: string, requestOptions?: Users.RequestOptions): Promise<TrophyApi.UserPreferencesResponse>;
8888
/**
89-
* Update a user's notification preferences.
89+
* Update a user's notification and streak preferences. Streak preferences require streak customization to be enabled in your Trophy dashboard settings.
9090
* @throws {@link TrophyApi.UnauthorizedError}
91+
* @throws {@link TrophyApi.ForbiddenError}
9192
* @throws {@link TrophyApi.NotFoundError}
9293
* @throws {@link TrophyApi.UnprocessableEntityError}
9394
*
@@ -111,6 +112,17 @@ export declare class Users {
111112
* achievementCompleted: [TrophyApi.NotificationChannel.Email, TrophyApi.NotificationChannel.Push]
112113
* }
113114
* })
115+
*
116+
* @example
117+
* await trophyApi.users.updatePreferences("user-123", {
118+
* streak: {
119+
* evaluationMode: TrophyApi.StreakEvaluationModePreference.Or,
120+
* metrics: [{
121+
* key: "words-written",
122+
* threshold: 500
123+
* }]
124+
* }
125+
* })
114126
*/
115127
updatePreferences(id: string, request?: TrophyApi.UpdateUserPreferencesRequest, requestOptions?: Users.RequestOptions): Promise<TrophyApi.UserPreferencesResponse>;
116128
/**

api/resources/users/client/Client.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,9 @@ class Users {
477477
});
478478
}
479479
/**
480-
* Update a user's notification preferences.
480+
* Update a user's notification and streak preferences. Streak preferences require streak customization to be enabled in your Trophy dashboard settings.
481481
* @throws {@link TrophyApi.UnauthorizedError}
482+
* @throws {@link TrophyApi.ForbiddenError}
482483
* @throws {@link TrophyApi.NotFoundError}
483484
* @throws {@link TrophyApi.UnprocessableEntityError}
484485
*
@@ -502,6 +503,17 @@ class Users {
502503
* achievementCompleted: [TrophyApi.NotificationChannel.Email, TrophyApi.NotificationChannel.Push]
503504
* }
504505
* })
506+
*
507+
* @example
508+
* await trophyApi.users.updatePreferences("user-123", {
509+
* streak: {
510+
* evaluationMode: TrophyApi.StreakEvaluationModePreference.Or,
511+
* metrics: [{
512+
* key: "words-written",
513+
* threshold: 500
514+
* }]
515+
* }
516+
* })
505517
*/
506518
updatePreferences(id, request = {}, requestOptions) {
507519
var _a;
@@ -541,6 +553,13 @@ class Users {
541553
allowUnrecognizedEnumValues: true,
542554
breadcrumbsPrefix: ["response"],
543555
}));
556+
case 403:
557+
throw new TrophyApi.ForbiddenError(yield serializers.ErrorBody.parseOrThrow(_response.error.body, {
558+
unrecognizedObjectKeys: "passthrough",
559+
allowUnrecognizedUnionMembers: true,
560+
allowUnrecognizedEnumValues: true,
561+
breadcrumbsPrefix: ["response"],
562+
}));
544563
case 404:
545564
throw new TrophyApi.NotFoundError(yield serializers.ErrorBody.parseOrThrow(_response.error.body, {
546565
unrecognizedObjectKeys: "passthrough",

api/resources/users/client/requests/UpdateUserPreferencesRequest.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,19 @@ import * as TrophyApi from "../../../..";
2323
* achievementCompleted: [TrophyApi.NotificationChannel.Email, TrophyApi.NotificationChannel.Push]
2424
* }
2525
* }
26+
*
27+
* @example
28+
* {
29+
* streak: {
30+
* evaluationMode: TrophyApi.StreakEvaluationModePreference.Or,
31+
* metrics: [{
32+
* key: "words-written",
33+
* threshold: 500
34+
* }]
35+
* }
36+
* }
2637
*/
2738
export interface UpdateUserPreferencesRequest {
2839
notifications?: TrophyApi.NotificationPreferences;
40+
streak?: TrophyApi.StreakPreferences;
2941
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
/**
5+
* Whether meeting any single metric threshold (`OR`) or all configured metric thresholds (`AND`) extends the user's streak. Matches the evaluation mode configured in dashboard streak settings.
6+
*/
7+
export declare type StreakEvaluationModePreference = "OR" | "AND";
8+
export declare const StreakEvaluationModePreference: {
9+
readonly Or: "OR";
10+
readonly And: "AND";
11+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"use strict";
2+
/**
3+
* This file was auto-generated by Fern from our API Definition.
4+
*/
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
exports.StreakEvaluationModePreference = void 0;
7+
exports.StreakEvaluationModePreference = {
8+
Or: "OR",
9+
And: "AND",
10+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
/**
5+
* Per-metric streak threshold override for a user.
6+
*/
7+
export interface StreakMetricPreference {
8+
/** The metric key. */
9+
key: string;
10+
/** Minimum metric change in a streak period to count toward the streak. */
11+
threshold: number;
12+
}

0 commit comments

Comments
 (0)