@playcademy/sdk 0.11.0-beta.1 → 0.11.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 -3
- package/dist/index.js +43 -14
- package/dist/internal.js +43 -14
- package/dist/types.d.ts +9 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1028,9 +1028,15 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
|
|
|
1028
1028
|
pauseActivity: () => void;
|
|
1029
1029
|
resumeActivity: () => void;
|
|
1030
1030
|
endActivity: (data: _playcademy_types.EndActivityScoreData) => Promise<_playcademy_types.EndActivityResponse>;
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1031
|
+
course: {
|
|
1032
|
+
advance: (options?: {
|
|
1033
|
+
subject?: _playcademy_types.TimebackSubject;
|
|
1034
|
+
}) => Promise<_playcademy_types.AdvanceCourseResponse>;
|
|
1035
|
+
unenroll: (options?: {
|
|
1036
|
+
subject?: _playcademy_types.TimebackSubject;
|
|
1037
|
+
force?: boolean;
|
|
1038
|
+
}) => Promise<_playcademy_types.UnenrollCourseResponse>;
|
|
1039
|
+
};
|
|
1034
1040
|
};
|
|
1035
1041
|
/**
|
|
1036
1042
|
* Game score submission and leaderboards.
|
package/dist/index.js
CHANGED
|
@@ -1147,7 +1147,8 @@ var TIMEBACK_ROUTES = {
|
|
|
1147
1147
|
GET_XP: "/integrations/timeback/xp",
|
|
1148
1148
|
GET_MASTERY: "/integrations/timeback/mastery",
|
|
1149
1149
|
HEARTBEAT: "/integrations/timeback/heartbeat",
|
|
1150
|
-
ADVANCE_COURSE: "/integrations/timeback/advance-course"
|
|
1150
|
+
ADVANCE_COURSE: "/integrations/timeback/advance-course",
|
|
1151
|
+
UNENROLL_COURSE: "/integrations/timeback/unenroll-course"
|
|
1151
1152
|
};
|
|
1152
1153
|
var TIMEBACK_GAME_METRIC_DECIMAL_PLACES = {
|
|
1153
1154
|
xp: 1,
|
|
@@ -1804,16 +1805,20 @@ function createTimebackEngine(client) {
|
|
|
1804
1805
|
ttl: 5 * 60 * 1000,
|
|
1805
1806
|
keyPrefix: "game.timeback.enrollments"
|
|
1806
1807
|
});
|
|
1807
|
-
async function
|
|
1808
|
-
if (promotion.status !== "promoted" && promotion.status !== "already-promoted") {
|
|
1809
|
-
return;
|
|
1810
|
-
}
|
|
1808
|
+
async function refreshAfterCourseMutation() {
|
|
1811
1809
|
userCache.clear("current");
|
|
1812
1810
|
enrollmentsCache.clear("current");
|
|
1811
|
+
xpCache.clear();
|
|
1813
1812
|
try {
|
|
1814
1813
|
await userStore.refresh();
|
|
1815
1814
|
} catch {}
|
|
1816
1815
|
}
|
|
1816
|
+
async function applyPromotion(promotion) {
|
|
1817
|
+
if (promotion.status !== "promoted" && promotion.status !== "already-promoted") {
|
|
1818
|
+
return;
|
|
1819
|
+
}
|
|
1820
|
+
await refreshAfterCourseMutation();
|
|
1821
|
+
}
|
|
1817
1822
|
const activityTracker = createTimebackActivityTracker(client);
|
|
1818
1823
|
async function refreshUserContext() {
|
|
1819
1824
|
const context = await userStore.refresh();
|
|
@@ -1900,10 +1905,22 @@ function createTimebackEngine(client) {
|
|
|
1900
1905
|
resume: activityTracker.resumeActivity,
|
|
1901
1906
|
end: activityTracker.endActivity
|
|
1902
1907
|
},
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1908
|
+
course: {
|
|
1909
|
+
async advance(params) {
|
|
1910
|
+
const response = await client["requestGameBackend"](TIMEBACK_ROUTES.ADVANCE_COURSE, "POST", params?.subject !== undefined ? { subject: params.subject } : {});
|
|
1911
|
+
await applyPromotion(response.promotion);
|
|
1912
|
+
return response;
|
|
1913
|
+
},
|
|
1914
|
+
async unenroll(params) {
|
|
1915
|
+
const response = await client["requestGameBackend"](TIMEBACK_ROUTES.UNENROLL_COURSE, "POST", {
|
|
1916
|
+
...params?.subject !== undefined ? { subject: params.subject } : {},
|
|
1917
|
+
...params?.force !== undefined ? { force: params.force } : {}
|
|
1918
|
+
});
|
|
1919
|
+
if (response.unenrollment.status === "unenrolled") {
|
|
1920
|
+
await refreshAfterCourseMutation();
|
|
1921
|
+
}
|
|
1922
|
+
return response;
|
|
1923
|
+
}
|
|
1907
1924
|
}
|
|
1908
1925
|
};
|
|
1909
1926
|
}
|
|
@@ -1999,12 +2016,24 @@ function createTimebackNamespace(client) {
|
|
|
1999
2016
|
assertPlatformMode(client, "timeback.endActivity()");
|
|
2000
2017
|
return engine.activity.end(data);
|
|
2001
2018
|
},
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2019
|
+
course: {
|
|
2020
|
+
advance: async (options) => {
|
|
2021
|
+
assertPlatformMode(client, "timeback.course.advance()");
|
|
2022
|
+
if (options?.subject !== undefined && !isValidSubject(options.subject)) {
|
|
2023
|
+
throw new Error(`Invalid subject: ${options.subject}. Valid subjects: ${VALID_SUBJECTS.join(", ")}`);
|
|
2024
|
+
}
|
|
2025
|
+
return engine.course.advance(options);
|
|
2026
|
+
},
|
|
2027
|
+
unenroll: async (options) => {
|
|
2028
|
+
assertPlatformMode(client, "timeback.course.unenroll()");
|
|
2029
|
+
if (options?.subject !== undefined && !isValidSubject(options.subject)) {
|
|
2030
|
+
throw new Error(`Invalid subject: ${options.subject}. Valid subjects: ${VALID_SUBJECTS.join(", ")}`);
|
|
2031
|
+
}
|
|
2032
|
+
if (options?.force !== undefined && typeof options.force !== "boolean") {
|
|
2033
|
+
throw new Error("Invalid force: must be a boolean");
|
|
2034
|
+
}
|
|
2035
|
+
return engine.course.unenroll(options);
|
|
2006
2036
|
}
|
|
2007
|
-
return engine.advanceCourse(options);
|
|
2008
2037
|
}
|
|
2009
2038
|
};
|
|
2010
2039
|
}
|
package/dist/internal.js
CHANGED
|
@@ -1147,7 +1147,8 @@ var TIMEBACK_ROUTES = {
|
|
|
1147
1147
|
GET_XP: "/integrations/timeback/xp",
|
|
1148
1148
|
GET_MASTERY: "/integrations/timeback/mastery",
|
|
1149
1149
|
HEARTBEAT: "/integrations/timeback/heartbeat",
|
|
1150
|
-
ADVANCE_COURSE: "/integrations/timeback/advance-course"
|
|
1150
|
+
ADVANCE_COURSE: "/integrations/timeback/advance-course",
|
|
1151
|
+
UNENROLL_COURSE: "/integrations/timeback/unenroll-course"
|
|
1151
1152
|
};
|
|
1152
1153
|
var TIMEBACK_GAME_METRIC_DECIMAL_PLACES = {
|
|
1153
1154
|
xp: 1,
|
|
@@ -1804,16 +1805,20 @@ function createTimebackEngine(client) {
|
|
|
1804
1805
|
ttl: 5 * 60 * 1000,
|
|
1805
1806
|
keyPrefix: "game.timeback.enrollments"
|
|
1806
1807
|
});
|
|
1807
|
-
async function
|
|
1808
|
-
if (promotion.status !== "promoted" && promotion.status !== "already-promoted") {
|
|
1809
|
-
return;
|
|
1810
|
-
}
|
|
1808
|
+
async function refreshAfterCourseMutation() {
|
|
1811
1809
|
userCache.clear("current");
|
|
1812
1810
|
enrollmentsCache.clear("current");
|
|
1811
|
+
xpCache.clear();
|
|
1813
1812
|
try {
|
|
1814
1813
|
await userStore.refresh();
|
|
1815
1814
|
} catch {}
|
|
1816
1815
|
}
|
|
1816
|
+
async function applyPromotion(promotion) {
|
|
1817
|
+
if (promotion.status !== "promoted" && promotion.status !== "already-promoted") {
|
|
1818
|
+
return;
|
|
1819
|
+
}
|
|
1820
|
+
await refreshAfterCourseMutation();
|
|
1821
|
+
}
|
|
1817
1822
|
const activityTracker = createTimebackActivityTracker(client);
|
|
1818
1823
|
async function refreshUserContext() {
|
|
1819
1824
|
const context = await userStore.refresh();
|
|
@@ -1900,10 +1905,22 @@ function createTimebackEngine(client) {
|
|
|
1900
1905
|
resume: activityTracker.resumeActivity,
|
|
1901
1906
|
end: activityTracker.endActivity
|
|
1902
1907
|
},
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1908
|
+
course: {
|
|
1909
|
+
async advance(params) {
|
|
1910
|
+
const response = await client["requestGameBackend"](TIMEBACK_ROUTES.ADVANCE_COURSE, "POST", params?.subject !== undefined ? { subject: params.subject } : {});
|
|
1911
|
+
await applyPromotion(response.promotion);
|
|
1912
|
+
return response;
|
|
1913
|
+
},
|
|
1914
|
+
async unenroll(params) {
|
|
1915
|
+
const response = await client["requestGameBackend"](TIMEBACK_ROUTES.UNENROLL_COURSE, "POST", {
|
|
1916
|
+
...params?.subject !== undefined ? { subject: params.subject } : {},
|
|
1917
|
+
...params?.force !== undefined ? { force: params.force } : {}
|
|
1918
|
+
});
|
|
1919
|
+
if (response.unenrollment.status === "unenrolled") {
|
|
1920
|
+
await refreshAfterCourseMutation();
|
|
1921
|
+
}
|
|
1922
|
+
return response;
|
|
1923
|
+
}
|
|
1907
1924
|
}
|
|
1908
1925
|
};
|
|
1909
1926
|
}
|
|
@@ -1999,12 +2016,24 @@ function createTimebackNamespace(client) {
|
|
|
1999
2016
|
assertPlatformMode(client, "timeback.endActivity()");
|
|
2000
2017
|
return engine.activity.end(data);
|
|
2001
2018
|
},
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2019
|
+
course: {
|
|
2020
|
+
advance: async (options) => {
|
|
2021
|
+
assertPlatformMode(client, "timeback.course.advance()");
|
|
2022
|
+
if (options?.subject !== undefined && !isValidSubject(options.subject)) {
|
|
2023
|
+
throw new Error(`Invalid subject: ${options.subject}. Valid subjects: ${VALID_SUBJECTS.join(", ")}`);
|
|
2024
|
+
}
|
|
2025
|
+
return engine.course.advance(options);
|
|
2026
|
+
},
|
|
2027
|
+
unenroll: async (options) => {
|
|
2028
|
+
assertPlatformMode(client, "timeback.course.unenroll()");
|
|
2029
|
+
if (options?.subject !== undefined && !isValidSubject(options.subject)) {
|
|
2030
|
+
throw new Error(`Invalid subject: ${options.subject}. Valid subjects: ${VALID_SUBJECTS.join(", ")}`);
|
|
2031
|
+
}
|
|
2032
|
+
if (options?.force !== undefined && typeof options.force !== "boolean") {
|
|
2033
|
+
throw new Error("Invalid force: must be a boolean");
|
|
2034
|
+
}
|
|
2035
|
+
return engine.course.unenroll(options);
|
|
2006
2036
|
}
|
|
2007
|
-
return engine.advanceCourse(options);
|
|
2008
2037
|
}
|
|
2009
2038
|
};
|
|
2010
2039
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1385,9 +1385,15 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
|
|
|
1385
1385
|
pauseActivity: () => void;
|
|
1386
1386
|
resumeActivity: () => void;
|
|
1387
1387
|
endActivity: (data: _playcademy_types.EndActivityScoreData) => Promise<_playcademy_types.EndActivityResponse>;
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1388
|
+
course: {
|
|
1389
|
+
advance: (options?: {
|
|
1390
|
+
subject?: _playcademy_types.TimebackSubject;
|
|
1391
|
+
}) => Promise<_playcademy_types.AdvanceCourseResponse>;
|
|
1392
|
+
unenroll: (options?: {
|
|
1393
|
+
subject?: _playcademy_types.TimebackSubject;
|
|
1394
|
+
force?: boolean;
|
|
1395
|
+
}) => Promise<_playcademy_types.UnenrollCourseResponse>;
|
|
1396
|
+
};
|
|
1391
1397
|
};
|
|
1392
1398
|
/**
|
|
1393
1399
|
* Game score submission and leaderboards.
|