@lowdefy/api 4.0.0-rc.9 → 4.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.
Files changed (45) hide show
  1. package/dist/context/createApiContext.js +5 -18
  2. package/dist/context/createAuthorize.js +4 -4
  3. package/dist/context/createReadConfigFile.js +2 -2
  4. package/dist/context/errors.js +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/routes/auth/callbacks/addUserFieldsToSession.js +5 -4
  7. package/dist/routes/auth/callbacks/addUserFieldsToToken.js +7 -13
  8. package/dist/routes/auth/callbacks/createCallbackPlugins.js +2 -2
  9. package/dist/routes/auth/callbacks/createCallbacks.js +9 -6
  10. package/dist/routes/auth/callbacks/createJWTCallback.js +7 -5
  11. package/dist/routes/auth/callbacks/createRedirectCallback.js +9 -4
  12. package/dist/routes/auth/callbacks/createSessionCallback.js +12 -6
  13. package/dist/routes/auth/callbacks/createSignInCallback.js +3 -3
  14. package/dist/routes/auth/createAdapter.js +2 -2
  15. package/dist/routes/auth/createLogger.js +34 -0
  16. package/dist/routes/auth/createProviders.js +2 -2
  17. package/dist/routes/auth/events/createCreateUserEvent.js +12 -4
  18. package/dist/routes/auth/events/createEventPlugins.js +2 -2
  19. package/dist/routes/auth/events/createEvents.js +30 -29
  20. package/dist/routes/auth/events/createLinkAccountEvent.js +12 -4
  21. package/dist/routes/auth/events/createSessionEvent.js +3 -3
  22. package/dist/routes/auth/events/createSignInEvent.js +14 -4
  23. package/dist/routes/auth/events/createSignOutEvent.js +16 -7
  24. package/dist/routes/auth/events/createUpdateUserEvent.js +12 -4
  25. package/dist/routes/auth/getNextAuthConfig.js +18 -11
  26. package/dist/routes/page/getPageConfig.js +3 -3
  27. package/dist/routes/request/authorizeRequest.js +11 -7
  28. package/dist/routes/request/callRequest.js +10 -12
  29. package/dist/routes/request/callRequestResolver.js +3 -2
  30. package/dist/routes/request/checkConnectionRead.js +2 -2
  31. package/dist/routes/request/checkConnectionWrite.js +2 -2
  32. package/dist/routes/request/evaluateOperators.js +5 -5
  33. package/dist/routes/request/getConnection.js +2 -2
  34. package/dist/routes/request/getConnectionConfig.js +3 -3
  35. package/dist/routes/request/getRequestConfig.js +2 -2
  36. package/dist/routes/request/getRequestResolver.js +2 -2
  37. package/dist/routes/request/validateSchemas.js +2 -2
  38. package/dist/routes/rootConfig/getHomeAndMenus.js +1 -1
  39. package/dist/routes/rootConfig/getLowdefyGlobal.js +2 -2
  40. package/dist/routes/rootConfig/getRootConfig.js +2 -2
  41. package/dist/routes/rootConfig/menus/filterMenuList.js +3 -3
  42. package/dist/routes/rootConfig/menus/filterMenus.js +2 -2
  43. package/dist/routes/rootConfig/menus/getMenus.js +1 -1
  44. package/dist/test/testContext.js +5 -8
  45. package/package.json +18 -20
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,15 +13,24 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import createEventPlugins from './createEventPlugins.js';
16
- function createSignOutEvent(context, { authConfig , plugins }) {
17
- const signInPlugins = createEventPlugins({
16
+ function createSignOutEvent({ authConfig, logger, plugins }) {
17
+ const signOutPlugins = createEventPlugins({
18
18
  authConfig,
19
19
  plugins,
20
20
  type: 'signOut'
21
21
  });
22
- if (signInPlugins.length === 0) return undefined;
23
- async function signInEvent({ session , token }) {
24
- for (const plugin of signInPlugins){
22
+ async function signOutEvent({ session, token }) {
23
+ const user = session?.user ?? token;
24
+ logger.info({
25
+ event: 'auth_sign_out',
26
+ user: {
27
+ id: user.id,
28
+ roles: user.roles,
29
+ sub: user.sub,
30
+ session_id: user.session_id
31
+ }
32
+ });
33
+ for (const plugin of signOutPlugins){
25
34
  await plugin.fn({
26
35
  properties: plugin.properties ?? {},
27
36
  session,
@@ -29,6 +38,6 @@ function createSignOutEvent(context, { authConfig , plugins }) {
29
38
  });
30
39
  }
31
40
  }
32
- return signInEvent;
41
+ return signOutEvent;
33
42
  }
34
43
  export default createSignOutEvent;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,14 +13,22 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import createEventPlugins from './createEventPlugins.js';
16
- function createUpdateUserEvent(context, { authConfig , plugins }) {
16
+ function createUpdateUserEvent({ authConfig, logger, plugins }) {
17
17
  const updateUserPlugins = createEventPlugins({
18
18
  authConfig,
19
19
  plugins,
20
20
  type: 'updateUser'
21
21
  });
22
- if (updateUserPlugins.length === 0) return undefined;
23
- async function updateUserEvent({ user }) {
22
+ async function updateUserEvent({ user }) {
23
+ logger.info({
24
+ event: 'auth_update_user',
25
+ user: {
26
+ id: user.id,
27
+ roles: user.roles,
28
+ sub: user.sub,
29
+ session_id: user.session_id
30
+ }
31
+ });
24
32
  for (const plugin of updateUserPlugins){
25
33
  await plugin.fn({
26
34
  properties: plugin.properties ?? {},
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,18 +13,16 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { ServerParser } from '@lowdefy/operators';
16
- import { getSecretsFromEnv } from '@lowdefy/node-utils';
17
16
  import { _secret } from '@lowdefy/operators-js/operators/server';
18
17
  import createAdapter from './createAdapter.js';
19
18
  import createCallbacks from './callbacks/createCallbacks.js';
20
19
  import createEvents from './events/createEvents.js';
20
+ import createLogger from './createLogger.js';
21
21
  import createProviders from './createProviders.js';
22
22
  const nextAuthConfig = {};
23
23
  let initialized = false;
24
- function getNextAuthConfig(context, { authJson , plugins }) {
24
+ function getNextAuthConfig({ authJson, logger, plugins, secrets }) {
25
25
  if (initialized) return nextAuthConfig;
26
- const secrets = getSecretsFromEnv();
27
- // TODO: Add logger
28
26
  const operatorsParser = new ServerParser({
29
27
  operators: {
30
28
  _secret
@@ -33,33 +31,42 @@ function getNextAuthConfig(context, { authJson , plugins }) {
33
31
  secrets,
34
32
  user: {}
35
33
  });
36
- const { output: authConfig , errors: operatorErrors } = operatorsParser.parse({
34
+ const { output: authConfig, errors: operatorErrors } = operatorsParser.parse({
37
35
  input: authJson,
38
36
  location: 'auth'
39
37
  });
40
38
  if (operatorErrors.length > 0) {
41
39
  throw new Error(operatorErrors[0]);
42
40
  }
43
- nextAuthConfig.adapter = createAdapter(context, {
41
+ nextAuthConfig.adapter = createAdapter({
44
42
  authConfig,
43
+ logger,
45
44
  plugins
46
45
  });
47
- nextAuthConfig.callbacks = createCallbacks(context, {
46
+ nextAuthConfig.callbacks = createCallbacks({
48
47
  authConfig,
48
+ logger,
49
49
  plugins
50
50
  });
51
- nextAuthConfig.events = createEvents(context, {
51
+ nextAuthConfig.events = createEvents({
52
52
  authConfig,
53
+ logger,
53
54
  plugins
54
55
  });
55
- nextAuthConfig.providers = createProviders(context, {
56
+ nextAuthConfig.logger = createLogger({
57
+ logger
58
+ });
59
+ nextAuthConfig.providers = createProviders({
56
60
  authConfig,
61
+ logger,
57
62
  plugins
58
63
  });
64
+ nextAuthConfig.debug = authConfig.debug ?? logger?.isLevelEnabled('debug') === true;
65
+ nextAuthConfig.pages = authConfig.authPages;
59
66
  nextAuthConfig.session = authConfig.session;
60
67
  nextAuthConfig.theme = authConfig.theme;
61
- nextAuthConfig.pages = authConfig.authPages;
62
68
  nextAuthConfig.cookies = authConfig?.advanced?.cookies;
69
+ nextAuthConfig.originalRedirectCallback = nextAuthConfig.callbacks.redirect;
63
70
  initialized = true;
64
71
  return nextAuthConfig;
65
72
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -12,11 +12,11 @@
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
- */ async function getPageConfig({ authorize , readConfigFile }, { pageId }) {
15
+ */ async function getPageConfig({ authorize, readConfigFile }, { pageId }) {
16
16
  const pageConfig = await readConfigFile(`pages/${pageId}/${pageId}.json`);
17
17
  if (pageConfig && authorize(pageConfig)) {
18
18
  // eslint-disable-next-line no-unused-vars
19
- const { auth , ...rest } = pageConfig;
19
+ const { auth, ...rest } = pageConfig;
20
20
  return {
21
21
  ...rest
22
22
  };
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,16 +13,20 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { ConfigurationError } from '../../context/errors.js';
16
- function authorizeRequest({ authorize , logger }, { requestConfig }) {
16
+ function authorizeRequest({ authorize, logger }, { requestConfig }) {
17
17
  if (!authorize(requestConfig)) {
18
- logger.warn({
19
- authorized: false
20
- }, 'Unauthorized Request');
18
+ logger.debug({
19
+ event: 'debug_request_authorize',
20
+ authorized: false,
21
+ auth_config: requestConfig.auth
22
+ });
21
23
  // Throw does not exist error to avoid leaking information that request exists to unauthorized users
22
24
  throw new ConfigurationError(`Request "${requestConfig.requestId}" does not exist.`);
23
25
  }
24
26
  logger.debug({
25
- authorized: true
26
- }, 'Authorize Request');
27
+ event: 'debug_request_authorize',
28
+ authorized: true,
29
+ auth_config: requestConfig.auth
30
+ });
27
31
  }
28
32
  export default authorizeRequest;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -23,17 +23,15 @@ import getConnectionConfig from './getConnectionConfig.js';
23
23
  import getRequestConfig from './getRequestConfig.js';
24
24
  import getRequestResolver from './getRequestResolver.js';
25
25
  import validateSchemas from './validateSchemas.js';
26
- async function callRequest(context, { blockId , pageId , payload , requestId }) {
27
- const { logger } = context;
26
+ async function callRequest(context, { blockId, pageId, payload, requestId }) {
27
+ const { logger } = context;
28
28
  logger.debug({
29
- route: 'request',
30
- params: {
31
- blockId,
32
- pageId,
33
- payload,
34
- requestId
35
- }
36
- }, 'Started request');
29
+ event: 'debug_request',
30
+ blockId,
31
+ pageId,
32
+ payload,
33
+ requestId
34
+ });
37
35
  const requestConfig = await getRequestConfig(context, {
38
36
  pageId,
39
37
  requestId
@@ -52,7 +50,7 @@ async function callRequest(context, { blockId , pageId , payload , requestId })
52
50
  requestConfig
53
51
  });
54
52
  const deserializedPayload = serializer.deserialize(payload);
55
- const { connectionProperties , requestProperties } = evaluateOperators(context, {
53
+ const { connectionProperties, requestProperties } = evaluateOperators(context, {
56
54
  connectionConfig,
57
55
  payload: deserializedPayload,
58
56
  requestConfig
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,11 +13,12 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { RequestError } from '../../context/errors.js';
16
- async function callRequestResolver({ logger }, { blockId , connectionProperties , payload , requestConfig , requestProperties , requestResolver }) {
16
+ async function callRequestResolver({ logger }, { blockId, connectionProperties, payload, requestConfig, requestProperties, requestResolver }) {
17
17
  try {
18
18
  const response = await requestResolver({
19
19
  blockId,
20
20
  connection: connectionProperties,
21
+ connectionId: requestConfig.connectionId,
21
22
  pageId: requestConfig.pageId,
22
23
  payload,
23
24
  request: requestProperties,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { ConfigurationError } from '../../context/errors.js';
16
- function checkConnectionRead({ logger }, { connectionConfig , connectionProperties , requestConfig , requestResolver }) {
16
+ function checkConnectionRead({ logger }, { connectionConfig, connectionProperties, requestConfig, requestResolver }) {
17
17
  if (requestResolver.meta.checkRead && connectionProperties.read === false) {
18
18
  const err = new ConfigurationError(`Connection "${connectionConfig.connectionId}" does not allow reads.`);
19
19
  logger.debug({
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { ConfigurationError } from '../../context/errors.js';
16
- function checkConnectionWrite({ logger }, { connectionConfig , connectionProperties , requestConfig , requestResolver }) {
16
+ function checkConnectionWrite({ logger }, { connectionConfig, connectionProperties, requestConfig, requestResolver }) {
17
17
  if (requestResolver.meta.checkWrite && connectionProperties.write !== true) {
18
18
  const err = new ConfigurationError(`Connection "${connectionConfig.connectionId}" does not allow writes.`);
19
19
  logger.debug({
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,21 +14,21 @@
14
14
  limitations under the License.
15
15
  */ import { ServerParser } from '@lowdefy/operators';
16
16
  import { RequestError } from '../../context/errors.js';
17
- function evaluateOperators({ operators , secrets , user }, { connectionConfig , payload , requestConfig }) {
17
+ function evaluateOperators({ operators, secrets, session }, { connectionConfig, payload, requestConfig }) {
18
18
  const operatorsParser = new ServerParser({
19
19
  operators,
20
20
  payload,
21
21
  secrets,
22
- user
22
+ user: session?.user
23
23
  });
24
- const { output: connectionProperties , errors: connectionErrors } = operatorsParser.parse({
24
+ const { output: connectionProperties, errors: connectionErrors } = operatorsParser.parse({
25
25
  input: connectionConfig.properties || {},
26
26
  location: connectionConfig.connectionId
27
27
  });
28
28
  if (connectionErrors.length > 0) {
29
29
  throw new RequestError(connectionErrors[0]);
30
30
  }
31
- const { output: requestProperties , errors: requestErrors } = operatorsParser.parse({
31
+ const { output: requestProperties, errors: requestErrors } = operatorsParser.parse({
32
32
  input: requestConfig.properties || {},
33
33
  location: requestConfig.requestId
34
34
  });
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { ConfigurationError } from '../../context/errors.js';
16
- function getConnection({ connections , logger }, { connectionConfig }) {
16
+ function getConnection({ connections, logger }, { connectionConfig }) {
17
17
  const connection = connections[connectionConfig.type];
18
18
  if (!connection) {
19
19
  const err = new ConfigurationError(`Connection type "${connectionConfig.type}" can not be found.`);
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,8 +13,8 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { ConfigurationError } from '../../context/errors.js';
16
- async function getConnectionConfig({ logger , readConfigFile }, { requestConfig }) {
17
- const { connectionId , requestId } = requestConfig;
16
+ async function getConnectionConfig({ logger, readConfigFile }, { requestConfig }) {
17
+ const { connectionId, requestId } = requestConfig;
18
18
  let err;
19
19
  if (!connectionId) {
20
20
  err = new ConfigurationError(`Request "${requestId}" does not specify a connection.`);
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { ConfigurationError } from '../../context/errors.js';
16
- async function getRequestConfig({ logger , readConfigFile }, { pageId , requestId }) {
16
+ async function getRequestConfig({ logger, readConfigFile }, { pageId, requestId }) {
17
17
  const request = await readConfigFile(`pages/${pageId}/requests/${requestId}.json`);
18
18
  if (!request) {
19
19
  const err = new ConfigurationError(`Request "${requestId}" does not exist.`);
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { ConfigurationError } from '../../context/errors.js';
16
- function getRequestResolver({ logger }, { connection , requestConfig }) {
16
+ function getRequestResolver({ logger }, { connection, requestConfig }) {
17
17
  const requestResolver = connection.requests[requestConfig.type];
18
18
  if (!requestResolver) {
19
19
  const err = new ConfigurationError(`Request type "${requestConfig.type}" can not be found.`);
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
14
14
  limitations under the License.
15
15
  */ import { validate } from '@lowdefy/ajv';
16
16
  import { ConfigurationError } from '../../context/errors.js';
17
- function validateSchemas({ logger }, { connection , connectionProperties , requestConfig , requestResolver , requestProperties }) {
17
+ function validateSchemas({ logger }, { connection, connectionProperties, requestConfig, requestResolver, requestProperties }) {
18
18
  try {
19
19
  validate({
20
20
  schema: connection.schema,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
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
- */ async function getLowdefyGlobal({ readConfigFile }) {
15
+ */ async function getLowdefyGlobal({ readConfigFile }) {
16
16
  const lowdefyGlobal = await readConfigFile('global.json');
17
17
  return lowdefyGlobal || {};
18
18
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
15
15
  */ import getHomeAndMenus from './getHomeAndMenus.js';
16
16
  import getLowdefyGlobal from './getLowdefyGlobal.js';
17
17
  async function getRootConfig(context) {
18
- const [lowdefyGlobal, { home , menus }] = await Promise.all([
18
+ const [lowdefyGlobal, { home, menus }] = await Promise.all([
19
19
  getLowdefyGlobal(context),
20
20
  getHomeAndMenus(context)
21
21
  ]);
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,8 +13,8 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { get } from '@lowdefy/helpers';
16
- function filterMenuList(context, { menuList }) {
17
- const { authorize } = context;
16
+ function filterMenuList(context, { menuList }) {
17
+ const { authorize } = context;
18
18
  return menuList.map((item)=>{
19
19
  if (item.type === 'MenuLink') {
20
20
  if (authorize(item)) {
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
14
14
  limitations under the License.
15
15
  */ import { get } from '@lowdefy/helpers';
16
16
  import filterMenuList from './filterMenuList.js';
17
- function filterMenus(context, { menus }) {
17
+ function filterMenus(context, { menus }) {
18
18
  return menus.map((menu)=>{
19
19
  return {
20
20
  ...menu,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,14 +13,14 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import createAuthorize from '../context/createAuthorize.js';
16
- function testContext({ config ={} , connections ={} , headers ={} , host ='host' , logger ={
16
+ function testContext({ config = {}, connections = {}, headers = {}, logger = {
17
17
  debug: ()=>{},
18
18
  error: ()=>{},
19
19
  info: ()=>{},
20
20
  warn: ()=>{}
21
- } , operators ={
21
+ }, operators = {
22
22
  _test: ()=>'test'
23
- } , readConfigFile , secrets ={} , setHeader , session , protocol ='https' } = {}) {
23
+ }, readConfigFile, secrets = {}, session } = {}) {
24
24
  return {
25
25
  authorize: createAuthorize({
26
26
  session
@@ -28,14 +28,11 @@ function testContext({ config ={} , connections ={} , headers ={} , host ='host'
28
28
  config,
29
29
  connections,
30
30
  headers,
31
- host,
32
31
  logger,
33
32
  operators,
34
- protocol,
35
33
  readConfigFile,
36
34
  secrets,
37
- setHeader,
38
- user: session?.user
35
+ session
39
36
  };
40
37
  }
41
38
  export default testContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/api",
3
- "version": "4.0.0-rc.9",
3
+ "version": "4.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -33,29 +33,27 @@
33
33
  "files": [
34
34
  "dist/*"
35
35
  ],
36
- "scripts": {
37
- "build": "swc src --out-dir dist --config-file ../../.swcrc --delete-dir-on-start",
38
- "clean": "rm -rf dist",
39
- "prepublishOnly": "pnpm build",
40
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
41
- },
42
36
  "dependencies": {
43
- "@lowdefy/ajv": "4.0.0-rc.9",
44
- "@lowdefy/helpers": "4.0.0-rc.9",
45
- "@lowdefy/node-utils": "4.0.0-rc.9",
46
- "@lowdefy/nunjucks": "4.0.0-rc.9",
47
- "@lowdefy/operators": "4.0.0-rc.9",
48
- "@lowdefy/operators-js": "4.0.0-rc.9"
37
+ "@lowdefy/ajv": "4.0.0",
38
+ "@lowdefy/helpers": "4.0.0",
39
+ "@lowdefy/node-utils": "4.0.0",
40
+ "@lowdefy/nunjucks": "4.0.0",
41
+ "@lowdefy/operators": "4.0.0",
42
+ "@lowdefy/operators-js": "4.0.0"
49
43
  },
50
44
  "devDependencies": {
51
- "@jest/globals": "28.1.0",
52
- "@swc/cli": "0.1.59",
53
- "@swc/core": "1.3.24",
54
- "@swc/jest": "0.2.24",
55
- "jest": "28.1.0"
45
+ "@jest/globals": "28.1.3",
46
+ "@swc/cli": "0.1.63",
47
+ "@swc/core": "1.3.99",
48
+ "@swc/jest": "0.2.29",
49
+ "jest": "28.1.3"
56
50
  },
57
51
  "publishConfig": {
58
52
  "access": "public"
59
53
  },
60
- "gitHead": "d20e6ac424643feca527a732dc2b0710713c8243"
61
- }
54
+ "scripts": {
55
+ "build": "swc src --out-dir dist --config-file ../../.swcrc --delete-dir-on-start",
56
+ "clean": "rm -rf dist",
57
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
58
+ }
59
+ }