@lark-apaas/dataloom 0.1.2-alpha.2 → 0.1.2-alpha.4
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/lib/service/index.d.ts.map +1 -1
- package/lib/service/index.js +27 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,WAAW,sBAAsB;IACrC,eAAe,CAAC,EAAE,wBAAwB,CAAC;CAC5C;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,WAAW,sBAAsB;IACrC,eAAe,CAAC,EAAE,wBAAwB,CAAC;CAC5C;AAwCD;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,uCAAuC;IACvC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,uCAAuC;IACvC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;gBAEd,OAAO,EAAE,sBAAsB;CAU5C;AAED,YAAY,EAAE,wBAAwB,EAAE,CAAC"}
|
package/lib/service/index.js
CHANGED
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
const MIGRATION_HINT = "[dataloom] service.user / service.session has moved to @lark-apaas/auth-sdk in v0.2.0.\nUse `authClient` from @lark-apaas/client-toolkit/auth (or @lark-apaas/auth-sdk), e.g.:\n import { authClient } from '@lark-apaas/client-toolkit/auth';\n await authClient.user.search({ name: '张三' });\nIf you really need to keep using dataloom.service.*, ensure client-toolkit injects accountServices when constructing DataloomClient.";
|
|
2
|
+
const ALLOWED_REFLECTION_KEYS = new Set([
|
|
3
|
+
'constructor',
|
|
4
|
+
'then',
|
|
5
|
+
'toJSON',
|
|
6
|
+
'toString',
|
|
7
|
+
'asymmetricMatch',
|
|
8
|
+
'nodeType',
|
|
9
|
+
'tagName',
|
|
10
|
+
'Symbol(Symbol.toPrimitive)',
|
|
11
|
+
'$$typeof'
|
|
12
|
+
]);
|
|
13
|
+
const createUninjectedStub = (key)=>new Proxy({}, {
|
|
14
|
+
get (_target, prop) {
|
|
15
|
+
if ('symbol' == typeof prop) return;
|
|
16
|
+
if (ALLOWED_REFLECTION_KEYS.has(prop)) return;
|
|
17
|
+
return (..._args)=>{
|
|
18
|
+
throw new Error(`[dataloom] service.${key}.${String(prop)} ${MIGRATION_HINT}`);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
});
|
|
2
22
|
class DataloomService {
|
|
3
23
|
constructor(options){
|
|
4
24
|
const injected = options.accountServices;
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
|
|
25
|
+
if (injected) {
|
|
26
|
+
this.user = injected.user;
|
|
27
|
+
this.session = injected.session;
|
|
28
|
+
} else {
|
|
29
|
+
this.user = createUninjectedStub('user');
|
|
30
|
+
this.session = createUninjectedStub('session');
|
|
31
|
+
}
|
|
8
32
|
}
|
|
9
33
|
}
|
|
10
34
|
export { DataloomService as default };
|