@learncard/lca-api-plugin 1.2.23 → 2.0.0
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/lca-api-plugin.cjs.development.cjs +4 -2
- package/dist/lca-api-plugin.cjs.development.cjs.map +2 -2
- package/dist/lca-api-plugin.cjs.production.min.cjs +1 -1
- package/dist/lca-api-plugin.cjs.production.min.cjs.map +2 -2
- package/dist/lca-api-plugin.esm.js +4 -2
- package/dist/lca-api-plugin.esm.js.map +2 -2
- package/dist/test/plugin-mode.test.d.ts +1 -0
- package/dist/types.d.ts +6 -3
- package/package.json +5 -5
- package/src/plugin.ts +2 -0
- package/src/test/plugin-mode.test.ts +40 -0
- package/src/types.ts +6 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -72,8 +72,8 @@ export declare const SigningAuthorityValidator: z.ZodObject<{
|
|
|
72
72
|
_id: z.ZodOptional<z.ZodString>;
|
|
73
73
|
ownerDid: z.ZodString;
|
|
74
74
|
name: z.ZodString;
|
|
75
|
-
did: z.
|
|
76
|
-
endpoint: z.
|
|
75
|
+
did: z.ZodString;
|
|
76
|
+
endpoint: z.ZodString;
|
|
77
77
|
}, z.core.$strip>;
|
|
78
78
|
/** @group LCA API Plugin */
|
|
79
79
|
export type SigningAuthorityType = z.infer<typeof SigningAuthorityValidator>;
|
|
@@ -800,5 +800,8 @@ export type LCAPluginMethods = {
|
|
|
800
800
|
}>;
|
|
801
801
|
};
|
|
802
802
|
/** @group LearnCardNetwork Plugin */
|
|
803
|
-
export type LCAPlugin = Plugin<'LearnCard App', never, LCAPluginMethods, 'id', LCAPluginDependentMethods
|
|
803
|
+
export type LCAPlugin = Plugin<'LearnCard App', never, LCAPluginMethods, 'id', LCAPluginDependentMethods> & {
|
|
804
|
+
/** Whether the plugin fell back because its initial LCA API setup failed. */
|
|
805
|
+
isOffline: boolean;
|
|
806
|
+
};
|
|
804
807
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@learncard/lca-api-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
},
|
|
53
53
|
"types": "./dist/index.d.ts",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@learncard/core": "9.4.
|
|
56
|
-
"@learncard/didkit-plugin": "1.9.
|
|
57
|
-
"@learncard/init": "2.4.
|
|
58
|
-
"@learncard/lca-api-client": "1.2.
|
|
55
|
+
"@learncard/core": "9.4.30",
|
|
56
|
+
"@learncard/didkit-plugin": "1.9.10",
|
|
57
|
+
"@learncard/init": "2.4.11",
|
|
58
|
+
"@learncard/lca-api-client": "1.2.4",
|
|
59
59
|
"@learncard/types": "5.18.1",
|
|
60
60
|
"hex-lite": "^1.5.0",
|
|
61
61
|
"isomorphic-fetch": "^3.0.0",
|
package/src/plugin.ts
CHANGED
|
@@ -114,6 +114,7 @@ export const getLCAPlugin = async (
|
|
|
114
114
|
|
|
115
115
|
return {
|
|
116
116
|
name: 'LearnCard App',
|
|
117
|
+
isOffline: false,
|
|
117
118
|
displayName: 'LearnCard App Plugin',
|
|
118
119
|
description: 'Adds bespoke logic to the LearnCard App.',
|
|
119
120
|
methods: {
|
|
@@ -548,6 +549,7 @@ export const getLCAPlugin = async (
|
|
|
548
549
|
);
|
|
549
550
|
return {
|
|
550
551
|
name: 'LearnCard App',
|
|
552
|
+
isOffline: true,
|
|
551
553
|
displayName: 'LearnCard App Plugin (Offline)',
|
|
552
554
|
description: 'Adds bespoke logic to the LearnCard App. (Unable to connect to LCA API)',
|
|
553
555
|
methods: {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { getClient } from '@learncard/lca-api-client';
|
|
2
|
+
|
|
3
|
+
import { getLCAPlugin } from '../plugin';
|
|
4
|
+
|
|
5
|
+
jest.mock('@learncard/lca-api-client', () => ({ getClient: jest.fn() }), { virtual: true });
|
|
6
|
+
|
|
7
|
+
const mockedGetClient = jest.mocked(getClient);
|
|
8
|
+
|
|
9
|
+
const learnCard = {
|
|
10
|
+
id: { did: () => 'did:key:z6MkTest' },
|
|
11
|
+
invoke: { getProfile: () => new Promise<never>(() => undefined) },
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
describe('getLCAPlugin', () => {
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
mockedGetClient.mockReset();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('reports when initial setup falls back to offline mode', async () => {
|
|
20
|
+
const consoleError = jest.spyOn(console, 'error').mockImplementation(() => undefined);
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
mockedGetClient.mockRejectedValueOnce(new Error('connection failed'));
|
|
24
|
+
|
|
25
|
+
const plugin = await getLCAPlugin(learnCard as never, 'https://example.com/trpc');
|
|
26
|
+
|
|
27
|
+
expect(plugin.isOffline).toBe(true);
|
|
28
|
+
} finally {
|
|
29
|
+
consoleError.mockRestore();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('reports when initial setup remains online', async () => {
|
|
34
|
+
mockedGetClient.mockResolvedValueOnce({} as never);
|
|
35
|
+
|
|
36
|
+
const plugin = await getLCAPlugin(learnCard as never, 'https://example.com/trpc');
|
|
37
|
+
|
|
38
|
+
expect(plugin.isOffline).toBe(false);
|
|
39
|
+
});
|
|
40
|
+
});
|
package/src/types.ts
CHANGED
|
@@ -92,8 +92,8 @@ export const SigningAuthorityValidator = z.object({
|
|
|
92
92
|
_id: z.string().optional(),
|
|
93
93
|
ownerDid: z.string(),
|
|
94
94
|
name: z.string(),
|
|
95
|
-
did: z.string()
|
|
96
|
-
endpoint: z.string()
|
|
95
|
+
did: z.string(),
|
|
96
|
+
endpoint: z.string(),
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
/** @group LCA API Plugin */
|
|
@@ -396,4 +396,7 @@ export type LCAPlugin = Plugin<
|
|
|
396
396
|
LCAPluginMethods,
|
|
397
397
|
'id',
|
|
398
398
|
LCAPluginDependentMethods
|
|
399
|
-
|
|
399
|
+
> & {
|
|
400
|
+
/** Whether the plugin fell back because its initial LCA API setup failed. */
|
|
401
|
+
isOffline: boolean;
|
|
402
|
+
};
|