@lowdefy/client 4.0.0-rc.7 → 4.0.0-rc.9
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/Client.js
CHANGED
|
@@ -20,15 +20,16 @@ import DisplayMessage from './DisplayMessage.js';
|
|
|
20
20
|
import Head from './Head.js';
|
|
21
21
|
import ProgressBarController from './ProgressBarController.js';
|
|
22
22
|
import initLowdefyContext from './initLowdefyContext.js';
|
|
23
|
-
const Client = ({ auth , Components , config: rawConfig , resetContext ={
|
|
23
|
+
const Client = ({ auth , Components , config: rawConfig , lowdefy , resetContext ={
|
|
24
24
|
reset: false,
|
|
25
25
|
setReset: ()=>undefined
|
|
26
26
|
} , router , stage , types , window })=>{
|
|
27
27
|
const config = serializer.deserialize(rawConfig);
|
|
28
|
-
|
|
28
|
+
initLowdefyContext({
|
|
29
29
|
auth,
|
|
30
30
|
Components,
|
|
31
31
|
config,
|
|
32
|
+
lowdefy,
|
|
32
33
|
router,
|
|
33
34
|
stage,
|
|
34
35
|
types,
|
|
@@ -34,14 +34,14 @@ function getCallbackUrl({ lowdefy , callbackUrl ={} }) {
|
|
|
34
34
|
}
|
|
35
35
|
return undefined;
|
|
36
36
|
}
|
|
37
|
-
function createAuthMethods(
|
|
37
|
+
function createAuthMethods(lowdefy, auth) {
|
|
38
38
|
// login and logout are Lowdefy function that handle action params
|
|
39
39
|
// signIn and signOut are the next-auth methods
|
|
40
40
|
function login({ authUrl , callbackUrl , providerId , ...rest } = {}) {
|
|
41
41
|
if (type.isNone(providerId) && auth.authConfig.providers.length === 1) {
|
|
42
42
|
providerId = auth.authConfig.providers[0].id;
|
|
43
43
|
}
|
|
44
|
-
auth.signIn(providerId, {
|
|
44
|
+
return auth.signIn(providerId, {
|
|
45
45
|
...rest,
|
|
46
46
|
callbackUrl: getCallbackUrl({
|
|
47
47
|
lowdefy,
|
|
@@ -50,7 +50,7 @@ function createAuthMethods({ lowdefy , auth }) {
|
|
|
50
50
|
}, authUrl?.urlQuery);
|
|
51
51
|
}
|
|
52
52
|
function logout({ callbackUrl , redirect } = {}) {
|
|
53
|
-
auth.signOut({
|
|
53
|
+
return auth.signOut({
|
|
54
54
|
callbackUrl: getCallbackUrl({
|
|
55
55
|
lowdefy,
|
|
56
56
|
callbackUrl
|
|
@@ -58,9 +58,14 @@ function createAuthMethods({ lowdefy , auth }) {
|
|
|
58
58
|
redirect
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
+
async function updateSession() {
|
|
62
|
+
const session = await auth.getSession();
|
|
63
|
+
lowdefy.user = session?.user ?? null;
|
|
64
|
+
}
|
|
61
65
|
return {
|
|
62
66
|
login,
|
|
63
|
-
logout
|
|
67
|
+
logout,
|
|
68
|
+
updateSession
|
|
64
69
|
};
|
|
65
70
|
}
|
|
66
71
|
export default createAuthMethods;
|
|
@@ -13,13 +13,16 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import request from './request.js';
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
function createCallRequest({ basePath }) {
|
|
17
|
+
function callRequest({ pageId , payload , requestId }) {
|
|
18
|
+
return request({
|
|
19
|
+
url: `${basePath}/api/request/${pageId}/${requestId}`,
|
|
20
|
+
method: 'POST',
|
|
21
|
+
body: {
|
|
22
|
+
payload
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return callRequest;
|
|
24
27
|
}
|
|
25
|
-
export default
|
|
28
|
+
export default createCallRequest;
|
|
@@ -34,7 +34,7 @@ const createLinkComponent = (lowdefy, Link)=>{
|
|
|
34
34
|
id: id,
|
|
35
35
|
"aria-label": ariaLabel,
|
|
36
36
|
className: className,
|
|
37
|
-
href: `${window.location.origin}${lowdefy.
|
|
37
|
+
href: `${window.location.origin}${lowdefy.basePath}${pathname}${query ? `?${query}` : ''}`,
|
|
38
38
|
rel: rel || 'noopener noreferrer',
|
|
39
39
|
target: "_blank",
|
|
40
40
|
onClick: async (...params)=>{
|
|
@@ -12,60 +12,57 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ import
|
|
15
|
+
*/ import createAuthMethods from './auth/createAuthMethods.js';
|
|
16
|
+
import createCallRequest from './createCallRequest.js';
|
|
16
17
|
import createIcon from './createIcon.js';
|
|
17
|
-
import createAuthMethods from './auth/createAuthMethods.js';
|
|
18
18
|
import createLinkComponent from './createLinkComponent.js';
|
|
19
19
|
import setupLink from './setupLink.js';
|
|
20
|
-
|
|
21
|
-
_internal
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return ()=>undefined;
|
|
28
|
-
},
|
|
29
|
-
link: ()=>undefined,
|
|
30
|
-
progress: {
|
|
31
|
-
state: {
|
|
32
|
-
progress: 0
|
|
20
|
+
function initLowdefyContext({ auth , Components , config , lowdefy , router , stage , types , window }) {
|
|
21
|
+
if (!lowdefy._internal?.initialised) {
|
|
22
|
+
lowdefy._internal = {
|
|
23
|
+
actions: types.actions,
|
|
24
|
+
blockComponents: types.blocks,
|
|
25
|
+
components: {
|
|
26
|
+
Icon: createIcon(types.icons)
|
|
33
27
|
},
|
|
34
|
-
|
|
28
|
+
displayMessage: ({ content })=>{
|
|
29
|
+
console.log(content);
|
|
30
|
+
return ()=>undefined;
|
|
31
|
+
},
|
|
32
|
+
globals: {
|
|
33
|
+
document: window.document,
|
|
34
|
+
fetch: window.fetch,
|
|
35
|
+
window
|
|
36
|
+
},
|
|
37
|
+
initialised: true,
|
|
38
|
+
link: ()=>undefined,
|
|
39
|
+
operators: types.operators,
|
|
40
|
+
progress: {
|
|
41
|
+
state: {
|
|
42
|
+
progress: 0
|
|
43
|
+
},
|
|
44
|
+
dispatch: ()=>undefined
|
|
45
|
+
},
|
|
46
|
+
router,
|
|
47
|
+
updaters: {}
|
|
48
|
+
};
|
|
49
|
+
lowdefy.basePath = router.basePath;
|
|
50
|
+
lowdefy.contexts = {};
|
|
51
|
+
lowdefy.inputs = {};
|
|
52
|
+
lowdefy.lowdefyGlobal = config.rootConfig.lowdefyGlobal;
|
|
53
|
+
lowdefy._internal.auth = createAuthMethods(lowdefy, auth);
|
|
54
|
+
lowdefy._internal.callRequest = createCallRequest(lowdefy);
|
|
55
|
+
lowdefy._internal.components.Link = createLinkComponent(lowdefy, Components.Link);
|
|
56
|
+
lowdefy._internal.link = setupLink(lowdefy);
|
|
57
|
+
lowdefy._internal.updateBlock = (blockId)=>lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]();
|
|
58
|
+
if (stage === 'dev') {
|
|
59
|
+
window.lowdefy = lowdefy;
|
|
35
60
|
}
|
|
36
|
-
},
|
|
37
|
-
contexts: {},
|
|
38
|
-
inputs: {},
|
|
39
|
-
lowdefyGlobal: {}
|
|
40
|
-
};
|
|
41
|
-
function initLowdefyContext({ auth , Components , config , router , stage , types , window }) {
|
|
42
|
-
if (stage === 'dev') {
|
|
43
|
-
window.lowdefy = lowdefy;
|
|
44
61
|
}
|
|
45
|
-
lowdefy.basePath = router.basePath;
|
|
46
62
|
lowdefy.home = config.rootConfig.home || {};
|
|
47
|
-
lowdefy.lowdefyGlobal = config.rootConfig.lowdefyGlobal;
|
|
48
63
|
lowdefy.menus = config.rootConfig.menus;
|
|
49
64
|
lowdefy.pageId = config.pageConfig.pageId;
|
|
50
65
|
lowdefy.user = auth?.session?.user ?? null;
|
|
51
|
-
lowdefy._internal.globals = {
|
|
52
|
-
document: window.document,
|
|
53
|
-
fetch: window.fetch,
|
|
54
|
-
window
|
|
55
|
-
};
|
|
56
|
-
lowdefy._internal.router = router;
|
|
57
|
-
lowdefy._internal.link = setupLink(lowdefy);
|
|
58
|
-
lowdefy._internal.updateBlock = (blockId)=>lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]();
|
|
59
|
-
lowdefy._internal.components.Link = createLinkComponent(lowdefy, Components.Link);
|
|
60
|
-
lowdefy._internal.components.Icon = createIcon(types.icons);
|
|
61
|
-
lowdefy._internal.actions = types.actions;
|
|
62
|
-
lowdefy._internal.blockComponents = types.blocks;
|
|
63
|
-
lowdefy._internal.operators = types.operators;
|
|
64
|
-
// TODO: discuss not using object arguments
|
|
65
|
-
lowdefy._internal.auth = createAuthMethods({
|
|
66
|
-
lowdefy,
|
|
67
|
-
auth
|
|
68
|
-
});
|
|
69
66
|
return lowdefy;
|
|
70
67
|
}
|
|
71
68
|
export default initLowdefyContext;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/client",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.9",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy Client",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@ant-design/icons": "4.8.0",
|
|
44
|
-
"@lowdefy/block-utils": "4.0.0-rc.
|
|
45
|
-
"@lowdefy/engine": "4.0.0-rc.
|
|
46
|
-
"@lowdefy/helpers": "4.0.0-rc.
|
|
47
|
-
"@lowdefy/layout": "4.0.0-rc.
|
|
44
|
+
"@lowdefy/block-utils": "4.0.0-rc.9",
|
|
45
|
+
"@lowdefy/engine": "4.0.0-rc.9",
|
|
46
|
+
"@lowdefy/helpers": "4.0.0-rc.9",
|
|
47
|
+
"@lowdefy/layout": "4.0.0-rc.9",
|
|
48
48
|
"classnames": "2.3.2",
|
|
49
49
|
"react": "18.2.0",
|
|
50
50
|
"react-dom": "18.2.0"
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@emotion/jest": "11.10.5",
|
|
54
54
|
"@jest/globals": "28.1.0",
|
|
55
|
-
"@lowdefy/jest-yaml-transform": "4.0.0-rc.
|
|
55
|
+
"@lowdefy/jest-yaml-transform": "4.0.0-rc.9",
|
|
56
56
|
"@swc/cli": "0.1.59",
|
|
57
57
|
"@swc/core": "1.3.24",
|
|
58
58
|
"@swc/jest": "0.2.24",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "d20e6ac424643feca527a732dc2b0710713c8243"
|
|
71
71
|
}
|