@openstax/ts-utils 1.2.5 → 1.2.7
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/cjs/services/lrsGateway/index.d.ts +4 -2
- package/dist/cjs/services/lrsGateway/index.js +4 -3
- package/dist/cjs/services/searchProvider/memorySearchTheBadWay.d.ts +1 -0
- package/dist/cjs/services/searchProvider/memorySearchTheBadWay.js +2 -1
- package/dist/cjs/tsconfig.without-specs.cjs.tsbuildinfo +1 -1
- package/dist/esm/services/lrsGateway/index.d.ts +4 -2
- package/dist/esm/services/lrsGateway/index.js +4 -3
- package/dist/esm/services/searchProvider/memorySearchTheBadWay.d.ts +1 -0
- package/dist/esm/services/searchProvider/memorySearchTheBadWay.js +2 -1
- package/dist/esm/tsconfig.without-specs.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -88,9 +88,10 @@ export declare const lrsGateway: <C extends string = "lrs">(initializer: Initial
|
|
|
88
88
|
activity?: string | undefined;
|
|
89
89
|
registration?: string | undefined;
|
|
90
90
|
related_activities?: boolean | undefined;
|
|
91
|
-
ensureSync?: boolean | undefined;
|
|
92
91
|
user?: string | undefined;
|
|
93
92
|
anyUser?: boolean | undefined;
|
|
93
|
+
} & {
|
|
94
|
+
ensureSync?: boolean | undefined;
|
|
94
95
|
}) => Promise<{
|
|
95
96
|
more: string;
|
|
96
97
|
statements: XapiStatement[];
|
|
@@ -104,9 +105,10 @@ export declare const lrsGateway: <C extends string = "lrs">(initializer: Initial
|
|
|
104
105
|
activity?: string | undefined;
|
|
105
106
|
registration?: string | undefined;
|
|
106
107
|
related_activities?: boolean | undefined;
|
|
107
|
-
ensureSync?: boolean | undefined;
|
|
108
108
|
user?: string | undefined;
|
|
109
109
|
anyUser?: boolean | undefined;
|
|
110
|
+
} & {
|
|
111
|
+
ensureSync?: boolean | undefined;
|
|
110
112
|
}) => Promise<XapiStatement[]>;
|
|
111
113
|
};
|
|
112
114
|
export {};
|
|
@@ -106,10 +106,11 @@ ${await response.text()}`);
|
|
|
106
106
|
},
|
|
107
107
|
});
|
|
108
108
|
const getXapiStatements = async (params) => {
|
|
109
|
-
|
|
109
|
+
const { ensureSync, ...fetchParams } = params;
|
|
110
|
+
if (ensureSync) {
|
|
110
111
|
const date = new Date();
|
|
111
112
|
return (0, __1.retryWithDelay)(async () => {
|
|
112
|
-
const responsePromise = fetchXapiStatements(
|
|
113
|
+
const responsePromise = fetchXapiStatements(fetchParams);
|
|
113
114
|
const response = await responsePromise;
|
|
114
115
|
const consistentThrough = response.headers.get('X-Experience-API-Consistent-Through');
|
|
115
116
|
if (!consistentThrough || new Date(consistentThrough) < date) {
|
|
@@ -119,7 +120,7 @@ ${await response.text()}`);
|
|
|
119
120
|
});
|
|
120
121
|
}
|
|
121
122
|
else {
|
|
122
|
-
return formatGetXapiStatementsResponse(fetchXapiStatements(
|
|
123
|
+
return formatGetXapiStatementsResponse(fetchXapiStatements(fetchParams));
|
|
123
124
|
}
|
|
124
125
|
};
|
|
125
126
|
const getAllXapiStatements = async (params) => {
|
|
@@ -2,6 +2,7 @@ import { IndexOptions, SearchOptions } from '.';
|
|
|
2
2
|
export declare const memorySearchTheBadWay: <T>({ loadAllDocumentsTheBadWay }: {
|
|
3
3
|
loadAllDocumentsTheBadWay: () => Promise<T[]>;
|
|
4
4
|
}) => {
|
|
5
|
+
ensureIndexCreated: () => Promise<undefined>;
|
|
5
6
|
index: (_options: IndexOptions<T>) => Promise<undefined>;
|
|
6
7
|
search: (options: SearchOptions) => Promise<{
|
|
7
8
|
items: T[];
|
|
@@ -8,6 +8,7 @@ const MAX_RESULTS = 10;
|
|
|
8
8
|
const resolveField = (document, field) => field.key.toString().split('.').reduce((result, key) => result[key], document);
|
|
9
9
|
const memorySearchTheBadWay = ({ loadAllDocumentsTheBadWay }) => {
|
|
10
10
|
return {
|
|
11
|
+
ensureIndexCreated: async () => undefined,
|
|
11
12
|
index: async (_options) => undefined,
|
|
12
13
|
search: async (options) => {
|
|
13
14
|
const results = (await loadAllDocumentsTheBadWay())
|
|
@@ -52,7 +53,7 @@ const memorySearchTheBadWay = ({ loadAllDocumentsTheBadWay }) => {
|
|
|
52
53
|
totalItems: results.length,
|
|
53
54
|
totalPages: Math.ceil(results.length / MAX_RESULTS)
|
|
54
55
|
};
|
|
55
|
-
}
|
|
56
|
+
},
|
|
56
57
|
};
|
|
57
58
|
};
|
|
58
59
|
exports.memorySearchTheBadWay = memorySearchTheBadWay;
|