Merge branch 'develop' into remove-babel

This commit is contained in:
Sam 2022-02-03 12:43:39 +02:00
commit 0fafedf77b
No known key found for this signature in database
GPG Key ID: D004126FCD1A6DF0
25 changed files with 156 additions and 156 deletions

81
.pnp.cjs generated
View File

@ -5248,13 +5248,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["ansi-regex", "npm:5.0.1"]
],
"linkType": "HARD",
}],
["npm:6.0.1", {
"packageLocation": "./.yarn/cache/ansi-regex-npm-6.0.1-8d663a607d-1ff8b7667c.zip/node_modules/ansi-regex/",
"packageDependencies": [
["ansi-regex", "npm:6.0.1"]
],
"linkType": "HARD",
}]
]],
["ansi-styles", [
@ -6310,13 +6303,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["supports-color", "npm:7.2.0"]
],
"linkType": "HARD",
}],
["npm:5.0.0", {
"packageLocation": "./.yarn/cache/chalk-npm-5.0.0-7be183234e-6eba7c518b.zip/node_modules/chalk/",
"packageDependencies": [
["chalk", "npm:5.0.0"]
],
"linkType": "HARD",
}]
]],
["change-case", [
@ -6488,14 +6474,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["restore-cursor", "npm:3.1.0"]
],
"linkType": "HARD",
}],
["npm:4.0.0", {
"packageLocation": "./.yarn/cache/cli-cursor-npm-4.0.0-08e7cbaf41-ab3f3ea207.zip/node_modules/cli-cursor/",
"packageDependencies": [
["cli-cursor", "npm:4.0.0"],
["restore-cursor", "npm:4.0.0"]
],
"linkType": "HARD",
}]
]],
["cli-spinners", [
@ -10151,10 +10129,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]
]],
["is-interactive", [
["npm:2.0.0", {
"packageLocation": "./.yarn/cache/is-interactive-npm-2.0.0-dcec8b26d7-e8d52ad490.zip/node_modules/is-interactive/",
["npm:1.0.0", {
"packageLocation": "./.yarn/cache/is-interactive-npm-1.0.0-7ff7c6e04a-824808776e.zip/node_modules/is-interactive/",
"packageDependencies": [
["is-interactive", "npm:2.0.0"]
["is-interactive", "npm:1.0.0"]
],
"linkType": "HARD",
}]
@ -10349,10 +10327,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]
]],
["is-unicode-supported", [
["npm:1.1.0", {
"packageLocation": "./.yarn/cache/is-unicode-supported-npm-1.1.0-272ac4ebf4-1f2504d943.zip/node_modules/is-unicode-supported/",
["npm:0.1.0", {
"packageLocation": "./.yarn/cache/is-unicode-supported-npm-0.1.0-0833e1bbfb-a2aab86ee7.zip/node_modules/is-unicode-supported/",
"packageDependencies": [
["is-unicode-supported", "npm:1.1.0"]
["is-unicode-supported", "npm:0.1.0"]
],
"linkType": "HARD",
}]
@ -11873,12 +11851,12 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]
]],
["log-symbols", [
["npm:5.1.0", {
"packageLocation": "./.yarn/cache/log-symbols-npm-5.1.0-75864cfeb4-7291b6e7f1.zip/node_modules/log-symbols/",
["npm:4.1.0", {
"packageLocation": "./.yarn/cache/log-symbols-npm-4.1.0-0a13492d8b-fce1497b31.zip/node_modules/log-symbols/",
"packageDependencies": [
["log-symbols", "npm:5.1.0"],
["chalk", "npm:5.0.0"],
["is-unicode-supported", "npm:1.1.0"]
["log-symbols", "npm:4.1.0"],
["chalk", "npm:4.1.2"],
["is-unicode-supported", "npm:0.1.0"]
],
"linkType": "HARD",
}]
@ -11919,7 +11897,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["decompress-targz", "npm:4.1.1"],
["jest", "virtual:babee6e81435a5d101529cd67f2c6b175f4db37a4ab0b58df15adf73dd11be8917ac14caf44ab4e6882a92c61661055072365b349016e85173e049f006fc2305#npm:27.4.7"],
["js-yaml", "npm:4.1.0"],
["ora", "npm:6.0.1"],
["ora", "npm:5.4.1"],
["uuid", "npm:8.3.2"]
],
"linkType": "SOFT",
@ -13992,18 +13970,18 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]
]],
["ora", [
["npm:6.0.1", {
"packageLocation": "./.yarn/cache/ora-npm-6.0.1-05bbf96407-d2215b85a4.zip/node_modules/ora/",
["npm:5.4.1", {
"packageLocation": "./.yarn/cache/ora-npm-5.4.1-4f0343adb7-28d476ee6c.zip/node_modules/ora/",
"packageDependencies": [
["ora", "npm:6.0.1"],
["bl", "npm:5.0.0"],
["ora", "npm:5.4.1"],
["bl", "npm:4.1.0"],
["chalk", "npm:4.1.2"],
["cli-cursor", "npm:4.0.0"],
["cli-cursor", "npm:3.1.0"],
["cli-spinners", "npm:2.6.1"],
["is-interactive", "npm:2.0.0"],
["is-unicode-supported", "npm:1.1.0"],
["log-symbols", "npm:5.1.0"],
["strip-ansi", "npm:7.0.1"],
["is-interactive", "npm:1.0.0"],
["is-unicode-supported", "npm:0.1.0"],
["log-symbols", "npm:4.1.0"],
["strip-ansi", "npm:6.0.1"],
["wcwidth", "npm:1.0.1"]
],
"linkType": "HARD",
@ -16847,15 +16825,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["signal-exit", "npm:3.0.6"]
],
"linkType": "HARD",
}],
["npm:4.0.0", {
"packageLocation": "./.yarn/cache/restore-cursor-npm-4.0.0-d42254f39d-5b675c5a59.zip/node_modules/restore-cursor/",
"packageDependencies": [
["restore-cursor", "npm:4.0.0"],
["onetime", "npm:5.1.2"],
["signal-exit", "npm:3.0.6"]
],
"linkType": "HARD",
}]
]],
["retry", [
@ -17663,14 +17632,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["ansi-regex", "npm:5.0.1"]
],
"linkType": "HARD",
}],
["npm:7.0.1", {
"packageLocation": "./.yarn/cache/strip-ansi-npm-7.0.1-668c121204-257f78fa43.zip/node_modules/strip-ansi/",
"packageDependencies": [
["strip-ansi", "npm:7.0.1"],
["ansi-regex", "npm:6.0.1"]
],
"linkType": "HARD",
}]
]],
["strip-bom", [

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -77,7 +77,10 @@ supportedArchitectures:
- x86
- arm64
nodeLinker: "pnp"
pnpEnableEsmLoader: true
pnpMode: "strict"
yarnPath: .yarn/releases/yarn-3.1.0.cjs
pnpEnableEsmLoader: true

View File

@ -14,10 +14,12 @@
limitations under the License.
*/
// TODO: strip auth prop from page before we send it to the client
async function getPageConfig({ authorize, readConfigFile }, { pageId }) {
const pageConfig = await readConfigFile(`pages/${pageId}/${pageId}.json`);
if (pageConfig && authorize(pageConfig)) return pageConfig;
if (pageConfig && authorize(pageConfig)) {
delete pageConfig.auth;
return pageConfig;
}
return null;
}

View File

@ -40,9 +40,6 @@ test('getPageConfig, public', async () => {
const res = await getPageConfig(context, { pageId: 'pageId' });
expect(res).toEqual({
id: 'page:pageId',
auth: {
public: true,
},
});
});
@ -81,9 +78,6 @@ test('getPageConfig, protected, with user', async () => {
);
expect(res).toEqual({
id: 'page:pageId',
auth: {
public: false,
},
});
});

View File

@ -0,0 +1,83 @@
/*
Copyright 2020-2021 Lowdefy, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import testContext from '../../test/testContext.js';
const mockGetMenu = jest.fn();
jest.mock('./menus/getMenus.js', () => ({
__esModule: true,
default: mockGetMenu,
}));
const mockReadConfigFile = jest.fn();
const context = testContext({ readConfigFile: mockReadConfigFile });
beforeEach(() => {
mockReadConfigFile.mockReset();
});
test('getRootConfig', async () => {
const getRootConfig = (await import('./getRootConfig.js')).default;
mockReadConfigFile.mockImplementation((path) => {
if (path === 'global.json') {
return {
global: true,
};
}
return null;
});
const menus = [
{
menuId: 'default',
links: [
{
id: 'menuitem:default:0',
menuItemId: '0',
type: 'MenuLink',
pageId: 'page',
auth: { public: true },
},
],
},
];
mockGetMenu.mockImplementation(() => menus);
const res = await getRootConfig(context);
expect(res).toEqual({
authenticated: undefined,
home: {
configured: false,
pageId: 'page',
},
lowdefyGlobal: {
global: true,
},
menus: [
{
menuId: 'default',
links: [
{
id: 'menuitem:default:0',
menuItemId: '0',
type: 'MenuLink',
pageId: 'page',
auth: { public: true },
},
],
},
],
});
});

View File

@ -71,8 +71,8 @@ test('set empty operators array if no operators on page', async () => {
],
};
await buildPages({ components, context });
expect(context.counters.clientOperatorTypes.getCounts()).toEqual({});
expect(context.counters.serverOperatorTypes.getCounts()).toEqual({});
expect(context.typeCounters.operators.client.getCounts()).toEqual({});
expect(context.typeCounters.operators.server.getCounts()).toEqual({});
});
test('count all operators for the page', async () => {
@ -104,14 +104,14 @@ test('count all operators for the page', async () => {
],
};
await buildPages({ components, context });
expect(context.counters.clientOperatorTypes.getCounts()).toEqual({
expect(context.typeCounters.operators.client.getCounts()).toEqual({
_op_1: 3,
_op_2: 1,
_op_3: 1,
_op_4: 1,
_op_5: 1,
});
expect(context.counters.serverOperatorTypes.getCounts()).toEqual({});
expect(context.typeCounters.operators.server.getCounts()).toEqual({});
});
test('count requests operators as server operators', async () => {
@ -150,12 +150,12 @@ test('count requests operators as server operators', async () => {
],
};
await buildPages({ components, context });
expect(context.counters.clientOperatorTypes.getCounts()).toEqual({
expect(context.typeCounters.operators.client.getCounts()).toEqual({
_op_1: 1,
_op_2: 1,
_op_3: 1,
});
expect(context.counters.serverOperatorTypes.getCounts()).toEqual({
expect(context.typeCounters.operators.server.getCounts()).toEqual({
_r_op_1: 1,
});
});
@ -187,11 +187,11 @@ test('count request payload operators as client operators', async () => {
],
};
await buildPages({ components, context });
expect(context.counters.clientOperatorTypes.getCounts()).toEqual({
expect(context.typeCounters.operators.client.getCounts()).toEqual({
_r_op_1: 1,
_op_1: 1,
});
expect(context.counters.serverOperatorTypes.getCounts()).toEqual({
expect(context.typeCounters.operators.server.getCounts()).toEqual({
_r_op_2: 1,
});
});

View File

@ -38,6 +38,10 @@ function buildTypeClass(
function buildTypes({ components, context }) {
const { typeCounters } = context;
// Add operators used by form validation
typeCounters.operators.client.increment('_not');
typeCounters.operators.client.increment('_type');
components.types = {
actions: {},
blocks: {},

View File

@ -17,7 +17,6 @@
import generateImportFile from './generateImportFile.js';
async function writeOperatorImports({ components, context }) {
// TODO: import _not and _type for validation.
await context.writeBuildArtifact(
'plugins/operatorsClient.js',
generateImportFile({

View File

@ -48,7 +48,7 @@
"decompress": "4.2.1",
"decompress-targz": "4.1.1",
"js-yaml": "4.1.0",
"ora": "6.0.1",
"ora": "5.4.1",
"uuid": "8.3.2"
},
"devDependencies": {

View File

@ -14,8 +14,6 @@
limitations under the License.
*/
// TODO: Send keep-alive comment event: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#examples
import chokidar from 'chokidar';
const handler = async (req, res) => {

View File

@ -23,8 +23,6 @@ export async function getServerSideProps(context) {
// TODO: get the right api context options
const apiContext = await createApiContext({ buildDirectory: './build' });
// TODO: Maybe we can only get rootConfig once?
// We can't do getServerSideProps on _app :(
const [rootConfig, pageConfig] = await Promise.all([
getRootConfig(apiContext),
getPageConfig(apiContext, { pageId }),

102
yarn.lock
View File

@ -4015,13 +4015,6 @@ __metadata:
languageName: node
linkType: hard
"ansi-regex@npm:^6.0.1":
version: 6.0.1
resolution: "ansi-regex@npm:6.0.1"
checksum: 1ff8b7667cded1de4fa2c9ae283e979fc87036864317da86a2e546725f96406746411d0d85e87a2d12fa5abd715d90006de7fa4fa0477c92321ad3b4c7d4e169
languageName: node
linkType: hard
"ansi-styles@npm:^3.2.1":
version: 3.2.1
resolution: "ansi-styles@npm:3.2.1"
@ -4557,7 +4550,7 @@ __metadata:
languageName: node
linkType: hard
"bl@npm:^4.0.3":
"bl@npm:^4.0.3, bl@npm:^4.1.0":
version: 4.1.0
resolution: "bl@npm:4.1.0"
dependencies:
@ -4872,7 +4865,7 @@ __metadata:
languageName: node
linkType: hard
"chalk@npm:4.1.2, chalk@npm:^4.0.0, chalk@npm:^4.1.0, chalk@npm:^4.1.2":
"chalk@npm:4.1.2, chalk@npm:^4.0.0, chalk@npm:^4.1.0":
version: 4.1.2
resolution: "chalk@npm:4.1.2"
dependencies:
@ -4903,13 +4896,6 @@ __metadata:
languageName: node
linkType: hard
"chalk@npm:^5.0.0":
version: 5.0.0
resolution: "chalk@npm:5.0.0"
checksum: 6eba7c518b9aa5fe882ae6d14a1ffa58c418d72a3faa7f72af56641f1bbef51b645fca1d6e05d42357b7d3c846cd504c0b7b64d12309cdd07867e3b4411e0d01
languageName: node
linkType: hard
"change-case@npm:4.1.2":
version: 4.1.2
resolution: "change-case@npm:4.1.2"
@ -5060,16 +5046,7 @@ __metadata:
languageName: node
linkType: hard
"cli-cursor@npm:^4.0.0":
version: 4.0.0
resolution: "cli-cursor@npm:4.0.0"
dependencies:
restore-cursor: ^4.0.0
checksum: ab3f3ea2076e2176a1da29f9d64f72ec3efad51c0960898b56c8a17671365c26e67b735920530eaf7328d61f8bd41c27f46b9cf6e4e10fe2fa44b5e8c0e392cc
languageName: node
linkType: hard
"cli-spinners@npm:^2.6.0":
"cli-spinners@npm:^2.5.0":
version: 2.6.1
resolution: "cli-spinners@npm:2.6.1"
checksum: 423409baaa7a58e5104b46ca1745fbfc5888bbd0b0c5a626e052ae1387060839c8efd512fb127e25769b3dc9562db1dc1b5add6e0b93b7ef64f477feb6416a45
@ -8206,10 +8183,10 @@ __metadata:
languageName: node
linkType: hard
"is-interactive@npm:^2.0.0":
version: 2.0.0
resolution: "is-interactive@npm:2.0.0"
checksum: e8d52ad490bed7ae665032c7675ec07732bbfe25808b0efbc4d5a76b1a1f01c165f332775c63e25e9a03d319ebb6b24f571a9e902669fc1e40b0a60b5be6e26c
"is-interactive@npm:^1.0.0":
version: 1.0.0
resolution: "is-interactive@npm:1.0.0"
checksum: 824808776e2d468b2916cdd6c16acacebce060d844c35ca6d82267da692e92c3a16fdba624c50b54a63f38bdc4016055b6f443ce57d7147240de4f8cdabaf6f9
languageName: node
linkType: hard
@ -8375,10 +8352,10 @@ __metadata:
languageName: node
linkType: hard
"is-unicode-supported@npm:^1.1.0":
version: 1.1.0
resolution: "is-unicode-supported@npm:1.1.0"
checksum: 1f2504d94383ea180ea25e729b40b1d97398a37325c2e62db96a3e98b457c767259dd5bbf9ab2815e83e5012dc4b61d533e75d12df7f208c470474d821bd5f24
"is-unicode-supported@npm:^0.1.0":
version: 0.1.0
resolution: "is-unicode-supported@npm:0.1.0"
checksum: a2aab86ee7712f5c2f999180daaba5f361bdad1efadc9610ff5b8ab5495b86e4f627839d085c6530363c6d6d4ecbde340fb8e54bdb83da4ba8e0865ed5513c52
languageName: node
linkType: hard
@ -9730,13 +9707,13 @@ __metadata:
languageName: node
linkType: hard
"log-symbols@npm:^5.0.0":
version: 5.1.0
resolution: "log-symbols@npm:5.1.0"
"log-symbols@npm:^4.1.0":
version: 4.1.0
resolution: "log-symbols@npm:4.1.0"
dependencies:
chalk: ^5.0.0
is-unicode-supported: ^1.1.0
checksum: 7291b6e7f1b3df6865bdaeb9b59605c832668ac2fa0965c63b1e7dd3700349aec09c1d7d40c368d5041ff58b7f89461a56e4009471921301af7b3609cbff9a29
chalk: ^4.1.0
is-unicode-supported: ^0.1.0
checksum: fce1497b3135a0198803f9f07464165e9eb83ed02ceb2273930a6f8a508951178d8cf4f0378e9d28300a2ed2bc49050995d2bd5f53ab716bb15ac84d58c6ef74
languageName: node
linkType: hard
@ -9774,7 +9751,7 @@ __metadata:
decompress-targz: 4.1.1
jest: 27.4.7
js-yaml: 4.1.0
ora: 6.0.1
ora: 5.4.1
uuid: 8.3.2
bin:
lowdefy: ./dist/index.js
@ -11638,20 +11615,20 @@ __metadata:
languageName: node
linkType: hard
"ora@npm:6.0.1":
version: 6.0.1
resolution: "ora@npm:6.0.1"
"ora@npm:5.4.1":
version: 5.4.1
resolution: "ora@npm:5.4.1"
dependencies:
bl: ^5.0.0
chalk: ^4.1.2
cli-cursor: ^4.0.0
cli-spinners: ^2.6.0
is-interactive: ^2.0.0
is-unicode-supported: ^1.1.0
log-symbols: ^5.0.0
strip-ansi: ^7.0.1
bl: ^4.1.0
chalk: ^4.1.0
cli-cursor: ^3.1.0
cli-spinners: ^2.5.0
is-interactive: ^1.0.0
is-unicode-supported: ^0.1.0
log-symbols: ^4.1.0
strip-ansi: ^6.0.0
wcwidth: ^1.0.1
checksum: d2215b85a481a21d4e53f2e484658a7d1526b0b6dfeab63e4b350b620f2bb9df33fd3f2a9ece1695b28ffa1b8954a31bfc26a44460a60fe98785c1c37527f4da
checksum: 28d476ee6c1049d68368c0dc922e7225e3b5600c3ede88fade8052837f9ed342625fdaa84a6209302587c8ddd9b664f71f0759833cbdb3a4cf81344057e63c63
languageName: node
linkType: hard
@ -13721,16 +13698,6 @@ __metadata:
languageName: node
linkType: hard
"restore-cursor@npm:^4.0.0":
version: 4.0.0
resolution: "restore-cursor@npm:4.0.0"
dependencies:
onetime: ^5.1.0
signal-exit: ^3.0.2
checksum: 5b675c5a59763bf26e604289eab35711525f11388d77f409453904e1e69c0d37ae5889295706b2c81d23bd780165084d040f9b68fffc32cc921519031c4fa4af
languageName: node
linkType: hard
"retry@npm:^0.12.0":
version: 0.12.0
resolution: "retry@npm:0.12.0"
@ -14474,15 +14441,6 @@ __metadata:
languageName: node
linkType: hard
"strip-ansi@npm:^7.0.1":
version: 7.0.1
resolution: "strip-ansi@npm:7.0.1"
dependencies:
ansi-regex: ^6.0.1
checksum: 257f78fa433520e7f9897722731d78599cb3fce29ff26a20a5e12ba4957463b50a01136f37c43707f4951817a75e90820174853d6ccc240997adc5df8f966039
languageName: node
linkType: hard
"strip-bom@npm:^3.0.0":
version: 3.0.0
resolution: "strip-bom@npm:3.0.0"