libmodulor 0.24.0 → 0.26.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/CHANGELOG.md +32 -0
- package/README.md +32 -151
- package/dist/esm/app/workers/AppUCsLoader.d.ts +2 -3
- package/dist/esm/apps/Helper/src/i18n.d.ts +39 -2
- package/dist/esm/apps/Helper/src/i18n.js +15 -1
- package/dist/esm/apps/Helper/src/lib/SrcFilesGenerator.d.ts +13 -0
- package/dist/esm/apps/Helper/src/lib/SrcFilesGenerator.js +37 -0
- package/dist/esm/apps/Helper/src/lib/consts.d.ts +2 -0
- package/dist/esm/apps/Helper/src/lib/consts.js +2 -0
- package/dist/esm/apps/Helper/src/lib/funcs.d.ts +4 -0
- package/dist/esm/apps/Helper/src/lib/funcs.js +9 -0
- package/dist/esm/apps/Helper/src/lib/io.d.ts +10 -0
- package/dist/esm/apps/Helper/src/lib/io.js +22 -0
- package/dist/esm/apps/Helper/src/lib/layers/app.d.ts +3 -0
- package/dist/esm/apps/Helper/src/lib/layers/app.js +30 -0
- package/dist/esm/apps/Helper/src/lib/layers/product.d.ts +3 -0
- package/dist/esm/apps/Helper/src/lib/layers/product.js +27 -0
- package/dist/esm/apps/Helper/src/lib/layers/project.d.ts +4 -0
- package/dist/esm/apps/Helper/src/lib/layers/project.js +163 -0
- package/dist/esm/apps/Helper/src/lib/layers/target.d.ts +3 -0
- package/dist/esm/apps/Helper/src/lib/layers/target.js +202 -0
- package/dist/esm/apps/Helper/src/lib/layers/uc.d.ts +3 -0
- package/dist/esm/apps/Helper/src/lib/layers/uc.js +113 -0
- package/dist/esm/apps/Helper/src/lib/project.js +21 -23
- package/dist/esm/apps/Helper/src/lib/types.d.ts +3 -0
- package/dist/esm/apps/Helper/src/lib/types.js +1 -0
- package/dist/esm/apps/Helper/src/manifest.d.ts +20 -0
- package/dist/esm/apps/Helper/src/manifest.js +20 -0
- package/dist/esm/apps/Helper/src/ucds/CreateAppUCD.d.ts +7 -0
- package/dist/esm/apps/Helper/src/ucds/CreateAppUCD.js +101 -0
- package/dist/esm/apps/Helper/src/ucds/CreateProductUCD.d.ts +7 -0
- package/dist/esm/apps/Helper/src/ucds/CreateProductUCD.js +101 -0
- package/dist/esm/apps/Helper/src/ucds/CreateProjectUCD.d.ts +1 -17
- package/dist/esm/apps/Helper/src/ucds/CreateProjectUCD.js +40 -34
- package/dist/esm/apps/Helper/src/ucds/CreateTargetUCD.d.ts +9 -0
- package/dist/esm/apps/Helper/src/ucds/CreateTargetUCD.js +109 -0
- package/dist/esm/apps/Helper/src/ucds/CreateUCUCD.d.ts +8 -0
- package/dist/esm/apps/Helper/src/ucds/CreateUCUCD.js +87 -0
- package/dist/esm/apps/Helper/src/ucds/DeleteGeneratedAppsTestsUCD.d.ts +1 -1
- package/dist/esm/apps/Helper/src/ucds/DeleteGeneratedAppsTestsUCD.js +1 -1
- package/dist/esm/apps/Helper/src/ucds/GenerateAppsTestsUCD.d.ts +1 -1
- package/dist/esm/apps/Helper/src/ucds/GenerateAppsTestsUCD.js +1 -1
- package/dist/esm/apps/Helper/src/ucds/TestAppUCD.d.ts +1 -1
- package/dist/esm/apps/Helper/src/ucds/TestAppUCD.js +1 -1
- package/dist/esm/convention.d.ts +15 -4
- package/dist/esm/convention.js +33 -9
- package/dist/esm/dt/Validation.d.ts +2 -2
- package/dist/esm/dt/base/TBase.d.ts +2 -0
- package/dist/esm/dt/base/TBase.js +3 -0
- package/dist/esm/dt/base/TObject.d.ts +6 -4
- package/dist/esm/dt/base/TObject.js +4 -5
- package/dist/esm/dt/base/TString.d.ts +2 -1
- package/dist/esm/dt/base/TString.js +22 -0
- package/dist/esm/dt/final/TFile.d.ts +13 -4
- package/dist/esm/dt/final/TFile.js +70 -8
- package/dist/esm/dt/final/TFileExtension.d.ts +1 -1
- package/dist/esm/dt/final/TFileMimeType.d.ts +2 -6
- package/dist/esm/dt/final/TFileMimeType.js +0 -6
- package/dist/esm/dt/final/TFilePath.d.ts +7 -0
- package/dist/esm/dt/final/TFilePath.js +5 -1
- package/dist/esm/dt/index.d.ts +1 -1
- package/dist/esm/error/funcs.d.ts +2 -0
- package/dist/esm/error/funcs.js +20 -0
- package/dist/esm/error/index.d.ts +1 -1
- package/dist/esm/error/index.js +1 -1
- package/dist/esm/i18n/WordingManager.d.ts +2 -1
- package/dist/esm/i18n/WordingManager.js +23 -2
- package/dist/esm/i18n/locales/de.js +8 -0
- package/dist/esm/i18n/locales/en.js +8 -0
- package/dist/esm/i18n/locales/es.js +8 -0
- package/dist/esm/i18n/locales/fr.js +8 -0
- package/dist/esm/i18n/types.d.ts +2 -2
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.node-test.d.ts +1 -1
- package/dist/esm/index.node-test.js +1 -1
- package/dist/esm/product/index.d.ts +1 -1
- package/dist/esm/product/index.js +1 -1
- package/dist/esm/product/workers/ProductUCsLoader.d.ts +8 -6
- package/dist/esm/product/workers/ProductUCsLoader.js +19 -5
- package/dist/esm/products/Helper/cli-node-core/container.d.ts +3 -0
- package/dist/esm/products/Helper/cli-node-core/container.js +26 -0
- package/dist/esm/products/Helper/cli-node-core/index.d.ts +1 -0
- package/dist/esm/products/Helper/cli-node-core/index.js +9 -0
- package/dist/esm/products/Helper/i18n.d.ts +101 -2
- package/dist/esm/products/Helper/targets/node-core-cli/container.d.ts +3 -0
- package/dist/esm/products/Helper/targets/node-core-cli/container.js +26 -0
- package/dist/esm/products/Helper/targets/node-core-cli/index.d.ts +1 -0
- package/dist/esm/products/Helper/targets/node-core-cli/index.js +9 -0
- package/dist/esm/std/FSManager.d.ts +7 -5
- package/dist/esm/std/FSManager.js +5 -6
- package/dist/esm/std/FormDataBuilder.d.ts +2 -1
- package/dist/esm/std/SettingsManager.d.ts +3 -16
- package/dist/esm/std/SettingsManager.js +1 -16
- package/dist/esm/std/ShellCommandExecutor.d.ts +1 -1
- package/dist/esm/std/consts.js +4 -4
- package/dist/esm/std/impl/EnvSettingsManager.d.ts +5 -4
- package/dist/esm/std/impl/EnvSettingsManager.js +40 -62
- package/dist/esm/std/impl/FakeFSManager.d.ts +3 -1
- package/dist/esm/std/impl/FakeFSManager.js +3 -0
- package/dist/esm/std/impl/FakeShellCommandExecutor.d.ts +12 -0
- package/dist/esm/std/impl/FakeShellCommandExecutor.js +30 -0
- package/dist/esm/std/impl/NodeFSManager.js +3 -2
- package/dist/esm/std/impl/StaticSettingsManager.d.ts +1 -1
- package/dist/esm/std/impl/StaticSettingsManager.js +3 -0
- package/dist/esm/std/index.d.ts +1 -0
- package/dist/esm/std/index.js +1 -0
- package/dist/esm/std/lib/settings.d.ts +5 -0
- package/dist/esm/std/lib/settings.js +39 -0
- package/dist/esm/target/edge-worker-hono-server/SyncEdgeWorkerHonoServerManager.d.ts +3 -1
- package/dist/esm/target/edge-worker-hono-server/SyncEdgeWorkerHonoServerManager.js +12 -7
- package/dist/esm/target/index.d.ts +1 -0
- package/dist/esm/target/index.js +1 -0
- package/dist/esm/target/lib/cli/CLIManager.d.ts +2 -2
- package/dist/esm/target/lib/client/consts.js +2 -1
- package/dist/esm/target/lib/entrypoint.d.ts +2 -0
- package/dist/esm/target/lib/entrypoint.js +1 -0
- package/dist/esm/target/lib/manifest.d.ts +13 -0
- package/dist/esm/target/lib/manifest.js +11 -0
- package/dist/esm/target/lib/mcp-server/MCPServerBooter.d.ts +2 -2
- package/dist/esm/target/lib/react/StyleContextProvider.d.ts +1 -0
- package/dist/esm/target/lib/react/form.d.ts +1 -1
- package/dist/esm/target/lib/react/form.js +1 -0
- package/dist/esm/target/lib/react/useAction.d.ts +1 -1
- package/dist/esm/target/lib/react/useAction.js +13 -12
- package/dist/esm/target/lib/server/CustomerFacingErrorBuilder.js +6 -1
- package/dist/esm/target/lib/server/ServerBooter.d.ts +2 -2
- package/dist/esm/target/lib/server/ServerRequestHandler.js +6 -2
- package/dist/esm/target/lib/server/consts.js +2 -1
- package/dist/esm/target/lib/server-express/funcs.d.ts +2 -0
- package/dist/esm/target/lib/server-express/funcs.js +8 -1
- package/dist/esm/target/lib/server-hono/funcs.d.ts +2 -1
- package/dist/esm/target/lib/server-hono/funcs.js +7 -3
- package/dist/esm/target/lib/web/input.d.ts +1 -0
- package/dist/esm/target/lib/web/input.js +5 -1
- package/dist/esm/target/node-express-server/NodeExpressServerManager.d.ts +3 -1
- package/dist/esm/target/node-express-server/NodeExpressServerManager.js +17 -12
- package/dist/esm/target/node-hono-server/NodeHonoServerManager.d.ts +3 -1
- package/dist/esm/target/node-hono-server/NodeHonoServerManager.js +15 -10
- package/dist/esm/target/node-stricli-cli/NodeStricliCLIManager.d.ts +3 -1
- package/dist/esm/target/node-stricli-cli/NodeStricliCLIManager.js +9 -5
- package/dist/esm/target/react-native-pure/UCFormField.js +2 -1
- package/dist/esm/target/react-native-pure/UCFormFieldControl.js +6 -4
- package/dist/esm/target/react-native-pure/UCFormFieldErr.d.ts +1 -1
- package/dist/esm/target/react-native-pure/UCFormFieldErr.js +4 -1
- package/dist/esm/target/react-native-pure/UCFormFieldHelp.d.ts +4 -0
- package/dist/esm/target/react-native-pure/UCFormFieldHelp.js +15 -0
- package/dist/esm/target/react-web-pure/UCFormField.js +2 -1
- package/dist/esm/target/react-web-pure/UCFormFieldErr.d.ts +1 -1
- package/dist/esm/target/react-web-pure/UCFormFieldErr.js +4 -1
- package/dist/esm/target/react-web-pure/UCFormFieldHelp.d.ts +4 -0
- package/dist/esm/target/react-web-pure/UCFormFieldHelp.js +14 -0
- package/dist/esm/testing/impl/NodeAppTesterConfigurator.d.ts +15 -0
- package/dist/esm/testing/impl/NodeAppTesterConfigurator.js +68 -0
- package/dist/esm/testing/impl/SimpleAppDocsEmitter/SimpleAppDocsEmitter.d.ts +7 -0
- package/dist/esm/testing/impl/SimpleAppDocsEmitter/SimpleAppDocsEmitter.js +59 -0
- package/dist/esm/testing/impl/SimpleAppDocsEmitter/markdown.d.ts +2 -0
- package/dist/esm/testing/impl/SimpleAppDocsEmitter/markdown.js +10 -0
- package/dist/esm/testing/impl/SimpleAppDocsEmitter/sequence-diagram.d.ts +2 -0
- package/dist/esm/testing/impl/SimpleAppDocsEmitter/sequence-diagram.js +92 -0
- package/dist/esm/testing/impl/SimpleAppDocsEmitter/tech-summary.d.ts +2 -0
- package/dist/esm/testing/impl/SimpleAppDocsEmitter/tech-summary.js +27 -0
- package/dist/esm/testing/impl/SimpleAppDocsEmitter/uc-summary.d.ts +2 -0
- package/dist/esm/testing/impl/SimpleAppDocsEmitter/uc-summary.js +63 -0
- package/dist/esm/testing/impl/VitestAppTestSuiteEmitter.d.ts +2 -0
- package/dist/esm/testing/impl/VitestAppTestSuiteEmitter.js +27 -10
- package/dist/esm/testing/impl/newNodeAppTester.js +4 -5
- package/dist/esm/testing/opts.d.ts +1 -1
- package/dist/esm/testing/uc-input.js +5 -2
- package/dist/esm/uc/exec.d.ts +42 -21
- package/dist/esm/uc/exec.js +48 -13
- package/dist/esm/uc/input-field.d.ts +6 -4
- package/dist/esm/uc/input-field.js +4 -5
- package/dist/esm/uc/side-effect.d.ts +10 -8
- package/dist/esm/uc/side-effect.js +5 -6
- package/dist/esm/uc/workers/UCInputFilesProcessor.js +3 -3
- package/dist/esm/uc/workers/UCInputValidator.js +2 -1
- package/dist/esm/uc/workers/UCOutputFilesProcessor.js +1 -1
- package/dist/esm/utils/bundling/webpack/loader.js +1 -1
- package/dist/esm/utils/index.d.ts +1 -1
- package/dist/esm/utils/ioc/bindCommon.d.ts +4 -4
- package/dist/esm/utils/ioc/bindCommon.js +17 -15
- package/dist/esm/utils/ioc/bindNodeCore.js +5 -0
- package/dist/esm/utils/ioc/bindServer.js +8 -2
- package/dist/esm/utils/types/utility-types.d.ts +4 -0
- package/package.json +19 -16
- package/pnpm-workspace.yaml +0 -8
- package/tsconfig.build.examples.json +0 -8
- package/tsconfig.json +0 -36
- package/vitest.config.ts +0 -16
package/dist/esm/convention.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { AppName } from './app/index.js';
|
|
2
2
|
import type { ProductName } from './product/index.js';
|
|
3
|
+
import type { TargetName } from './target/index.js';
|
|
4
|
+
import type { UCName } from './uc/index.js';
|
|
3
5
|
export declare const SRC_DIR_NAME: string;
|
|
4
6
|
export declare const APPS_ROOT_DIR_NAME: string;
|
|
5
7
|
export declare const APPS_ROOT_ALIAS: string;
|
|
@@ -12,7 +14,6 @@ export declare const APP_INDEX_FILE_NAME: string;
|
|
|
12
14
|
export declare const APP_INDEX_FILE_NAME_FOR_IMPORT: string;
|
|
13
15
|
export declare const APP_INSTALLER_FILE_NAME: string;
|
|
14
16
|
export declare const APP_MANIFEST_NAME: string;
|
|
15
|
-
export declare const APP_MANIFEST_FILE_EXT: string;
|
|
16
17
|
export declare const APP_MANIFEST_FILE_NAME: string;
|
|
17
18
|
export declare const APP_NAME_PLACEHOLDER: AppName;
|
|
18
19
|
export declare const APP_ROOT_FROM_UCD: string[];
|
|
@@ -20,17 +21,21 @@ export declare const APP_SETTINGS_FILE_NAME: string;
|
|
|
20
21
|
export declare const APP_SRC_DIR_NAME: string;
|
|
21
22
|
export declare const APP_SRC_LIB_DIR_NAME: string;
|
|
22
23
|
export declare const APP_SRC_UCDS_DIR_NAME: string;
|
|
24
|
+
export declare const APP_TEST_CONFIGURATOR_NAME: string;
|
|
25
|
+
export declare const APP_TEST_CONFIGURATOR_FILE_NAME: string;
|
|
23
26
|
export declare const APP_TEST_DIR_NAME: string;
|
|
24
27
|
export declare const APP_TEST_MAIN_FILE_NAME: string;
|
|
25
28
|
export declare const APP_TEST_REPORTS_DIR_NAME: string;
|
|
29
|
+
export declare const PRODUCTS_ROOT_DIR_NAME: string;
|
|
26
30
|
export declare const PRODUCTS_ROOT_ALIAS: string;
|
|
27
31
|
export declare const PRODUCTS_ROOT_PATH: string[];
|
|
32
|
+
export declare const PRODUCT_I18N_NAME: string;
|
|
33
|
+
export declare const PRODUCT_I18N_FILE_NAME: string;
|
|
28
34
|
export declare const PRODUCT_MANIFEST_NAME: string;
|
|
29
|
-
export declare const PRODUCT_MANIFEST_FILE_EXT: string;
|
|
30
35
|
export declare const PRODUCT_MANIFEST_FILE_NAME: string;
|
|
31
36
|
export declare const PRODUCT_NAME_PLACEHOLDER: ProductName;
|
|
37
|
+
export declare const PRODUCT_TARGETS_DIR_NAME: string;
|
|
32
38
|
export declare const UC_DEF_SUFFIX: string;
|
|
33
|
-
export declare const UC_DEF_FILE_NAME_EXT: string;
|
|
34
39
|
export declare const UC_DEF_FILE_NAME_SUFFIX: string;
|
|
35
40
|
export declare const UC_DEF_TYPE: string;
|
|
36
41
|
export declare const UC_INPUT_BASE: string;
|
|
@@ -42,10 +47,16 @@ export declare const UC_LIFECYCLE_SERVER_PROP_NAME: string;
|
|
|
42
47
|
export declare const UC_MAIN_SUFFIX: string;
|
|
43
48
|
export declare const UC_MAIN_CLIENT_SUFFIX: string;
|
|
44
49
|
export declare const UC_MAIN_SERVER_SUFFIX: string;
|
|
50
|
+
export declare const UC_MAIN_SERVER_FILE_NAME_SUFFIX: string;
|
|
45
51
|
export declare const UC_MAIN_STEP_PREFIX_REGULAR = "// >=>";
|
|
52
|
+
export declare const UC_NAME_PLACEHOLDER: UCName;
|
|
46
53
|
export declare const UC_OPI_BASE: string;
|
|
47
54
|
export declare const UC_OPI_SUFFIX: string;
|
|
55
|
+
export declare const UC_OPI0_SUFFIX: string;
|
|
56
|
+
export declare const UC_OPI1_SUFFIX: string;
|
|
48
57
|
export declare const UC_POLICY_SUFFIX: string;
|
|
49
58
|
export declare const UC_POLICY_SUFFIX_FULL: string;
|
|
50
|
-
export declare const UC_POLICY_FILE_NAME_EXT: string;
|
|
51
59
|
export declare const UC_POLICY_FILE_NAME_SUFFIX: string;
|
|
60
|
+
export declare const PRODUCT_ROOT_FROM_PRODUCT_TARGET_PATH: string[];
|
|
61
|
+
export declare const APPS_PATH_FROM_PRODUCT_TARGET_PATH: string[];
|
|
62
|
+
export declare const TARGET_NAME_PLACEHOLDER: TargetName;
|
package/dist/esm/convention.js
CHANGED
|
@@ -16,32 +16,38 @@ export const APP_INDEX_FILE_NAME = `${APP_INDEX_NAME}.ts`;
|
|
|
16
16
|
export const APP_INDEX_FILE_NAME_FOR_IMPORT = 'index.js'; // ESM
|
|
17
17
|
export const APP_INSTALLER_FILE_NAME = 'installer.ts';
|
|
18
18
|
export const APP_MANIFEST_NAME = 'Manifest';
|
|
19
|
-
export const
|
|
20
|
-
export const APP_MANIFEST_FILE_NAME = `${APP_MANIFEST_NAME.toLowerCase()}${APP_MANIFEST_FILE_EXT}`;
|
|
19
|
+
export const APP_MANIFEST_FILE_NAME = `${APP_MANIFEST_NAME.toLowerCase()}.ts`;
|
|
21
20
|
export const APP_NAME_PLACEHOLDER = 'AppX';
|
|
22
21
|
export const APP_ROOT_FROM_UCD = ['..', '..', '..']; // $root/src/ucds/XyzUCD.ts
|
|
23
22
|
export const APP_SETTINGS_FILE_NAME = 'settings.ts';
|
|
24
23
|
export const APP_SRC_DIR_NAME = SRC_DIR_NAME;
|
|
25
24
|
export const APP_SRC_LIB_DIR_NAME = 'lib';
|
|
26
25
|
export const APP_SRC_UCDS_DIR_NAME = 'ucds';
|
|
26
|
+
export const APP_TEST_CONFIGURATOR_NAME = 'Configurator';
|
|
27
|
+
export const APP_TEST_CONFIGURATOR_FILE_NAME = `${APP_TEST_CONFIGURATOR_NAME}.ts`;
|
|
27
28
|
export const APP_TEST_DIR_NAME = 'test';
|
|
28
29
|
export const APP_TEST_MAIN_FILE_NAME = 'App.test.ts';
|
|
29
30
|
export const APP_TEST_REPORTS_DIR_NAME = 'reports';
|
|
30
31
|
/*
|
|
31
32
|
* Product
|
|
32
33
|
*/
|
|
34
|
+
export const PRODUCTS_ROOT_DIR_NAME = 'products';
|
|
33
35
|
export const PRODUCTS_ROOT_ALIAS = '@p';
|
|
34
|
-
export const PRODUCTS_ROOT_PATH = [
|
|
36
|
+
export const PRODUCTS_ROOT_PATH = [
|
|
37
|
+
SRC_DIR_NAME,
|
|
38
|
+
PRODUCTS_ROOT_DIR_NAME,
|
|
39
|
+
];
|
|
40
|
+
export const PRODUCT_I18N_NAME = 'I18n';
|
|
41
|
+
export const PRODUCT_I18N_FILE_NAME = `${PRODUCT_I18N_NAME.toLowerCase()}.ts`;
|
|
35
42
|
export const PRODUCT_MANIFEST_NAME = 'Manifest';
|
|
36
|
-
export const
|
|
37
|
-
export const PRODUCT_MANIFEST_FILE_NAME = `${PRODUCT_MANIFEST_NAME.toLowerCase()}${PRODUCT_MANIFEST_FILE_EXT}`;
|
|
43
|
+
export const PRODUCT_MANIFEST_FILE_NAME = `${PRODUCT_MANIFEST_NAME.toLowerCase()}.ts`;
|
|
38
44
|
export const PRODUCT_NAME_PLACEHOLDER = 'ProductX';
|
|
45
|
+
export const PRODUCT_TARGETS_DIR_NAME = 'targets';
|
|
39
46
|
/*
|
|
40
47
|
* Use Case
|
|
41
48
|
*/
|
|
42
49
|
export const UC_DEF_SUFFIX = 'UCD';
|
|
43
|
-
export const
|
|
44
|
-
export const UC_DEF_FILE_NAME_SUFFIX = `${UC_DEF_SUFFIX}${UC_DEF_FILE_NAME_EXT}`;
|
|
50
|
+
export const UC_DEF_FILE_NAME_SUFFIX = `${UC_DEF_SUFFIX}.ts`;
|
|
45
51
|
export const UC_DEF_TYPE = 'UCDef';
|
|
46
52
|
export const UC_INPUT_BASE = 'UCInput';
|
|
47
53
|
export const UC_INPUT_FIELD_PATTERN = '^UCInputFieldValue<(.*)>$';
|
|
@@ -52,10 +58,28 @@ export const UC_LIFECYCLE_SERVER_PROP_NAME = 'server';
|
|
|
52
58
|
export const UC_MAIN_SUFFIX = 'Main';
|
|
53
59
|
export const UC_MAIN_CLIENT_SUFFIX = `Client${UC_MAIN_SUFFIX}`;
|
|
54
60
|
export const UC_MAIN_SERVER_SUFFIX = `Server${UC_MAIN_SUFFIX}`;
|
|
61
|
+
export const UC_MAIN_SERVER_FILE_NAME_SUFFIX = `${UC_MAIN_SERVER_SUFFIX}.ts`;
|
|
55
62
|
export const UC_MAIN_STEP_PREFIX_REGULAR = '// >=>';
|
|
63
|
+
export const UC_NAME_PLACEHOLDER = 'CreateX';
|
|
56
64
|
export const UC_OPI_BASE = 'UCOPIBase';
|
|
57
65
|
export const UC_OPI_SUFFIX = 'OPI';
|
|
66
|
+
export const UC_OPI0_SUFFIX = `${UC_OPI_SUFFIX}0`;
|
|
67
|
+
export const UC_OPI1_SUFFIX = `${UC_OPI_SUFFIX}1`;
|
|
58
68
|
export const UC_POLICY_SUFFIX = 'Policy';
|
|
59
69
|
export const UC_POLICY_SUFFIX_FULL = `UC${UC_POLICY_SUFFIX}`;
|
|
60
|
-
export const
|
|
61
|
-
|
|
70
|
+
export const UC_POLICY_FILE_NAME_SUFFIX = `${UC_POLICY_SUFFIX_FULL}.ts`;
|
|
71
|
+
/*
|
|
72
|
+
* Target
|
|
73
|
+
*/
|
|
74
|
+
export const PRODUCT_ROOT_FROM_PRODUCT_TARGET_PATH = [
|
|
75
|
+
// src/products/${ProductName}/targets/${target-name}
|
|
76
|
+
'..', // src/products/${ProductName}/targets
|
|
77
|
+
'..', // src/products/${ProductName}
|
|
78
|
+
];
|
|
79
|
+
export const APPS_PATH_FROM_PRODUCT_TARGET_PATH = [
|
|
80
|
+
...PRODUCT_ROOT_FROM_PRODUCT_TARGET_PATH,
|
|
81
|
+
'..', // src/products
|
|
82
|
+
'..', // src
|
|
83
|
+
APPS_ROOT_DIR_NAME, // src/apps
|
|
84
|
+
];
|
|
85
|
+
export const TARGET_NAME_PLACEHOLDER = 'node-express-server';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { I18nTranslation } from '../i18n/index.js';
|
|
2
2
|
import type { NumIndex } from './final/TNumIndex.js';
|
|
3
|
-
type ViolationConstraint = 'fieldsOr' | 'format' | 'mandatory' | 'max' | 'maxCount' | 'maxLength' | 'min' | 'minCount' | 'minLength' | 'oneOf' | 'shape' | 'type';
|
|
3
|
+
type ViolationConstraint = 'fieldsOr' | 'format' | 'mandatory' | 'max' | 'maxCount' | 'maxLength' | 'maxSize' | 'min' | 'minCount' | 'minLength' | 'minSize' | 'oneOf' | 'shape' | 'type';
|
|
4
4
|
type ViolationBase<C extends ViolationConstraint, EV> = {
|
|
5
5
|
constraint: C;
|
|
6
6
|
expected: EV;
|
|
7
7
|
};
|
|
8
8
|
export type ViolationFormat = 'ColorRGBA' | 'DateISO8601' | 'DirPath' | 'DomainName' | 'Email' | 'FilePath' | 'GitSSHURL' | 'IPv4' | 'IPv6' | 'JSON' | 'JWT' | 'PersonFirstname' | 'PersonFullname' | 'PersonInitials' | 'PersonLastname' | 'QRCode' | 'SemVerVersion' | 'Slug' | 'SSHPrivateKey' | 'SSHPublicKey' | 'Time' | 'URL' | 'UUID';
|
|
9
9
|
export type ViolationType = 'array' | 'boolean' | 'int' | 'number' | 'object' | 'scalar' | 'string';
|
|
10
|
-
export type Violation<T = unknown> = ViolationBase<'fieldsOr', string> | ViolationBase<'format', ViolationFormat> | ViolationBase<'format', string> | ViolationBase<'mandatory', undefined> | ViolationBase<'max', number> | ViolationBase<'maxCount', number> | ViolationBase<'maxLength', number> | ViolationBase<'min', number> | ViolationBase<'minCount', number> | ViolationBase<'minLength', number> | ViolationBase<'oneOf', T[]> | ViolationBase<'shape', object> | ViolationBase<'type', ViolationType>;
|
|
10
|
+
export type Violation<T = unknown> = ViolationBase<'fieldsOr', string> | ViolationBase<'format', ViolationFormat> | ViolationBase<'format', string> | ViolationBase<'mandatory', undefined> | ViolationBase<'max', number> | ViolationBase<'maxCount', number> | ViolationBase<'maxLength', number> | ViolationBase<'maxSize', string> | ViolationBase<'min', number> | ViolationBase<'minCount', number> | ViolationBase<'minLength', number> | ViolationBase<'minSize', string> | ViolationBase<'oneOf', T[]> | ViolationBase<'shape', object> | ViolationBase<'type', ViolationType>;
|
|
11
11
|
type ViolationI18nableSimple = Exclude<ViolationConstraint, 'format' | 'type'>;
|
|
12
12
|
export type ViolationI18nable = `validation_${ViolationI18nableSimple}` | `validation_format_${ViolationFormat}` | `validation_type_${ViolationType}`;
|
|
13
13
|
export type ViolationI18n = Record<ViolationI18nable, I18nTranslation>;
|
|
@@ -26,6 +26,7 @@ export interface OptionsOpts {
|
|
|
26
26
|
shouldTranslateLabels?: boolean;
|
|
27
27
|
strict?: boolean;
|
|
28
28
|
}
|
|
29
|
+
export type ConstraintsForHuman = Record<string, string>;
|
|
29
30
|
export declare abstract class TBase<T extends DataType> {
|
|
30
31
|
static DEFAULT_OPTIONS: Required<OptionsOpts>;
|
|
31
32
|
protected defaultValue: T | undefined;
|
|
@@ -44,6 +45,7 @@ export declare abstract class TBase<T extends DataType> {
|
|
|
44
45
|
fmt(ifNullOrUndefined?: string): string;
|
|
45
46
|
getDefaultValue(): T | undefined;
|
|
46
47
|
getExamples(): T[] | undefined;
|
|
48
|
+
getConstraintsForHuman(): ConstraintsForHuman | null;
|
|
47
49
|
getInitialValue(): T | undefined;
|
|
48
50
|
getOptions(): Option<T>[] | undefined;
|
|
49
51
|
getSemanticsMapping(): SemanticsMapping | undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { EnumOf } from '../../utils/index.js';
|
|
1
2
|
import type { Validation } from '../Validation.js';
|
|
2
3
|
import { TBase, type TName } from './TBase.js';
|
|
3
|
-
export declare
|
|
4
|
+
export declare const TObjectShapeValidationStrategy: {
|
|
4
5
|
/**
|
|
5
6
|
* No shape validation is performed
|
|
6
7
|
*
|
|
@@ -8,14 +9,15 @@ export declare enum TObjectShapeValidationStrategy {
|
|
|
8
9
|
*
|
|
9
10
|
* Otherwise, you can still override {@link validate} in the `T*` class and do your own validation.
|
|
10
11
|
*/
|
|
11
|
-
NONE
|
|
12
|
+
readonly NONE: "NONE";
|
|
12
13
|
/**
|
|
13
14
|
* Validate against the {@link TObject.example()}
|
|
14
15
|
*
|
|
15
16
|
* It checks that the keys of the value, sorted alphabetically, are the same as the example's keys.
|
|
16
17
|
*/
|
|
17
|
-
SAME_AS_EXAMPLE
|
|
18
|
-
}
|
|
18
|
+
readonly SAME_AS_EXAMPLE: "SAME_AS_EXAMPLE";
|
|
19
|
+
};
|
|
20
|
+
export type TObjectShapeValidationStrategy = EnumOf<typeof TObjectShapeValidationStrategy>;
|
|
19
21
|
export interface TObjectConstraints {
|
|
20
22
|
/**
|
|
21
23
|
* @defaultValue {@link TObjectShapeValidationStrategy.SAME_AS_EXAMPLE}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TBase } from './TBase.js';
|
|
2
|
-
export
|
|
3
|
-
(function (TObjectShapeValidationStrategy) {
|
|
2
|
+
export const TObjectShapeValidationStrategy = {
|
|
4
3
|
/**
|
|
5
4
|
* No shape validation is performed
|
|
6
5
|
*
|
|
@@ -8,14 +7,14 @@ export var TObjectShapeValidationStrategy;
|
|
|
8
7
|
*
|
|
9
8
|
* Otherwise, you can still override {@link validate} in the `T*` class and do your own validation.
|
|
10
9
|
*/
|
|
11
|
-
|
|
10
|
+
NONE: 'NONE',
|
|
12
11
|
/**
|
|
13
12
|
* Validate against the {@link TObject.example()}
|
|
14
13
|
*
|
|
15
14
|
* It checks that the keys of the value, sorted alphabetically, are the same as the example's keys.
|
|
16
15
|
*/
|
|
17
|
-
|
|
18
|
-
}
|
|
16
|
+
SAME_AS_EXAMPLE: 'SAME_AS_EXAMPLE',
|
|
17
|
+
};
|
|
19
18
|
export class TObject extends TBase {
|
|
20
19
|
constraints;
|
|
21
20
|
constructor(constraints = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Validation, ViolationFormat } from '../Validation.js';
|
|
2
|
-
import { TBase, type TName } from './TBase.js';
|
|
2
|
+
import { type ConstraintsForHuman, TBase, type TName } from './TBase.js';
|
|
3
3
|
export interface TStringConstraints<VF extends ViolationFormat | (string & {}) = ViolationFormat> {
|
|
4
4
|
format?: {
|
|
5
5
|
f: VF;
|
|
@@ -15,6 +15,7 @@ export declare class TString<T extends string = string, VF extends ViolationForm
|
|
|
15
15
|
constructor(constraints?: TStringConstraints<VF> | undefined);
|
|
16
16
|
tName(): TName;
|
|
17
17
|
example(): T;
|
|
18
|
+
getConstraintsForHuman(): ConstraintsForHuman | null;
|
|
18
19
|
getConstraints(): TStringConstraints<VF> | undefined;
|
|
19
20
|
isPotentiallyLong(): boolean;
|
|
20
21
|
protected removeFormatConstraint(): void;
|
|
@@ -13,6 +13,28 @@ export class TString extends TBase {
|
|
|
13
13
|
example() {
|
|
14
14
|
return 'Miami';
|
|
15
15
|
}
|
|
16
|
+
getConstraintsForHuman() {
|
|
17
|
+
if (!this.constraints) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const c = {};
|
|
21
|
+
const { format, maxLength, minLength } = this.constraints;
|
|
22
|
+
if (minLength) {
|
|
23
|
+
// biome-ignore lint/complexity/useLiteralKeys: typescript disagrees
|
|
24
|
+
c['minLength'] = minLength.toString();
|
|
25
|
+
}
|
|
26
|
+
if (maxLength) {
|
|
27
|
+
// biome-ignore lint/complexity/useLiteralKeys: typescript disagrees
|
|
28
|
+
c['maxLength'] = maxLength.toString();
|
|
29
|
+
}
|
|
30
|
+
if (format) {
|
|
31
|
+
// Are regexes really "human" ?
|
|
32
|
+
// TODO : Find a more human way of displaying regexes
|
|
33
|
+
// biome-ignore lint/complexity/useLiteralKeys: typescript disagrees
|
|
34
|
+
c['format'] = format.regexp.toString();
|
|
35
|
+
}
|
|
36
|
+
return c;
|
|
37
|
+
}
|
|
16
38
|
getConstraints() {
|
|
17
39
|
return this.constraints;
|
|
18
40
|
}
|
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
import type { TName } from '../base/TBase.js';
|
|
1
|
+
import type { ConstraintsForHuman, TName } from '../base/TBase.js';
|
|
2
2
|
import { TObject } from '../base/TObject.js';
|
|
3
3
|
import type { HTMLInputType } from '../targets/web.js';
|
|
4
4
|
import type { Validation } from '../Validation.js';
|
|
5
|
-
import { type FileMimeType
|
|
5
|
+
import { type FileMimeType } from './TFileMimeType.js';
|
|
6
6
|
import { type FileName } from './TFileName.js';
|
|
7
7
|
import { type FilePath } from './TFilePath.js';
|
|
8
|
+
import type { UIntQuantity } from './TUIntQuantity.js';
|
|
8
9
|
export type File = {
|
|
9
10
|
name: FileName;
|
|
10
|
-
|
|
11
|
+
size: UIntQuantity;
|
|
11
12
|
type: FileMimeType;
|
|
13
|
+
uri: FilePath;
|
|
12
14
|
};
|
|
13
15
|
export interface TFileConstraints {
|
|
14
|
-
|
|
16
|
+
accept: FileMimeType[];
|
|
17
|
+
maxSizeInBytes?: UIntQuantity;
|
|
18
|
+
minSizeInBytes?: UIntQuantity;
|
|
15
19
|
}
|
|
16
20
|
export declare class TFile extends TObject<File> {
|
|
17
21
|
protected fileConstraints: TFileConstraints;
|
|
22
|
+
static readonly UNITS: string[];
|
|
18
23
|
constructor(fileConstraints: TFileConstraints);
|
|
19
24
|
tName(): TName;
|
|
20
25
|
example(): File;
|
|
26
|
+
getConstraintsForHuman(): ConstraintsForHuman | null;
|
|
21
27
|
htmlInputType(): HTMLInputType;
|
|
22
28
|
validate(): Validation;
|
|
29
|
+
getFileConstraints(): TFileConstraints;
|
|
30
|
+
fmtBytes(bytes: number, decimals?: number): string;
|
|
31
|
+
withOneExample(name: File['name']): this;
|
|
23
32
|
}
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { TObject, TObjectShapeValidationStrategy } from '../base/TObject.js';
|
|
2
|
-
import { TFileMimeType
|
|
2
|
+
import { TFileMimeType } from './TFileMimeType.js';
|
|
3
3
|
import { TFileName } from './TFileName.js';
|
|
4
4
|
import { TFilePath } from './TFilePath.js';
|
|
5
5
|
export class TFile extends TObject {
|
|
6
6
|
fileConstraints;
|
|
7
|
+
// We consider them generic enough to not having to be translated
|
|
8
|
+
static UNITS = [
|
|
9
|
+
'B',
|
|
10
|
+
'KB',
|
|
11
|
+
'MB',
|
|
12
|
+
'GB',
|
|
13
|
+
'TB',
|
|
14
|
+
'PB',
|
|
15
|
+
'EB',
|
|
16
|
+
'ZB',
|
|
17
|
+
'YB',
|
|
18
|
+
];
|
|
7
19
|
constructor(fileConstraints) {
|
|
8
20
|
super({
|
|
9
21
|
// We usually process instances of https://developer.mozilla.org/fr/docs/Web/API/File
|
|
@@ -17,11 +29,27 @@ export class TFile extends TObject {
|
|
|
17
29
|
}
|
|
18
30
|
example() {
|
|
19
31
|
return {
|
|
20
|
-
name:
|
|
21
|
-
|
|
22
|
-
type:
|
|
32
|
+
name: TFilePath.FILE_NAME,
|
|
33
|
+
size: TFilePath.FILE_SIZE,
|
|
34
|
+
type: TFilePath.MIME_TYPE,
|
|
35
|
+
uri: `${TFilePath.ABS_PATH}/${TFilePath.FILE_NAME}`,
|
|
23
36
|
};
|
|
24
37
|
}
|
|
38
|
+
getConstraintsForHuman() {
|
|
39
|
+
const c = {};
|
|
40
|
+
const { accept, maxSizeInBytes, minSizeInBytes } = this.fileConstraints;
|
|
41
|
+
if (minSizeInBytes) {
|
|
42
|
+
// biome-ignore lint/complexity/useLiteralKeys: typescript disagrees
|
|
43
|
+
c['minSizeInBytes'] = this.fmtBytes(minSizeInBytes);
|
|
44
|
+
}
|
|
45
|
+
if (maxSizeInBytes) {
|
|
46
|
+
// biome-ignore lint/complexity/useLiteralKeys: typescript disagrees
|
|
47
|
+
c['maxSizeInBytes'] = this.fmtBytes(maxSizeInBytes);
|
|
48
|
+
}
|
|
49
|
+
// biome-ignore lint/complexity/useLiteralKeys: typescript disagrees
|
|
50
|
+
c['accept'] = accept.join(', ');
|
|
51
|
+
return c;
|
|
52
|
+
}
|
|
25
53
|
htmlInputType() {
|
|
26
54
|
return 'file';
|
|
27
55
|
}
|
|
@@ -32,13 +60,47 @@ export class TFile extends TObject {
|
|
|
32
60
|
}
|
|
33
61
|
const val = this.raw;
|
|
34
62
|
validation.concat(new TFileName().assign(val.name).validate());
|
|
63
|
+
const { accept, maxSizeInBytes, minSizeInBytes } = this.fileConstraints;
|
|
64
|
+
const { size, type, uri } = val;
|
|
35
65
|
if (!(val instanceof File)) {
|
|
36
|
-
validation.concat(new TFilePath().assign(
|
|
66
|
+
validation.concat(new TFilePath().assign(uri).validate());
|
|
37
67
|
}
|
|
38
|
-
validation.concat(new TFileMimeType(
|
|
39
|
-
.
|
|
68
|
+
validation.concat(new TFileMimeType()
|
|
69
|
+
.setOptions(accept.map((a) => ({ label: a, value: a })))
|
|
70
|
+
.assign(type)
|
|
40
71
|
.validate());
|
|
41
|
-
|
|
72
|
+
if (minSizeInBytes && size < minSizeInBytes) {
|
|
73
|
+
validation.add({
|
|
74
|
+
constraint: 'minSize',
|
|
75
|
+
expected: this.fmtBytes(minSizeInBytes),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (maxSizeInBytes && size > maxSizeInBytes) {
|
|
79
|
+
validation.add({
|
|
80
|
+
constraint: 'maxSize',
|
|
81
|
+
expected: this.fmtBytes(maxSizeInBytes),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
42
84
|
return validation;
|
|
43
85
|
}
|
|
86
|
+
getFileConstraints() {
|
|
87
|
+
return this.fileConstraints;
|
|
88
|
+
}
|
|
89
|
+
fmtBytes(bytes, decimals = 2) {
|
|
90
|
+
const k = 1024;
|
|
91
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
92
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
93
|
+
return `${Number.parseFloat((bytes / k ** i).toFixed(dm))} ${TFile.UNITS[i]}`;
|
|
94
|
+
}
|
|
95
|
+
withOneExample(name) {
|
|
96
|
+
this.setExamples([
|
|
97
|
+
{
|
|
98
|
+
name,
|
|
99
|
+
size: TFilePath.FILE_SIZE,
|
|
100
|
+
type: this.fileConstraints.accept[0] ?? TFilePath.MIME_TYPE,
|
|
101
|
+
uri: `${TFilePath.ABS_PATH}/${name}`,
|
|
102
|
+
},
|
|
103
|
+
]);
|
|
104
|
+
return this;
|
|
105
|
+
}
|
|
44
106
|
}
|
|
@@ -3,7 +3,7 @@ import { TString, type TStringConstraints } from '../base/TString.js';
|
|
|
3
3
|
type ImageExtension = 'gif' | 'heic' | 'jpg' | 'png';
|
|
4
4
|
type VideoExtension = 'mov' | 'mp4';
|
|
5
5
|
type XMLExtension = 'gpx' | 'xml';
|
|
6
|
-
export type FileExtension = ImageExtension | VideoExtension | XMLExtension;
|
|
6
|
+
export type FileExtension = ImageExtension | VideoExtension | XMLExtension | (string & {});
|
|
7
7
|
export interface TFileExtensionConstraints extends TStringConstraints {
|
|
8
8
|
allowed: FileExtension[];
|
|
9
9
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import type { TName } from '../base/TBase.js';
|
|
2
|
-
import { TString
|
|
3
|
-
export type FileMimeType = 'text/plain' | 'audio/aac' | 'application/x-abiword' | 'application/octet-stream' | 'video/x-msvideo' | 'application/vnd.amazon.ebook' | 'image/bmp' | 'application/x-bzip' | 'application/x-bzip2' | 'application/x-csh' | 'text/css' | 'text/csv' | 'application/msword' | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' | 'application/vnd.ms-fontobject' | 'application/epub+zip' | 'image/gif' | 'text/html' | 'image/x-icon' | 'text/calendar' | 'application/java-archive' | 'image/jpeg' | 'image/jpg' | 'application/javascript' | 'application/json' | 'audio/midi' | 'video/mpeg' | 'application/vnd.apple.installer+xml' | 'application/vnd.oasis.opendocument.presentation' | 'application/vnd.oasis.opendocument.spreadsheet' | 'application/vnd.oasis.opendocument.text' | 'audio/ogg' | 'video/ogg' | 'application/ogg' | 'font/otf' | 'image/png' | 'application/pdf' | 'application/vnd.ms-powerpoint' | 'application/vnd.openxmlformats-officedocument.presentationml.presentation' | 'application/x-rar-compressed' | 'application/rtf' | 'application/x-sh' | 'image/svg+xml' | 'application/x-shockwave-flash' | 'application/x-tar' | 'image/tiff' | 'application/typescript' | 'font/ttf' | 'application/vnd.visio' | 'audio/x-wav' | 'audio/webm' | 'video/webm' | 'image/webp' | 'font/woff' | 'font/woff2' | 'application/xhtml+xml' | 'application/vnd.ms-excel' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'application/xml' | 'application/vnd.mozilla.xul+xml' | 'application/zip' | 'video/3gpp audio/3gpp' | 'video/3gpp2 audio/3gpp2' | 'application/x-7z-compressed';
|
|
4
|
-
export interface TFileMimeTypeConstraints extends TStringConstraints {
|
|
5
|
-
allowed: FileMimeType[];
|
|
6
|
-
}
|
|
2
|
+
import { TString } from '../base/TString.js';
|
|
3
|
+
export type FileMimeType = 'text/plain' | 'audio/aac' | 'application/x-abiword' | 'application/octet-stream' | 'video/x-msvideo' | 'application/vnd.amazon.ebook' | 'image/bmp' | 'application/x-bzip' | 'application/x-bzip2' | 'application/x-csh' | 'text/css' | 'text/csv' | 'application/msword' | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' | 'application/vnd.ms-fontobject' | 'application/epub+zip' | 'image/gif' | 'text/html' | 'image/x-icon' | 'text/calendar' | 'application/java-archive' | 'image/jpeg' | 'image/jpg' | 'application/javascript' | 'application/json' | 'audio/midi' | 'video/mpeg' | 'application/vnd.apple.installer+xml' | 'application/vnd.oasis.opendocument.presentation' | 'application/vnd.oasis.opendocument.spreadsheet' | 'application/vnd.oasis.opendocument.text' | 'audio/ogg' | 'video/ogg' | 'application/ogg' | 'font/otf' | 'image/png' | 'application/pdf' | 'application/vnd.ms-powerpoint' | 'application/vnd.openxmlformats-officedocument.presentationml.presentation' | 'application/x-rar-compressed' | 'application/rtf' | 'application/x-sh' | 'image/svg+xml' | 'application/x-shockwave-flash' | 'application/x-tar' | 'image/tiff' | 'application/typescript' | 'font/ttf' | 'application/vnd.visio' | 'audio/x-wav' | 'audio/webm' | 'video/webm' | 'image/webp' | 'font/woff' | 'font/woff2' | 'application/xhtml+xml' | 'application/vnd.ms-excel' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'application/xml' | 'application/vnd.mozilla.xul+xml' | 'application/zip' | 'video/3gpp audio/3gpp' | 'video/3gpp2 audio/3gpp2' | 'application/x-7z-compressed' | (string & {});
|
|
7
4
|
export declare class TFileMimeType extends TString<FileMimeType> {
|
|
8
|
-
constructor(constraints?: TFileMimeTypeConstraints);
|
|
9
5
|
tName(): TName;
|
|
10
6
|
example(): FileMimeType;
|
|
11
7
|
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { TString } from '../base/TString.js';
|
|
2
2
|
export class TFileMimeType extends TString {
|
|
3
|
-
constructor(constraints) {
|
|
4
|
-
super(constraints);
|
|
5
|
-
if (constraints?.allowed) {
|
|
6
|
-
this.setOptions(constraints?.allowed.map((v) => ({ label: v, value: v })));
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
3
|
tName() {
|
|
10
4
|
return 'FileMimeType';
|
|
11
5
|
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import type { TName } from '../base/TBase.js';
|
|
2
2
|
import { TString, type TStringConstraints } from '../base/TString.js';
|
|
3
|
+
import type { FileMimeType } from './TFileMimeType.js';
|
|
4
|
+
import type { FileName } from './TFileName.js';
|
|
5
|
+
import type { UIntQuantity } from './TUIntQuantity.js';
|
|
3
6
|
export type FilePath = string;
|
|
4
7
|
export declare class TFilePath extends TString<FilePath> {
|
|
8
|
+
static readonly ABS_PATH: FilePath;
|
|
9
|
+
static readonly FILE_NAME: FileName;
|
|
10
|
+
static readonly FILE_SIZE: UIntQuantity;
|
|
11
|
+
static readonly MIME_TYPE: FileMimeType;
|
|
5
12
|
static readonly FORMAT: RegExp;
|
|
6
13
|
constructor(constraints?: TStringConstraints);
|
|
7
14
|
tName(): TName;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { TString } from '../base/TString.js';
|
|
2
2
|
export class TFilePath extends TString {
|
|
3
|
+
static ABS_PATH = '/Users/dexter/Desktop';
|
|
4
|
+
static FILE_NAME = 'picture.png';
|
|
5
|
+
static FILE_SIZE = 32;
|
|
6
|
+
static MIME_TYPE = 'image/png';
|
|
3
7
|
static FORMAT = /^[a-z0-9_/.][a-z0-9-_/.]+/i;
|
|
4
8
|
constructor(constraints) {
|
|
5
9
|
super({
|
|
@@ -11,6 +15,6 @@ export class TFilePath extends TString {
|
|
|
11
15
|
return 'FilePath';
|
|
12
16
|
}
|
|
13
17
|
example() {
|
|
14
|
-
return
|
|
18
|
+
return `${TFilePath.ABS_PATH}/${TFilePath.FILE_NAME}`;
|
|
15
19
|
}
|
|
16
20
|
}
|
package/dist/esm/dt/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export { type Emoji, TEmoji } from './final/TEmoji.js';
|
|
|
27
27
|
export { type EncryptionKey, TEncryptionKey } from './final/TEncryptionKey.js';
|
|
28
28
|
export { type ErrorMessage, TErrorMessage } from './final/TErrorMessage.js';
|
|
29
29
|
export { type ExternalServiceId, TExternalServiceId, } from './final/TExternalServiceId.js';
|
|
30
|
-
export { type File, TFile } from './final/TFile.js';
|
|
30
|
+
export { type File, TFile, type TFileConstraints } from './final/TFile.js';
|
|
31
31
|
export { type FileExtension, TFileExtension } from './final/TFileExtension.js';
|
|
32
32
|
export { type FileMimeType, TFileMimeType } from './final/TFileMimeType.js';
|
|
33
33
|
export { type FileName, TFileName } from './final/TFileName.js';
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type { ErrorMessage, HTTPStatusNumber } from '../dt/index.js';
|
|
2
|
+
export declare function isEmptyJSON(err: unknown): boolean;
|
|
3
|
+
export declare function isInvalidJSON(err: unknown): boolean;
|
|
2
4
|
export declare function throwCustomError(message: ErrorMessage, status: HTTPStatusNumber): never;
|
package/dist/esm/error/funcs.js
CHANGED
|
@@ -10,6 +10,26 @@ const ERROR_HTTP_STATUS_MAP = new Map([
|
|
|
10
10
|
[404, NotFoundError],
|
|
11
11
|
[500, InternalServerError],
|
|
12
12
|
]);
|
|
13
|
+
export function isEmptyJSON(err) {
|
|
14
|
+
return (err instanceof Error &&
|
|
15
|
+
err.message.toLowerCase().includes('unexpected end of json input'));
|
|
16
|
+
}
|
|
17
|
+
export function isInvalidJSON(err) {
|
|
18
|
+
if (!(err instanceof Error)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const message = err.message.toLowerCase();
|
|
22
|
+
// The usual JS error thrown by JSON.parse
|
|
23
|
+
if (message.includes('is not valid json')) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
// The error thrown by undici (used by hono for example)
|
|
27
|
+
// https://github.com/nodejs/undici/blob/ec4a84e13a9b86355b4d65a63a247524986386af/lib/web/fetch/body.js#L402
|
|
28
|
+
if (message.includes('content-type was not one of')) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
13
33
|
export function throwCustomError(message, status) {
|
|
14
34
|
const clazz = ERROR_HTTP_STATUS_MAP.get(status);
|
|
15
35
|
if (clazz) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { CustomError, type ServerError } from './CustomError.js';
|
|
2
2
|
export { ForbiddenAsNotFoundError } from './ForbiddenAsNotFoundError.js';
|
|
3
3
|
export { ForbiddenError } from './ForbiddenError.js';
|
|
4
|
-
export { throwCustomError } from './funcs.js';
|
|
4
|
+
export { isEmptyJSON, isInvalidJSON, throwCustomError } from './funcs.js';
|
|
5
5
|
export { IllegalArgumentError } from './IllegalArgumentError.js';
|
|
6
6
|
export { InternalServerError } from './InternalServerError.js';
|
|
7
7
|
export { NotAvailableError } from './internal/NotAvailableError.js';
|
package/dist/esm/error/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { CustomError } from './CustomError.js';
|
|
2
2
|
export { ForbiddenAsNotFoundError } from './ForbiddenAsNotFoundError.js';
|
|
3
3
|
export { ForbiddenError } from './ForbiddenError.js';
|
|
4
|
-
export { throwCustomError } from './funcs.js';
|
|
4
|
+
export { isEmptyJSON, isInvalidJSON, throwCustomError } from './funcs.js';
|
|
5
5
|
export { IllegalArgumentError } from './IllegalArgumentError.js';
|
|
6
6
|
export { InternalServerError } from './InternalServerError.js';
|
|
7
7
|
export { NotAvailableError } from './internal/NotAvailableError.js';
|
|
@@ -18,11 +18,12 @@ import type { UCClientConfirmConfig, UCDef, UCExecState, UCFieldKey, UCInput, UC
|
|
|
18
18
|
* One might argue that a label can be different for "name" in "CreateX" and "CreateY".
|
|
19
19
|
* In this case, we consider that the input field shouldn't be named "name" in both places.
|
|
20
20
|
*/
|
|
21
|
-
export type WordingManagerKey = `dt_${TName}_${string}_${keyof UCWording}` | `p_${keyof ProductWording}` | `uc_${UCName}_${keyof UCWording}` | `uc_${UCName}_client_confirm_${keyof UCClientConfirmConfig}` | `uc_${UCName}_i_submit_${UCExecState}` | `uc_${UCName}_op_${UCOutputPartIdx}_${keyof UCOutputPartWording}` | `ucif_${UCFieldKey}_${keyof UCWording}` | `ucof_${UCFieldKey}_${keyof UCWording}`;
|
|
21
|
+
export type WordingManagerKey = `dt_${TName}_constr_${string}` | `dt_${TName}_${string}_${keyof UCWording}` | `p_${keyof ProductWording}` | `uc_${UCName}_${keyof UCWording}` | `uc_${UCName}_client_confirm_${keyof UCClientConfirmConfig}` | `uc_${UCName}_i_submit_${UCExecState}` | `uc_${UCName}_op_${UCOutputPartIdx}_${keyof UCOutputPartWording}` | `ucif_${UCFieldKey}_${keyof UCWording}` | `ucof_${UCFieldKey}_${keyof UCWording}`;
|
|
22
22
|
export declare class WordingManager {
|
|
23
23
|
private i18nManager;
|
|
24
24
|
constructor(i18nManager: I18nManager);
|
|
25
25
|
dt<DT extends DataType>(type: TBase<DT>): UCWording;
|
|
26
|
+
dtConstr<DT extends DataType>(type: TBase<DT>): string[] | null;
|
|
26
27
|
p(): ProductWording;
|
|
27
28
|
uc<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(def: UCDef<I, OPI0, OPI1>): UCWording;
|
|
28
29
|
ucClientConfirm<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(def: UCDef<I, OPI0, OPI1>): UCClientConfirmConfig;
|
|
@@ -39,6 +39,24 @@ let WordingManager = class WordingManager {
|
|
|
39
39
|
}
|
|
40
40
|
return { desc, label };
|
|
41
41
|
}
|
|
42
|
+
dtConstr(type) {
|
|
43
|
+
const constraints = type.getConstraintsForHuman();
|
|
44
|
+
if (!constraints) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const entries = Object.entries(constraints);
|
|
48
|
+
if (entries.length === 0) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const parts = [];
|
|
52
|
+
for (const [k, v] of Object.entries(constraints)) {
|
|
53
|
+
parts.push(
|
|
54
|
+
// TODO : Consider moving up the type hierarchy to fetch the constr of the parent when missing
|
|
55
|
+
// e.g. TFreeTextShort > TString
|
|
56
|
+
this.t(`dt_${type.tName()}_constr_${k}`, undefined, v));
|
|
57
|
+
}
|
|
58
|
+
return parts;
|
|
59
|
+
}
|
|
42
60
|
p() {
|
|
43
61
|
return {
|
|
44
62
|
desc: this.tOrNull('p_desc'),
|
|
@@ -87,8 +105,11 @@ let WordingManager = class WordingManager {
|
|
|
87
105
|
label: this.tOrNull(`uc_${name}_op_${idx}_label`),
|
|
88
106
|
};
|
|
89
107
|
}
|
|
90
|
-
t(key, fallback = undefined) {
|
|
91
|
-
return this.i18nManager.t(key, {
|
|
108
|
+
t(key, fallback = undefined, expected = undefined) {
|
|
109
|
+
return this.i18nManager.t(key, {
|
|
110
|
+
fallback,
|
|
111
|
+
vars: expected ? { expected } : {},
|
|
112
|
+
});
|
|
92
113
|
}
|
|
93
114
|
tOr(key, fallbackKey) {
|
|
94
115
|
let val = this.tOrNull(key);
|