@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 {};
|
|
@@ -77,10 +77,11 @@ ${await response.text()}`);
|
|
|
77
77
|
},
|
|
78
78
|
});
|
|
79
79
|
const getXapiStatements = async (params) => {
|
|
80
|
-
|
|
80
|
+
const { ensureSync, ...fetchParams } = params;
|
|
81
|
+
if (ensureSync) {
|
|
81
82
|
const date = new Date();
|
|
82
83
|
return retryWithDelay(async () => {
|
|
83
|
-
const responsePromise = fetchXapiStatements(
|
|
84
|
+
const responsePromise = fetchXapiStatements(fetchParams);
|
|
84
85
|
const response = await responsePromise;
|
|
85
86
|
const consistentThrough = response.headers.get('X-Experience-API-Consistent-Through');
|
|
86
87
|
if (!consistentThrough || new Date(consistentThrough) < date) {
|
|
@@ -90,7 +91,7 @@ ${await response.text()}`);
|
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
93
|
else {
|
|
93
|
-
return formatGetXapiStatementsResponse(fetchXapiStatements(
|
|
94
|
+
return formatGetXapiStatementsResponse(fetchXapiStatements(fetchParams));
|
|
94
95
|
}
|
|
95
96
|
};
|
|
96
97
|
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[];
|
|
@@ -5,6 +5,7 @@ const MAX_RESULTS = 10;
|
|
|
5
5
|
const resolveField = (document, field) => field.key.toString().split('.').reduce((result, key) => result[key], document);
|
|
6
6
|
export const memorySearchTheBadWay = ({ loadAllDocumentsTheBadWay }) => {
|
|
7
7
|
return {
|
|
8
|
+
ensureIndexCreated: async () => undefined,
|
|
8
9
|
index: async (_options) => undefined,
|
|
9
10
|
search: async (options) => {
|
|
10
11
|
const results = (await loadAllDocumentsTheBadWay())
|
|
@@ -49,6 +50,6 @@ export const memorySearchTheBadWay = ({ loadAllDocumentsTheBadWay }) => {
|
|
|
49
50
|
totalItems: results.length,
|
|
50
51
|
totalPages: Math.ceil(results.length / MAX_RESULTS)
|
|
51
52
|
};
|
|
52
|
-
}
|
|
53
|
+
},
|
|
53
54
|
};
|
|
54
55
|
};
|