@playcademy/sdk 0.13.1-beta.4 → 0.14.1-beta.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 +9 -0
- package/dist/index.js +31 -2
- package/dist/internal.d.ts +1112 -1070
- package/dist/internal.js +31 -2
- package/dist/server/edge.js +1 -1
- package/dist/server.js +1 -1
- package/dist/types.d.ts +44 -2
- package/package.json +1 -1
package/dist/internal.js
CHANGED
|
@@ -1137,6 +1137,8 @@ function isValidGrade(value) {
|
|
|
1137
1137
|
function isValidSubject(value) {
|
|
1138
1138
|
return typeof value === "string" && VALID_SUBJECTS.includes(value);
|
|
1139
1139
|
}
|
|
1140
|
+
// ../constants/src/platform.ts
|
|
1141
|
+
var PLAYCADEMY_BROWSER_TIME_ZONE_HEADER = "x-playcademy-browser-time-zone";
|
|
1140
1142
|
// ../constants/src/timeback.ts
|
|
1141
1143
|
var TIMEBACK_ROUTES = {
|
|
1142
1144
|
END_ACTIVITY: "/integrations/timeback/end-activity",
|
|
@@ -2122,7 +2124,12 @@ function createUsersNamespace(client) {
|
|
|
2122
2124
|
return {
|
|
2123
2125
|
me: async () => {
|
|
2124
2126
|
assertPlatformMode(client, "users.me()");
|
|
2125
|
-
|
|
2127
|
+
const user = await client["request"]("/users/me", "GET");
|
|
2128
|
+
const initPayload = client["initPayload"];
|
|
2129
|
+
if (initPayload) {
|
|
2130
|
+
initPayload.localDay = user.localDay;
|
|
2131
|
+
}
|
|
2132
|
+
return user;
|
|
2126
2133
|
}
|
|
2127
2134
|
};
|
|
2128
2135
|
}
|
|
@@ -3082,7 +3089,7 @@ async function request({
|
|
|
3082
3089
|
return rawText && rawText.length > 0 ? rawText : undefined;
|
|
3083
3090
|
}
|
|
3084
3091
|
// src/version.ts
|
|
3085
|
-
var SDK_VERSION = "0.
|
|
3092
|
+
var SDK_VERSION = "0.14.1-beta.1";
|
|
3086
3093
|
|
|
3087
3094
|
// src/clients/base.ts
|
|
3088
3095
|
class PlaycademyBaseClient {
|
|
@@ -3097,6 +3104,7 @@ class PlaycademyBaseClient {
|
|
|
3097
3104
|
initPayload;
|
|
3098
3105
|
launchId;
|
|
3099
3106
|
gameOrigin;
|
|
3107
|
+
browserTimeZone;
|
|
3100
3108
|
constructor(config) {
|
|
3101
3109
|
this.baseUrl = config?.baseUrl?.endsWith("/api") ? config.baseUrl : `${config?.baseUrl}/api`;
|
|
3102
3110
|
this.gameUrl = config?.gameUrl;
|
|
@@ -3125,6 +3133,9 @@ class PlaycademyBaseClient {
|
|
|
3125
3133
|
ping() {
|
|
3126
3134
|
return "pong";
|
|
3127
3135
|
}
|
|
3136
|
+
get localDay() {
|
|
3137
|
+
return this.initPayload?.localDay;
|
|
3138
|
+
}
|
|
3128
3139
|
setToken(token, tokenType) {
|
|
3129
3140
|
this.authStrategy = createAuthStrategy(token, tokenType);
|
|
3130
3141
|
this.emit("authChange", { token });
|
|
@@ -3168,11 +3179,13 @@ class PlaycademyBaseClient {
|
|
|
3168
3179
|
});
|
|
3169
3180
|
}
|
|
3170
3181
|
async request(path, method, options) {
|
|
3182
|
+
const browserTimeZone = this.getBrowserTimeZone();
|
|
3171
3183
|
const effectiveHeaders = {
|
|
3172
3184
|
...options?.headers,
|
|
3173
3185
|
...this.authStrategy.getHeaders(),
|
|
3174
3186
|
...this.launchId ? { "x-playcademy-launch-id": this.launchId } : {},
|
|
3175
3187
|
...this.gameOrigin ? { "x-playcademy-game-origin": this.gameOrigin } : {},
|
|
3188
|
+
...browserTimeZone ? { [PLAYCADEMY_BROWSER_TIME_ZONE_HEADER]: browserTimeZone } : {},
|
|
3176
3189
|
"x-playcademy-sdk-version": SDK_VERSION
|
|
3177
3190
|
};
|
|
3178
3191
|
return request({
|
|
@@ -3185,6 +3198,22 @@ class PlaycademyBaseClient {
|
|
|
3185
3198
|
retryPolicy: options?.retryPolicy
|
|
3186
3199
|
});
|
|
3187
3200
|
}
|
|
3201
|
+
getBrowserTimeZone() {
|
|
3202
|
+
if (this.browserTimeZone !== undefined) {
|
|
3203
|
+
return this.browserTimeZone ?? undefined;
|
|
3204
|
+
}
|
|
3205
|
+
if (typeof globalThis.window === "undefined") {
|
|
3206
|
+
this.browserTimeZone = null;
|
|
3207
|
+
return;
|
|
3208
|
+
}
|
|
3209
|
+
try {
|
|
3210
|
+
const timeZone = new Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
3211
|
+
this.browserTimeZone = typeof timeZone === "string" && timeZone ? timeZone : null;
|
|
3212
|
+
} catch {
|
|
3213
|
+
this.browserTimeZone = null;
|
|
3214
|
+
}
|
|
3215
|
+
return this.browserTimeZone ?? undefined;
|
|
3216
|
+
}
|
|
3188
3217
|
async requestGameBackend(path, method, body, headers, options) {
|
|
3189
3218
|
const effectiveHeaders = {
|
|
3190
3219
|
...headers,
|
package/dist/server/edge.js
CHANGED
package/dist/server.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _playcademy_types from '@playcademy/types';
|
|
2
|
-
import { GameManifest } from '@playcademy/types';
|
|
3
|
-
export { AuthenticatedUser, DeveloperStatusEnumType, DeveloperStatusResponse, DeveloperStatusValue, GameCourseMetrics, GameLeaderboardEntry, GameManifest, GameMetricComparisonKind, GameMetricComparisonMetric, GameMetricComparisonRow, GameMetricComparisonRowStatus, GameMetricsProxyResponse, GameMetricsResponse, GameMetricsUnsupportedReason, GamePlatform, GameRunMetrics, GameRunMetricsComparison, GameRunMetricsComparisonStatus, GameRunMetricsComparisonSummary, GameTimebackIntegration, GameType, GameUser, LeaderboardEntry, LeaderboardOptions, LeaderboardTimeframe, ManifestV1, ManifestV2, ManifestVersions, PopulateStudentResponse, UserEnrollment, UserInfo, UserOrganization, UserRank, UserRankResponse, UserRoleEnumType, UserScore, UserTimebackData } from '@playcademy/types';
|
|
2
|
+
import { GameManifest, LocalDayContext } from '@playcademy/types';
|
|
3
|
+
export { AuthenticatedUser, DeveloperStatusEnumType, DeveloperStatusResponse, DeveloperStatusValue, GameCourseMetrics, GameLeaderboardEntry, GameManifest, GameMetricComparisonKind, GameMetricComparisonMetric, GameMetricComparisonRow, GameMetricComparisonRowStatus, GameMetricsProxyResponse, GameMetricsResponse, GameMetricsUnsupportedReason, GamePlatform, GameRunMetrics, GameRunMetricsComparison, GameRunMetricsComparisonStatus, GameRunMetricsComparisonSummary, GameTimebackIntegration, GameType, GameUser, LeaderboardEntry, LeaderboardOptions, LeaderboardTimeframe, LocalDayContext, LocalDaySource, ManifestV1, ManifestV2, ManifestVersions, PopulateStudentResponse, UserEnrollment, UserInfo, UserOrganization, UserRank, UserRankResponse, UserRoleEnumType, UserScore, UserTimebackData } from '@playcademy/types';
|
|
4
4
|
import { TimebackCourseConfig, CourseConfig, OrganizationConfig, ComponentConfig, ResourceConfig, ComponentResourceConfig, TimebackGrade, TimebackSubject, HeartbeatRequest } from '@playcademy/types/timeback';
|
|
5
5
|
export { QtiTestQuestionRef, QtiTestQuestionsResponse } from '@playcademy/types/timeback';
|
|
6
6
|
import { TimebackUserRole, UserEnrollment, UserOrganization, UserInfo } from '@playcademy/types/user';
|
|
@@ -506,6 +506,40 @@ declare const users: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
|
506
506
|
identity: undefined;
|
|
507
507
|
generated: undefined;
|
|
508
508
|
}, {}, {}>;
|
|
509
|
+
learningTimeZone: drizzle_orm_pg_core.PgColumn<{
|
|
510
|
+
name: "learning_time_zone";
|
|
511
|
+
tableName: "user";
|
|
512
|
+
dataType: "string";
|
|
513
|
+
columnType: "PgText";
|
|
514
|
+
data: string;
|
|
515
|
+
driverParam: string;
|
|
516
|
+
notNull: false;
|
|
517
|
+
hasDefault: false;
|
|
518
|
+
isPrimaryKey: false;
|
|
519
|
+
isAutoincrement: false;
|
|
520
|
+
hasRuntimeDefault: false;
|
|
521
|
+
enumValues: [string, ...string[]];
|
|
522
|
+
baseColumn: never;
|
|
523
|
+
identity: undefined;
|
|
524
|
+
generated: undefined;
|
|
525
|
+
}, {}, {}>;
|
|
526
|
+
learningTimeZoneUpdatedAt: drizzle_orm_pg_core.PgColumn<{
|
|
527
|
+
name: "learning_time_zone_updated_at";
|
|
528
|
+
tableName: "user";
|
|
529
|
+
dataType: "date";
|
|
530
|
+
columnType: "PgTimestamp";
|
|
531
|
+
data: Date;
|
|
532
|
+
driverParam: string;
|
|
533
|
+
notNull: false;
|
|
534
|
+
hasDefault: false;
|
|
535
|
+
isPrimaryKey: false;
|
|
536
|
+
isAutoincrement: false;
|
|
537
|
+
hasRuntimeDefault: false;
|
|
538
|
+
enumValues: undefined;
|
|
539
|
+
baseColumn: never;
|
|
540
|
+
identity: undefined;
|
|
541
|
+
generated: undefined;
|
|
542
|
+
}, {}, {}>;
|
|
509
543
|
emailVerified: drizzle_orm_pg_core.PgColumn<{
|
|
510
544
|
name: "email_verified";
|
|
511
545
|
tableName: "user";
|
|
@@ -1166,6 +1200,7 @@ declare abstract class PlaycademyBaseClient {
|
|
|
1166
1200
|
protected initPayload?: InitPayload;
|
|
1167
1201
|
protected launchId?: string;
|
|
1168
1202
|
protected gameOrigin?: string;
|
|
1203
|
+
private browserTimeZone?;
|
|
1169
1204
|
constructor(config?: Partial<ClientConfig>);
|
|
1170
1205
|
/**
|
|
1171
1206
|
* Gets the effective base URL for API requests.
|
|
@@ -1179,6 +1214,10 @@ declare abstract class PlaycademyBaseClient {
|
|
|
1179
1214
|
* Simple ping method for testing connectivity.
|
|
1180
1215
|
*/
|
|
1181
1216
|
ping(): string;
|
|
1217
|
+
/**
|
|
1218
|
+
* Local day context supplied by the platform during iframe initialization.
|
|
1219
|
+
*/
|
|
1220
|
+
get localDay(): LocalDayContext | undefined;
|
|
1182
1221
|
/**
|
|
1183
1222
|
* Sets the authentication token for API requests.
|
|
1184
1223
|
*/
|
|
@@ -1235,6 +1274,7 @@ declare abstract class PlaycademyBaseClient {
|
|
|
1235
1274
|
raw?: boolean;
|
|
1236
1275
|
retryPolicy?: RetryPolicy;
|
|
1237
1276
|
}): Promise<T>;
|
|
1277
|
+
private getBrowserTimeZone;
|
|
1238
1278
|
/**
|
|
1239
1279
|
* Makes an authenticated HTTP request to the game's backend Worker.
|
|
1240
1280
|
*/
|
|
@@ -1817,6 +1857,8 @@ interface InitPayload {
|
|
|
1817
1857
|
gameId: string;
|
|
1818
1858
|
/** Timeback context (if user has a Timeback account) */
|
|
1819
1859
|
timeback?: TimebackInitContext;
|
|
1860
|
+
/** Playcademy context for resolving the student's local learning day */
|
|
1861
|
+
localDay?: LocalDayContext;
|
|
1820
1862
|
/** Runtime mode for the game client */
|
|
1821
1863
|
mode?: PlaycademyMode;
|
|
1822
1864
|
/** Launch session correlation ID (UUID, set by platform on game launch) */
|