diff --git a/datex_short.ts b/datex_short.ts index 80be4be1..50978787 100644 --- a/datex_short.ts +++ b/datex_short.ts @@ -4,7 +4,7 @@ import { baseURL, Runtime, PrecompiledDXB, Type, Pointer, Ref, PointerProperty, primitive, any_class, Target, IdEndpoint, TransformFunctionInputs, AsyncTransformFunction, TransformFunction, TextRef, Markdown, DecimalRef, BooleanRef, IntegerRef, MinimalJSRef, RefOrValue, PartialRefOrValueObject, datex_meta, ObjectWithDatexValues, Compiler, endpoint_by_endpoint_name, endpoint_name, Storage, compiler_scope, datex_scope, DatexResponse, target_clause, ValueError, logger, Class, getUnknownMeta, Endpoint, INSERT_MARK, CollapsedValueAdvanced, CollapsedValue, SmartTransformFunction, compiler_options, activePlugins, METADATA, handleDecoratorArgs, RefOrValueObject, PointerPropertyParent, InferredPointerProperty, RefLike } from "./datex_all.ts"; /** make decorators global */ -import { validate as _validate, property as _property, sync as _sync, endpoint as _endpoint, template as _template, jsdoc as _jsdoc} from "./datex_all.ts"; +import { assert as _assert, property as _property, sync as _sync, endpoint as _endpoint, template as _template, jsdoc as _jsdoc} from "./datex_all.ts"; import { effect as _effect, always as _always, toggle as _toggle, map as _map, equals as _equals, selectProperty as _selectProperty, not as _not } from "./functions.ts"; export * from "./functions.ts"; import { NOT_EXISTING, DX_SLOTS, SLOT_GET, SLOT_SET } from "./runtime/constants.ts"; @@ -17,7 +17,7 @@ export {instance} from "./js_adapter/js_class_adapter.ts"; declare global { const property: typeof _property; - const validate: typeof _validate; + const assert: typeof _assert; const jsdoc: typeof _jsdoc; const sync: typeof _sync; @@ -40,7 +40,7 @@ declare global { // @ts-ignore global globalThis.property = _property; // @ts-ignore global -globalThis.validate = _validate; +globalThis.assert = _assert; // @ts-ignore global globalThis.sync = _sync; @@ -71,8 +71,13 @@ export async function get(dx:string|URL|Endpoint, assert_type?:Type escape - if (dx.toString().startsWith('blob:http://') || dx.toString().startsWith('blob:https://')) dx = `url '${dx}'`; + // escape relative paths + if (typeof dx == "string" && (dx.startsWith('./') || dx.startsWith('../'))) { + dx = new URL(dx, context_location).toString(); + } + + // escape urls + if (dx.toString().startsWith('http://') || dx.toString().startsWith('https://') || dx.toString().startsWith('file://') || dx.toString().startsWith('blob:http://') || dx.toString().startsWith('blob:https://')) dx = `url '${dx}'`; const res = await _datex('get (' + dx + ' )', undefined, undefined, undefined, undefined, context_location, plugins); if (plugins) activePlugins.splice(0, activePlugins.length); diff --git a/deno.lock b/deno.lock deleted file mode 100644 index 6163cc7f..00000000 --- a/deno.lock +++ /dev/null @@ -1,230 +0,0 @@ -{ - "version": "3", - "redirects": { - "https://deno.land/std/async/mod.ts": "https://deno.land/std@0.204.0/async/mod.ts" - }, - "remote": { - "https://cdn.unyt.org/datex-core-js-legacy/compiler/binary_codes.ts": "e04ac5aea360036675c81127146e92d200fca75ae8f8dc53a3d40ca80f5fa31b", - "https://cdn.unyt.org/datex-core-js-legacy/compiler/compiler.ts": "0c9d8417e7aa9ea010e9bf97ff7bfa73d9eb078cb3fc417a45a499beb8e65171", - "https://cdn.unyt.org/datex-core-js-legacy/compiler/protocol_types.ts": "98114be167ae672773d6176b6014e1710838d6bcb81a3686c1525e95e18fb815", - "https://cdn.unyt.org/datex-core-js-legacy/compiler/tokens_regex.ts": "632e87ca07cc0d56cfa8a2a9b77248a296c775f04c6b235060407adbdcc343ee", - "https://cdn.unyt.org/datex-core-js-legacy/compiler/unit_codes.ts": "0da02d162eed5583c30130eea7d3f013bc09e1c5e274d1b3c41566cb71ef22a1", - "https://cdn.unyt.org/datex-core-js-legacy/datex.js": "ef365a06fe1b5565a57be6acb5d3c5921d389aed584a3d9fdb72c92f2466706b", - "https://cdn.unyt.org/datex-core-js-legacy/datex_all.ts": "9438e875f40a9700e125dc1dbd4a8061e7b2219d97ecaf3e2f474c9d80a9d5fb", - "https://cdn.unyt.org/datex-core-js-legacy/datex_short.ts": "c212909a53dd0232399639846481243b6dd6133a0ebf09e2daa89b6ac7d072d2", - "https://cdn.unyt.org/datex-core-js-legacy/functions.ts": "55baddf426899a31fcc3a6455cfd8831c8fef439a95ca8d68a0965534b87b1fe", - "https://cdn.unyt.org/datex-core-js-legacy/init.ts": "6475bd5a66975fa63652bda105281dea6888fe7c23b85194fbe137d4b494f35c", - "https://cdn.unyt.org/datex-core-js-legacy/js_adapter/js_class_adapter.ts": "d14ce1cb52999532cbceb8c2284f5407c157e69c71fffa0dc9542bbc186268e5", - "https://cdn.unyt.org/datex-core-js-legacy/js_adapter/legacy_decorators.ts": "9b0e3c18be2e47349f315e27e49ae18b3a9d107f7a19f8b911f698cf3d4ac0a6", - "https://cdn.unyt.org/datex-core-js-legacy/lib/localforage/drivers/indexeddb.js": "94a6cfe0f3bfbe677bae59127c991405d68c4c54ae4d3dbbdb56072a471ece02", - "https://cdn.unyt.org/datex-core-js-legacy/lib/localforage/drivers/localstorage.js": "62f07f7063c3ff385f307b0cf84f8daf10e3896b623e720c39ee5daab68863d1", - "https://cdn.unyt.org/datex-core-js-legacy/lib/localforage/drivers/websql.js": "5c69bdff0af1cbc3103feb76964490817e221091dc3ae573c8f9a94a78437609", - "https://cdn.unyt.org/datex-core-js-legacy/lib/localforage/localforage.js": "8bde4fb43ce0bfe34b9f7b7362be63a9674628192718af25b7eabfc2ba7da385", - "https://cdn.unyt.org/datex-core-js-legacy/lib/localforage/utils/createBlob.js": "14dd379f079966554b93c6982f6a57b6334d39d500d14592a90a25f057ffb1a0", - "https://cdn.unyt.org/datex-core-js-legacy/lib/localforage/utils/executeCallback.js": "385bde0bcbeb7bb0916a18f9fa13e087bef6e8c73322c6cea921a7d2a9faaf76", - "https://cdn.unyt.org/datex-core-js-legacy/lib/localforage/utils/executeTwoCallbacks.js": "0ab6f19a2645c8af6657c55faba1760de0510706d5f0ad7c433a9a28a8f22b8b", - "https://cdn.unyt.org/datex-core-js-legacy/lib/localforage/utils/getCallback.js": "7c6d36433132aa416fce88915f004fa4a5520a70bb6c3cc775b1da9373bba25b", - "https://cdn.unyt.org/datex-core-js-legacy/lib/localforage/utils/idb.js": "1e7f31e75cab1bd86f475db87faa3b469b07b24503d60840a4902b7b4c38f768", - "https://cdn.unyt.org/datex-core-js-legacy/lib/localforage/utils/includes.js": "6a2598464f6b0ada6d9442b86c6339aa307a155b9be15eaea38c5d343da8c5ce", - "https://cdn.unyt.org/datex-core-js-legacy/lib/localforage/utils/isArray.js": "33b7af80a36b73e20fb8464e91d4a398477d4ea47a7f8f077dafd99e53d647fb", - "https://cdn.unyt.org/datex-core-js-legacy/lib/localforage/utils/isIndexedDBValid.js": "758336bc6f5630f74b2c902de4f56f0bed015d71369e0d67bd4fbf480607cd57", - "https://cdn.unyt.org/datex-core-js-legacy/lib/localforage/utils/isLocalStorageValid.js": "64e1fa95986ff2dc2aa66b6f064ac72bc06cc56fa28d3c3dd0ea18cc5aa0df7c", - "https://cdn.unyt.org/datex-core-js-legacy/lib/localforage/utils/isWebSQLValid.js": "a2cb2bc344ad4fc3d9bd66e59b03765d15e5695896be5ef43ddf7c00c8005090", - "https://cdn.unyt.org/datex-core-js-legacy/lib/localforage/utils/normalizeKey.js": "57ed80a6f574511682e1575ebcb8cfe57652bddb36252642372168312d054082", - "https://cdn.unyt.org/datex-core-js-legacy/lib/localforage/utils/promise.js": "553a6e73bfe59e43390c7f88514574d4284eef5e34ce7cdbf93c3d9c6347c559", - "https://cdn.unyt.org/datex-core-js-legacy/lib/localforage/utils/serializer.js": "5960c40deb26d81ca4841c9fe829a5305ea09bfd3d9deb6c1d74875934923b03", - "https://cdn.unyt.org/datex-core-js-legacy/lib/marked.js": "0a1fa6c8bbe5f691c8d5bed2041fdfb9e22494bd3caca2cbc076cb142c19b014", - "https://cdn.unyt.org/datex-core-js-legacy/mod.ts": "446c7e5f0ab17fb04b93f125d0b619be9de1796e236dd5380c3089655a844d88", - "https://cdn.unyt.org/datex-core-js-legacy/network/blockchain_adapter.ts": "0e1bb55b27a76b8d607895b143936a9cb193a7a7876c71ffeffc73cb337a1fec", - "https://cdn.unyt.org/datex-core-js-legacy/network/client.ts": "eb47457b18b200a0a0f48614ddb6a047d96f6e9aae1f60f83ab2eb7c0b876aa0", - "https://cdn.unyt.org/datex-core-js-legacy/network/network_utils.ts": "531615aa700a8d10e0bfaa3c8f79c247f98e69add0005a2898c532ae3d0a57d2", - "https://cdn.unyt.org/datex-core-js-legacy/network/supranet.ts": "1d452cf863da9e4842d566fbabe72585fb89f3ce629941a94a50922da94b5728", - "https://cdn.unyt.org/datex-core-js-legacy/network/unyt.ts": "3c3a4fd80e5b5942aef084bf655c2307b0f7a3459fd5ec045e567991dcaf2241", - "https://cdn.unyt.org/datex-core-js-legacy/runtime/cache_path.ts": "9ddd39ac5fe6b45e71189a4aad31b928a29552fc01134c4dca618001fe8d8d6e", - "https://cdn.unyt.org/datex-core-js-legacy/runtime/cli.ts": "a4811ce51a337057420b590d80c943d38c42a5a086198029ae40bfc850b2fbdc", - "https://cdn.unyt.org/datex-core-js-legacy/runtime/constants.ts": "53e50418488d5305bf72b53810b6300577eb6a81ccf674df9755bd1ea01cc449", - "https://cdn.unyt.org/datex-core-js-legacy/runtime/crypto.ts": "251ccd119eea32a6829570b3364615374699b3f9a697edefc3d95fa239057e11", - "https://cdn.unyt.org/datex-core-js-legacy/runtime/debugger.ts": "ad1b12229b5d8749107e12a5b6c157b4d65e675e53c3182dc4c01cee75efe9b7", - "https://cdn.unyt.org/datex-core-js-legacy/runtime/display.ts": "702a521c6c810f6fd4b4ea8a3c0040dcc7b9beff9b4665085b7f6218081175a6", - "https://cdn.unyt.org/datex-core-js-legacy/runtime/endpoint_config.ts": "48d5d104ba8c4105ef2fe4db3e8e45efe9bb8c04b5ebc56b64bea8617139fda1", - "https://cdn.unyt.org/datex-core-js-legacy/runtime/io_handler.ts": "fae478283b6475f69e4e9c5c995848c5c1baae2c4e2146d6e92bc0cbb294c856", - "https://cdn.unyt.org/datex-core-js-legacy/runtime/js_interface.ts": "eeccc5b72e08716b1e9892c93802a35ba0b57d8b10c11f786c0f61733ef5be23", - "https://cdn.unyt.org/datex-core-js-legacy/runtime/performance_measure.ts": "ec6a72315c9e0924abbb9c9667edd1dfc28245d8b2b743332a8f0997f2fc6b4d", - "https://cdn.unyt.org/datex-core-js-legacy/runtime/pointers.ts": "b18b19ebf76d18f5bd2a71cda3c5ce2dc49e384b7f7332626c7cbb778f667c7d", - "https://cdn.unyt.org/datex-core-js-legacy/runtime/runtime.ts": "d8302a6c4866902d74691bb8b28601267d32a1933acee859c9ab86dfb9259a51", - "https://cdn.unyt.org/datex-core-js-legacy/runtime/storage-locations/deno-kv.ts": "5abbe3fb17f75db41a53c9f07ac4584df48791082b148d96a36570b69aeadbe2", - "https://cdn.unyt.org/datex-core-js-legacy/runtime/storage-locations/indexed-db.ts": "1fe42f765cc82caf3964c1b59b8a80e9be6ecf3ee82bae0780abe93201ffd032", - "https://cdn.unyt.org/datex-core-js-legacy/runtime/storage-locations/local-storage-compat.ts": "a435e9cf6573be000ae5b439b4647cd4df513a99affcdc99473ca5128d1a24fc", - "https://cdn.unyt.org/datex-core-js-legacy/runtime/storage-locations/local-storage.ts": "a10dede8a0a03a4c3eec00004b2ff8b4c9e93fb0e8ca7407dece98c3975b3daf", - "https://cdn.unyt.org/datex-core-js-legacy/runtime/storage.ts": "9b81082eaa8b585f85f850504fd985f1a89eca6c45fb7e888623199cd8280faf", - "https://cdn.unyt.org/datex-core-js-legacy/types/abstract_types.ts": "04ad3192b3b0973fdf28f730dd6f16feb63b6d9ea0963e280d035889d8abb0c8", - "https://cdn.unyt.org/datex-core-js-legacy/types/addressing.ts": "35e907068406076a7e50a84d91e33a083e591417bb6f09327fe94228f012174a", - "https://cdn.unyt.org/datex-core-js-legacy/types/assertion.ts": "30a0586706572de284ceb6ae1677c1ba5a9990cd96b91ae62f139a20d912be74", - "https://cdn.unyt.org/datex-core-js-legacy/types/deferred.ts": "eb308e59468c7ca5bd3179e4aa86b5c73d7c4de60d1d656a6c244e3414e61e0d", - "https://cdn.unyt.org/datex-core-js-legacy/types/error_codes.ts": "e4c8c23a07a5e71c70a6c2769de73f45547a4086152155b84ac080699bfb02ea", - "https://cdn.unyt.org/datex-core-js-legacy/types/errors.ts": "4ce39c0543f5a43d8060a1c1090679e289349238d385e61bb06badbd1c43b547", - "https://cdn.unyt.org/datex-core-js-legacy/types/function-utils.ts": "771feefa6dcc8edc68d24f26fbe1c2e0e23390f7d57e2d35fe455c839b532d59", - "https://cdn.unyt.org/datex-core-js-legacy/types/function.ts": "ee51bf618abd05c0e6e591a1a06c4877bb9f97df2197eee0e9695d200b86edd2", - "https://cdn.unyt.org/datex-core-js-legacy/types/iterator.ts": "645a2ce155fa6dbbe3465a12e8c8871dffdc062f7261762ebf85896cfcdd3a73", - "https://cdn.unyt.org/datex-core-js-legacy/types/js-function.ts": "d08945e1d8d3651e8c2761c20c172770bb04cc949fe31dc49a6cc16fb5919ee3", - "https://cdn.unyt.org/datex-core-js-legacy/types/logic.ts": "71b3694d8ad0e11c18db174ff9c957b3116cd160b3932f406324225b4ad5132d", - "https://cdn.unyt.org/datex-core-js-legacy/types/markdown.ts": "7c762ad0c64eea3495f13371551424d971cc3d98eba09464f07f5ac3c1417fb6", - "https://cdn.unyt.org/datex-core-js-legacy/types/native_types.ts": "9eb58533bb989964d28b6191ef33af05956fed01519b30cbec1ae913593cdcb7", - "https://cdn.unyt.org/datex-core-js-legacy/types/object.ts": "9711f523ae51ebf53f992837e921dbe7b572f4150a1379a6ac6d0b240ed978dd", - "https://cdn.unyt.org/datex-core-js-legacy/types/quantity.ts": "f2ca8f563964d85a0cd7cd0b7fa060e974da10f697ea4273e6e4f7f3182d8043", - "https://cdn.unyt.org/datex-core-js-legacy/types/scope.ts": "edd3dcd28f0948e704fea143e771e2a1fa2b3db0756b72224f93c8fdfd1f2256", - "https://cdn.unyt.org/datex-core-js-legacy/types/storage_map.ts": "7aebc4149d2e278e44ed3f87e0f4e07d9043e11c462d390b0f8ca39f1fa42162", - "https://cdn.unyt.org/datex-core-js-legacy/types/storage_set.ts": "81c968810a43066b62b0e8a942c5dba8e0e0c268d4c9cf62bbb358f394a951dc", - "https://cdn.unyt.org/datex-core-js-legacy/types/stream.ts": "c3f324979ebc4bf29c9e071c75364bb109f30782d2267b2702b4e7b8a559fc9b", - "https://cdn.unyt.org/datex-core-js-legacy/types/struct.ts": "1009e377570b57a8d0dc51ca98c562694c55d83b42636cb80ff96f30bfcf1649", - "https://cdn.unyt.org/datex-core-js-legacy/types/task.ts": "b5073e9682ca9cb93b44646e0fbe7896f96cd369d151a94d2d11728e5d7e2da9", - "https://cdn.unyt.org/datex-core-js-legacy/types/time.ts": "4ea90eafedad768e43dc6f8cdc20018fb2264fc19e6bf58bc1aecf35766d6e61", - "https://cdn.unyt.org/datex-core-js-legacy/types/tuple.ts": "798c635102d46f4c29903f82fb50cd1f6c0449eb0090654ae08e59e9ae98a80e", - "https://cdn.unyt.org/datex-core-js-legacy/types/type.ts": "b1fb387d89a59c07d66ee1fe2be86298dce7d33f4b77eba0c36c9ccc9de78780", - "https://cdn.unyt.org/datex-core-js-legacy/utils/_command_line_options.ts": "b6ac395803c34fc69c59a853769d44770bda4da6bad6904ae65fbdca6ccbe308", - "https://cdn.unyt.org/datex-core-js-legacy/utils/ansi_compat.ts": "d220d4387c98d6bb1fb2422b7e40f5bbdcfcf7f198f087460ab27712020baed8", - "https://cdn.unyt.org/datex-core-js-legacy/utils/args.ts": "f752ba2a61bcd463f79c032d3245a7f286809063d4b8dbd98e1f95a34bb86345", - "https://cdn.unyt.org/datex-core-js-legacy/utils/auto_map.ts": "44fca794249889ecb52ae183d5deed19b4bb66268ceafc4563a0de035524f1e8", - "https://cdn.unyt.org/datex-core-js-legacy/utils/caller_metadata.ts": "57f79bff64cfb24749cdebec41230a416a32e8d0e80c319096e653778e7a5fde", - "https://cdn.unyt.org/datex-core-js-legacy/utils/constants.ts": "a7992c1dbb4d28a22c52d02281564f0236508217cc1b7a035ff0e95988fa83cb", - "https://cdn.unyt.org/datex-core-js-legacy/utils/eternals.ts": "843bb0e9d4de9b2ce61eaa28e96e9438191facafbc5b097dffded673ab195d4e", - "https://cdn.unyt.org/datex-core-js-legacy/utils/global_types.ts": "f6abfda31cbfb146e6e6933fddb57f9bfc3e1c70367127d886f33c59a0e33523", - "https://cdn.unyt.org/datex-core-js-legacy/utils/global_values.ts": "993b8381932936a9c90fb2ab3705e0ed2a929dc5db0f3d85988c296c69998f3c", - "https://cdn.unyt.org/datex-core-js-legacy/utils/iterable-handler.ts": "27450a6e1caccf5933c18928018ff130ee7a8b70c7b66074720f402d3a494e26", - "https://cdn.unyt.org/datex-core-js-legacy/utils/local_files.ts": "f81613b5aecc4d4b1fbf6884d3acb7785cb656d72fe9e6cf81dbe3f0c8264993", - "https://cdn.unyt.org/datex-core-js-legacy/utils/logger.ts": "dcee1cd28fbe455716b5ab688e18c1264f79e932c8edfddb0a8e0793f22d0165", - "https://cdn.unyt.org/datex-core-js-legacy/utils/message_logger.ts": "bc6b683739a7c0c7d2be948a644dfba69296410bdf7229afc71b652c10877696", - "https://cdn.unyt.org/datex-core-js-legacy/utils/normalize-path.ts": "1f3fea7a349600fec02ea434fd18ef34476e59f977c09a00146702e71e92d342", - "https://cdn.unyt.org/datex-core-js-legacy/utils/observers.ts": "df82f2dfbc0189d7f3f6d1f21461ac4a329a6dbbd7ec1bd72d3cd2f5afada9a6", - "https://cdn.unyt.org/datex-core-js-legacy/utils/polyfills.ts": "1f47a967c5813e8a465ca985af8a5867884f8aadd8d763d361b548121fbc6ccf", - "https://cdn.unyt.org/datex-core-js-legacy/utils/promises.ts": "b43d38724a2fd42d1d0a3cc479bc21f7a75ccee872f680c46f50e99839e17803", - "https://cdn.unyt.org/datex-core-js-legacy/utils/sha256.ts": "268f78d135706b3dbd342b6bff674abe423bc486b31c4497055070a55d2919a2", - "https://cdn.unyt.org/datex-core-js-legacy/utils/utils.ts": "86fe78e869c00d17f88a38dbe1f22a7d0197ac981c77dd635d3950dfc5a41337", - "https://cdn.unyt.org/datex-core-js-legacy/wasm/adapter/pkg/datex_wasm.js": "e9416983fb275de1cd28849c3cb85ba3d3be05032e9246c73fe217e7a2d422c5", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/compiler/binary_codes.ts": "e04ac5aea360036675c81127146e92d200fca75ae8f8dc53a3d40ca80f5fa31b", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/compiler/compiler.ts": "0c9d8417e7aa9ea010e9bf97ff7bfa73d9eb078cb3fc417a45a499beb8e65171", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/compiler/protocol_types.ts": "98114be167ae672773d6176b6014e1710838d6bcb81a3686c1525e95e18fb815", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/compiler/tokens_regex.ts": "632e87ca07cc0d56cfa8a2a9b77248a296c775f04c6b235060407adbdcc343ee", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/compiler/unit_codes.ts": "0da02d162eed5583c30130eea7d3f013bc09e1c5e274d1b3c41566cb71ef22a1", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/datex.ts": "71bb6d0b4d50df4678bc156480f58cf0b65389199ab24d8c4d6aabfb1e2e2b2f", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/datex_all.ts": "9438e875f40a9700e125dc1dbd4a8061e7b2219d97ecaf3e2f474c9d80a9d5fb", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/datex_short.ts": "c212909a53dd0232399639846481243b6dd6133a0ebf09e2daa89b6ac7d072d2", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/functions.ts": "55baddf426899a31fcc3a6455cfd8831c8fef439a95ca8d68a0965534b87b1fe", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/init.ts": "6475bd5a66975fa63652bda105281dea6888fe7c23b85194fbe137d4b494f35c", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/js_adapter/js_class_adapter.ts": "d14ce1cb52999532cbceb8c2284f5407c157e69c71fffa0dc9542bbc186268e5", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/js_adapter/legacy_decorators.ts": "9b0e3c18be2e47349f315e27e49ae18b3a9d107f7a19f8b911f698cf3d4ac0a6", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/lib/localforage/drivers/indexeddb.js": "94a6cfe0f3bfbe677bae59127c991405d68c4c54ae4d3dbbdb56072a471ece02", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/lib/localforage/drivers/localstorage.js": "62f07f7063c3ff385f307b0cf84f8daf10e3896b623e720c39ee5daab68863d1", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/lib/localforage/drivers/websql.js": "5c69bdff0af1cbc3103feb76964490817e221091dc3ae573c8f9a94a78437609", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/lib/localforage/localforage.js": "8bde4fb43ce0bfe34b9f7b7362be63a9674628192718af25b7eabfc2ba7da385", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/lib/localforage/utils/createBlob.js": "14dd379f079966554b93c6982f6a57b6334d39d500d14592a90a25f057ffb1a0", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/lib/localforage/utils/executeCallback.js": "385bde0bcbeb7bb0916a18f9fa13e087bef6e8c73322c6cea921a7d2a9faaf76", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/lib/localforage/utils/executeTwoCallbacks.js": "0ab6f19a2645c8af6657c55faba1760de0510706d5f0ad7c433a9a28a8f22b8b", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/lib/localforage/utils/getCallback.js": "7c6d36433132aa416fce88915f004fa4a5520a70bb6c3cc775b1da9373bba25b", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/lib/localforage/utils/idb.js": "1e7f31e75cab1bd86f475db87faa3b469b07b24503d60840a4902b7b4c38f768", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/lib/localforage/utils/includes.js": "6a2598464f6b0ada6d9442b86c6339aa307a155b9be15eaea38c5d343da8c5ce", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/lib/localforage/utils/isArray.js": "33b7af80a36b73e20fb8464e91d4a398477d4ea47a7f8f077dafd99e53d647fb", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/lib/localforage/utils/isIndexedDBValid.js": "758336bc6f5630f74b2c902de4f56f0bed015d71369e0d67bd4fbf480607cd57", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/lib/localforage/utils/isLocalStorageValid.js": "64e1fa95986ff2dc2aa66b6f064ac72bc06cc56fa28d3c3dd0ea18cc5aa0df7c", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/lib/localforage/utils/isWebSQLValid.js": "a2cb2bc344ad4fc3d9bd66e59b03765d15e5695896be5ef43ddf7c00c8005090", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/lib/localforage/utils/normalizeKey.js": "57ed80a6f574511682e1575ebcb8cfe57652bddb36252642372168312d054082", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/lib/localforage/utils/promise.js": "553a6e73bfe59e43390c7f88514574d4284eef5e34ce7cdbf93c3d9c6347c559", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/lib/localforage/utils/serializer.js": "5960c40deb26d81ca4841c9fe829a5305ea09bfd3d9deb6c1d74875934923b03", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/lib/marked.js": "0a1fa6c8bbe5f691c8d5bed2041fdfb9e22494bd3caca2cbc076cb142c19b014", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/mod.ts": "446c7e5f0ab17fb04b93f125d0b619be9de1796e236dd5380c3089655a844d88", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/network/blockchain_adapter.ts": "0e1bb55b27a76b8d607895b143936a9cb193a7a7876c71ffeffc73cb337a1fec", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/network/client.ts": "eb47457b18b200a0a0f48614ddb6a047d96f6e9aae1f60f83ab2eb7c0b876aa0", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/network/network_utils.ts": "531615aa700a8d10e0bfaa3c8f79c247f98e69add0005a2898c532ae3d0a57d2", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/network/supranet.ts": "1d452cf863da9e4842d566fbabe72585fb89f3ce629941a94a50922da94b5728", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/network/unyt.ts": "3c3a4fd80e5b5942aef084bf655c2307b0f7a3459fd5ec045e567991dcaf2241", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/runtime/cache_path.ts": "9ddd39ac5fe6b45e71189a4aad31b928a29552fc01134c4dca618001fe8d8d6e", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/runtime/cli.ts": "a4811ce51a337057420b590d80c943d38c42a5a086198029ae40bfc850b2fbdc", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/runtime/constants.ts": "53e50418488d5305bf72b53810b6300577eb6a81ccf674df9755bd1ea01cc449", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/runtime/crypto.ts": "251ccd119eea32a6829570b3364615374699b3f9a697edefc3d95fa239057e11", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/runtime/debugger.ts": "ad1b12229b5d8749107e12a5b6c157b4d65e675e53c3182dc4c01cee75efe9b7", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/runtime/display.ts": "702a521c6c810f6fd4b4ea8a3c0040dcc7b9beff9b4665085b7f6218081175a6", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/runtime/endpoint_config.ts": "48d5d104ba8c4105ef2fe4db3e8e45efe9bb8c04b5ebc56b64bea8617139fda1", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/runtime/io_handler.ts": "fae478283b6475f69e4e9c5c995848c5c1baae2c4e2146d6e92bc0cbb294c856", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/runtime/js_interface.ts": "eeccc5b72e08716b1e9892c93802a35ba0b57d8b10c11f786c0f61733ef5be23", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/runtime/performance_measure.ts": "ec6a72315c9e0924abbb9c9667edd1dfc28245d8b2b743332a8f0997f2fc6b4d", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/runtime/pointers.ts": "b18b19ebf76d18f5bd2a71cda3c5ce2dc49e384b7f7332626c7cbb778f667c7d", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/runtime/runtime.ts": "d8302a6c4866902d74691bb8b28601267d32a1933acee859c9ab86dfb9259a51", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/runtime/storage-locations/deno-kv.ts": "5abbe3fb17f75db41a53c9f07ac4584df48791082b148d96a36570b69aeadbe2", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/runtime/storage-locations/indexed-db.ts": "1fe42f765cc82caf3964c1b59b8a80e9be6ecf3ee82bae0780abe93201ffd032", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/runtime/storage-locations/local-storage-compat.ts": "a435e9cf6573be000ae5b439b4647cd4df513a99affcdc99473ca5128d1a24fc", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/runtime/storage-locations/local-storage.ts": "a10dede8a0a03a4c3eec00004b2ff8b4c9e93fb0e8ca7407dece98c3975b3daf", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/runtime/storage.ts": "9b81082eaa8b585f85f850504fd985f1a89eca6c45fb7e888623199cd8280faf", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/abstract_types.ts": "04ad3192b3b0973fdf28f730dd6f16feb63b6d9ea0963e280d035889d8abb0c8", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/addressing.ts": "35e907068406076a7e50a84d91e33a083e591417bb6f09327fe94228f012174a", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/assertion.ts": "30a0586706572de284ceb6ae1677c1ba5a9990cd96b91ae62f139a20d912be74", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/deferred.ts": "eb308e59468c7ca5bd3179e4aa86b5c73d7c4de60d1d656a6c244e3414e61e0d", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/error_codes.ts": "e4c8c23a07a5e71c70a6c2769de73f45547a4086152155b84ac080699bfb02ea", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/errors.ts": "4ce39c0543f5a43d8060a1c1090679e289349238d385e61bb06badbd1c43b547", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/function-utils.ts": "771feefa6dcc8edc68d24f26fbe1c2e0e23390f7d57e2d35fe455c839b532d59", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/function.ts": "ee51bf618abd05c0e6e591a1a06c4877bb9f97df2197eee0e9695d200b86edd2", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/iterator.ts": "645a2ce155fa6dbbe3465a12e8c8871dffdc062f7261762ebf85896cfcdd3a73", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/js-function.ts": "d08945e1d8d3651e8c2761c20c172770bb04cc949fe31dc49a6cc16fb5919ee3", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/logic.ts": "71b3694d8ad0e11c18db174ff9c957b3116cd160b3932f406324225b4ad5132d", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/markdown.ts": "7c762ad0c64eea3495f13371551424d971cc3d98eba09464f07f5ac3c1417fb6", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/native_types.ts": "9eb58533bb989964d28b6191ef33af05956fed01519b30cbec1ae913593cdcb7", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/object.ts": "9711f523ae51ebf53f992837e921dbe7b572f4150a1379a6ac6d0b240ed978dd", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/quantity.ts": "f2ca8f563964d85a0cd7cd0b7fa060e974da10f697ea4273e6e4f7f3182d8043", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/scope.ts": "edd3dcd28f0948e704fea143e771e2a1fa2b3db0756b72224f93c8fdfd1f2256", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/storage_map.ts": "7aebc4149d2e278e44ed3f87e0f4e07d9043e11c462d390b0f8ca39f1fa42162", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/storage_set.ts": "81c968810a43066b62b0e8a942c5dba8e0e0c268d4c9cf62bbb358f394a951dc", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/stream.ts": "c3f324979ebc4bf29c9e071c75364bb109f30782d2267b2702b4e7b8a559fc9b", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/struct.ts": "1009e377570b57a8d0dc51ca98c562694c55d83b42636cb80ff96f30bfcf1649", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/task.ts": "b5073e9682ca9cb93b44646e0fbe7896f96cd369d151a94d2d11728e5d7e2da9", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/time.ts": "4ea90eafedad768e43dc6f8cdc20018fb2264fc19e6bf58bc1aecf35766d6e61", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/tuple.ts": "798c635102d46f4c29903f82fb50cd1f6c0449eb0090654ae08e59e9ae98a80e", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/types/type.ts": "b1fb387d89a59c07d66ee1fe2be86298dce7d33f4b77eba0c36c9ccc9de78780", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/_command_line_options.ts": "b6ac395803c34fc69c59a853769d44770bda4da6bad6904ae65fbdca6ccbe308", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/ansi_compat.ts": "d220d4387c98d6bb1fb2422b7e40f5bbdcfcf7f198f087460ab27712020baed8", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/args.ts": "f752ba2a61bcd463f79c032d3245a7f286809063d4b8dbd98e1f95a34bb86345", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/auto_map.ts": "44fca794249889ecb52ae183d5deed19b4bb66268ceafc4563a0de035524f1e8", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/caller_metadata.ts": "57f79bff64cfb24749cdebec41230a416a32e8d0e80c319096e653778e7a5fde", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/constants.ts": "a7992c1dbb4d28a22c52d02281564f0236508217cc1b7a035ff0e95988fa83cb", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/eternals.ts": "843bb0e9d4de9b2ce61eaa28e96e9438191facafbc5b097dffded673ab195d4e", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/global_types.ts": "f6abfda31cbfb146e6e6933fddb57f9bfc3e1c70367127d886f33c59a0e33523", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/global_values.ts": "993b8381932936a9c90fb2ab3705e0ed2a929dc5db0f3d85988c296c69998f3c", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/iterable-handler.ts": "27450a6e1caccf5933c18928018ff130ee7a8b70c7b66074720f402d3a494e26", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/local_files.ts": "f81613b5aecc4d4b1fbf6884d3acb7785cb656d72fe9e6cf81dbe3f0c8264993", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/logger.ts": "dcee1cd28fbe455716b5ab688e18c1264f79e932c8edfddb0a8e0793f22d0165", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/message_logger.ts": "bc6b683739a7c0c7d2be948a644dfba69296410bdf7229afc71b652c10877696", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/normalize-path.ts": "1f3fea7a349600fec02ea434fd18ef34476e59f977c09a00146702e71e92d342", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/observers.ts": "df82f2dfbc0189d7f3f6d1f21461ac4a329a6dbbd7ec1bd72d3cd2f5afada9a6", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/polyfills.ts": "1f47a967c5813e8a465ca985af8a5867884f8aadd8d763d361b548121fbc6ccf", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/promises.ts": "b43d38724a2fd42d1d0a3cc479bc21f7a75ccee872f680c46f50e99839e17803", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/sha256.ts": "268f78d135706b3dbd342b6bff674abe423bc486b31c4497055070a55d2919a2", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/utils/utils.ts": "86fe78e869c00d17f88a38dbe1f22a7d0197ac981c77dd635d3950dfc5a41337", - "https://cdn.unyt.org/datex-core-js-legacy@0.0.x/wasm/adapter/pkg/datex_wasm.js": "e9416983fb275de1cd28849c3cb85ba3d3be05032e9246c73fe217e7a2d422c5", - "https://deno.land/std@0.168.0/_util/asserts.ts": "d0844e9b62510f89ce1f9878b046f6a57bf88f208a10304aab50efcb48365272", - "https://deno.land/std@0.168.0/flags/mod.ts": "4f50ec6383c02684db35de38b3ffb2cd5b9fcfcc0b1147055d1980c49e82521c", - "https://deno.land/std@0.204.0/assert/assert.ts": "9a97dad6d98c238938e7540736b826440ad8c1c1e54430ca4c4e623e585607ee", - "https://deno.land/std@0.204.0/assert/assertion_error.ts": "4d0bde9b374dfbcbe8ac23f54f567b77024fb67dbb1906a852d67fe050d42f56", - "https://deno.land/std@0.204.0/async/abortable.ts": "fd682fa46f3b7b16b4606a5ab52a7ce309434b76f820d3221bdfb862719a15d7", - "https://deno.land/std@0.204.0/async/deadline.ts": "58f72a3cc0fcb731b2cc055ba046f4b5be3349ff6bf98f2e793c3b969354aab2", - "https://deno.land/std@0.204.0/async/debounce.ts": "adab11d04ca38d699444ac8a9d9856b4155e8dda2afd07ce78276c01ea5a4332", - "https://deno.land/std@0.204.0/async/deferred.ts": "42790112f36a75a57db4a96d33974a936deb7b04d25c6084a9fa8a49f135def8", - "https://deno.land/std@0.204.0/async/delay.ts": "a6142eb44cdd856b645086af2b811b1fcce08ec06bb7d50969e6a872ee9b8659", - "https://deno.land/std@0.204.0/async/mod.ts": "f04344fa21738e5ad6bea37a6bfffd57c617c2d372bb9f9dcfd118a1b622e576", - "https://deno.land/std@0.204.0/async/mux_async_iterator.ts": "70c7f2ee4e9466161350473ad61cac0b9f115cff4c552eaa7ef9d50c4cbb4cc9", - "https://deno.land/std@0.204.0/async/pool.ts": "47c1841cfa9c036144943d11747ddd44064f5baf8cb7ece25473ba873c6aceb0", - "https://deno.land/std@0.204.0/async/retry.ts": "296fb9c323e1325a69bee14ba947e7da7409a8dd9dd646d70cb51ea0d301f24e", - "https://deno.land/std@0.204.0/async/tee.ts": "47e42d35f622650b02234d43803d0383a89eb4387e1b83b5a40106d18ae36757", - "https://deno.land/x/caller_metadata@v0.0.3/src/main.ts": "2258e7eb41a54ac9a99058f40a487c6313232feafcb5f02f22d51fe6b526dd73", - "https://deno.land/x/input@2.0.3/history.ts": "3cad3fee1e2f86d4202ca6ab49f1a5609aff2323ff762cc637e1da3edbef9608", - "https://deno.land/x/input@2.0.3/index.ts": "f9539661733886f9497873a640a79be4f996ea2d40408b68e74691353f5a5539", - "https://deno.land/x/input@2.0.3/printer.ts": "60339de0f3d98ca9ad2cb4e3b047d0b680e27ed7ceb987d82d96fc00f7ab04d1", - "https://deno.land/x/input@2.0.3/types.ts": "915079a7187073c9c9c99863ab4e4a4c7341e25bf5d4a2e02c33f8b896dd0c69", - "https://deno.land/x/mimetypes@v1.0.0/mod.ts": "abd1ea614b32cfa7fd50b46f6e070617696664698b8a34935dc807f3035ad408", - "https://deno.land/x/mimetypes@v1.0.0/src/mime.ts": "7cd7590eae6127dc1abfe710900fc749e94d5c715ffe8a148e59fe20ee21a9a5", - "https://deno.land/x/reflect_metadata@v0.1.12/Reflect.ts": "eced7b7e642853c6fb9a209f96ddd1932ab1e0fc3c514705c87d56169c8fe260", - "https://deno.land/x/reflect_metadata@v0.1.12/mod.ts": "8b5e3b20f1e604c118df433e84a409b1d5116e885001047134cc42ecf84fa2cd", - "https://dev.cdn.unyt.org/command-line-args/ansi.ts": "945dfe165cba067b9cc0035c454dc4991c8af826404573938848f84f79a97ba5", - "https://dev.cdn.unyt.org/command-line-args/generators/cli-generator.ts": "39a570056a82da1ba983057b317d9baae7a0a4b715bd6738c977ea6f1991512b", - "https://dev.cdn.unyt.org/command-line-args/generators/markdown-generator.ts": "47a39eede55a20f1431634525786b58ae93f4df0e751de301de5d0c35bfdc72f", - "https://dev.cdn.unyt.org/command-line-args/main.ts": "60d51cc63b7c18a116d8db0479da16df5a17fee233dedcf7ebc75f90f5722fc2", - "https://dev.cdn.unyt.org/command-line-args/types.ts": "f1bd9b69321731bcb5e53d26e895a9310b8c82ca821364545a0f9336463d6bc8" - } -} diff --git a/js_adapter/js_class_adapter.ts b/js_adapter/js_class_adapter.ts index c3b5ebe8..931ce4aa 100644 --- a/js_adapter/js_class_adapter.ts +++ b/js_adapter/js_class_adapter.ts @@ -325,11 +325,11 @@ export class Decorators { } - /** @validate: add type assertion function */ - static validate(value:any, name:context_name, kind:context_kind, is_static:boolean, is_private:boolean, setMetadata:context_meta_setter, getMetadata:context_meta_getter, params:[((value:any)=>boolean)?] = []) { - if (kind != "field" && kind != "getter" && kind != "setter" && kind != "method") logger.error("Invalid use of @validate decorator"); + /** @assert: add type assertion function */ + static assert(value:any, name:context_name, kind:context_kind, is_static:boolean, is_private:boolean, setMetadata:context_meta_setter, getMetadata:context_meta_getter, params:[((value:any)=>boolean)?] = []) { + if (kind != "field" && kind != "getter" && kind != "setter" && kind != "method") logger.error("Invalid use of @assert decorator"); else { - if (typeof params[0] !== "function") logger.error("Invalid @validate decorator value, must be a function"); + if (typeof params[0] !== "function") logger.error("Invalid @assert decorator value, must be a function"); else { const assertionType = new Conjunction(Assertion.get(undefined, params[0], false)); setMetadata(Decorators.FORCE_TYPE, assertionType) diff --git a/js_adapter/legacy_decorators.ts b/js_adapter/legacy_decorators.ts index 6f23f9ff..4e0d2755 100644 --- a/js_adapter/legacy_decorators.ts +++ b/js_adapter/legacy_decorators.ts @@ -291,9 +291,9 @@ export function type(...args:any[]): any { return handleDecoratorArgs(args, Decorators.type); } -export function validate(assertion:(val:any)=>boolean):any -export function validate(...args:any[]): any { - return handleDecoratorArgs(args, Decorators.validate, true); +export function assert(assertion:(val:any)=>boolean|string|undefined|null):any +export function assert(...args:any[]): any { + return handleDecoratorArgs(args, Decorators.assert, true); } diff --git a/network/communication-interface.ts b/network/communication-interface.ts new file mode 100644 index 00000000..9c1c4eae --- /dev/null +++ b/network/communication-interface.ts @@ -0,0 +1,6 @@ +/** + * Base class for all DATEX communication interfaces + */ +export abstract class CommunicationInterface { + //TODO: +} \ No newline at end of file diff --git a/runtime/pointers.ts b/runtime/pointers.ts index bb4acf48..4919637a 100644 --- a/runtime/pointers.ts +++ b/runtime/pointers.ts @@ -3051,9 +3051,7 @@ export class Pointer extends Ref { if (typeof value == "number" && this.type.getAllowedPropertyType(key).root_type == Type.std.integer) value = BigInt(value); // invalid type for value? - if (!this.type.isPropertyValueAllowed(key, value)) { - throw new ValueError("Property '" + key + "' must be of type " + this.type.getAllowedPropertyType(key)); - } + this.type.assertPropertyValueAllowed(key, value) this.initShadowObjectProperty(key, value); @@ -3082,9 +3080,7 @@ export class Pointer extends Ref { if (typeof value == "number" && this.type.getAllowedPropertyType(key).root_type == Type.std.integer) value = BigInt(value); // invalid type for value? - if (!this.type.isPropertyValueAllowed(key, value)) { - throw new ValueError("Property '" + key + "' must be of type " + this.type.getAllowedPropertyType(key)); - } + this.type.assertPropertyValueAllowed(key, value) // get current value const current_value = this.getProperty(key); diff --git a/runtime/runtime.ts b/runtime/runtime.ts index ddfb6b3d..b3648527 100644 --- a/runtime/runtime.ts +++ b/runtime/runtime.ts @@ -3516,8 +3516,8 @@ export class Runtime { const type = Type.ofValue(parent); if (type.template && !type.isPropertyAllowed(key)) throw new ValueError("Property '" + key + "' does not exist"); - if (type.template && !type.isPropertyValueAllowed(key, value)) throw new ValueError("Property '" + key + "' must be of type " + type.getAllowedPropertyType(key)); - + if (type.template) type.assertPropertyValueAllowed(key, value) + // check sealed tuple if (parent instanceof Tuple && !parent.has(key)) throw new ValueError("Property '"+key.toString()+"' does not exist in ", SCOPE) diff --git a/types/assertion.ts b/types/assertion.ts index 8cbeedd2..db01e5cf 100644 --- a/types/assertion.ts +++ b/types/assertion.ts @@ -35,7 +35,7 @@ export class Assertion extends ExtensibleFunction implements ValueConsume } - assert(value:T|Tuple, SCOPE?:datex_scope, return_boolean:B = false): B extends true ? boolean|Promise : void|Promise { + assert(value:T|Tuple, SCOPE?:datex_scope, return_boolean = false): boolean|Promise { // ntarget if (this.ntarget) { if (this.ntarget_async) return this.checkResultPromise(>this.ntarget(...(value instanceof Tuple ? value.toArray() : (value instanceof Array ? value : [value]))), return_boolean) @@ -53,7 +53,7 @@ export class Assertion extends ExtensibleFunction implements ValueConsume return this.checkResult(await valid_promise, return_boolean); } - private checkResult(valid:string|boolean|undefined, return_boolean = false) { + private checkResult(valid:string|boolean|undefined, return_boolean = false):boolean { if (return_boolean) return valid === true || valid === VOID if (valid !== true && valid !== VOID) { @@ -61,6 +61,7 @@ export class Assertion extends ExtensibleFunction implements ValueConsume else if (typeof valid == "string") throw new AssertionError(valid); else throw new ValueError("Invalid assertion result - must be of type , , or ") } + return true; } handleApply(value: T|Tuple, SCOPE?: datex_scope) { diff --git a/types/logic.ts b/types/logic.ts index 6029bd5d..13dd178b 100644 --- a/types/logic.ts +++ b/types/logic.ts @@ -61,7 +61,7 @@ export class Logical extends Set { // value clause matches against other clause // if no atomic_class is provided, the first value clause literal is used to determine a atomic class - public static matches(value:clause, against:clause, atomic_class?:Class&LogicalComparator, assertionValue = value): boolean { + public static matches(value:clause, against:clause, atomic_class?:Class&LogicalComparator, assertionValue = value, throwInvalidAssertion = false): boolean { // TODO: empty - does not match? if (against === undefined) return false; @@ -84,7 +84,7 @@ export class Logical extends Set { if (value.size == 0) return true; for (const p of value) { - if (!(this.matches(p, against, atomic_class))) return false; + if (!(this.matches(p, against, atomic_class, assertionValue, throwInvalidAssertion))) return false; } return true; } @@ -94,13 +94,13 @@ export class Logical extends Set { if (value.size == 0) return true; for (const p of value) { - if (this.matches(p, against, atomic_class)) return true; + if (this.matches(p, against, atomic_class, assertionValue, throwInvalidAssertion)) return true; } return false; } // not if (value instanceof Negation) { - return !this.matches(value.not(), against, atomic_class) + return !this.matches(value.not(), against, atomic_class, assertionValue, throwInvalidAssertion) } // assertion @@ -111,11 +111,11 @@ export class Logical extends Set { } // default - return this.matchesSingle(Ref.collapseValue(value, true, true), against, atomic_class, assertionValue); + return this.matchesSingle(Ref.collapseValue(value, true, true), against, atomic_class, assertionValue, throwInvalidAssertion); } - private static matchesSingle(atomic_value:T, against: clause, atomic_class:Class&LogicalComparator, assertionValue = atomic_value): boolean { + private static matchesSingle(atomic_value:T, against: clause, atomic_class:Class&LogicalComparator, assertionValue = atomic_value, throwInvalidAssertion = false): boolean { atomic_value = Datex.Ref.collapseValue(atomic_value, true, true); against = > Datex.Ref.collapseValue(against, true, true); @@ -128,25 +128,25 @@ export class Logical extends Set { // TODO:empty disjunction == any? if (against.size == 0) return true; for (const t of against) { - if (this.matchesSingle(atomic_value, t, atomic_class, assertionValue)) return true; // any type matches + if (this.matchesSingle(atomic_value, t, atomic_class, assertionValue, throwInvalidAssertion)) return true; // any type matches } return false; } // and if (against instanceof Conjunction) { for (const t of against) { - if (!this.matchesSingle(atomic_value, t, atomic_class, assertionValue)) return false; // any type does not match + if (!this.matchesSingle(atomic_value, t, atomic_class, assertionValue, throwInvalidAssertion)) return false; // any type does not match } return true; } // not if (against instanceof Negation) { - return !this.matchesSingle(atomic_value, against.not(), atomic_class, assertionValue) + return !this.matchesSingle(atomic_value, against.not(), atomic_class, assertionValue, throwInvalidAssertion) } // assertion if (against instanceof Assertion) { - const res = against.assert(assertionValue, undefined, true); + const res = against.assert(assertionValue, undefined, !throwInvalidAssertion); if (res instanceof Promise) throw new RuntimeError("async assertion cannot be evaluated in logical connective"); return res } diff --git a/types/type.ts b/types/type.ts index 1a999f93..03259595 100644 --- a/types/type.ts +++ b/types/type.ts @@ -402,12 +402,21 @@ export class Type extends ExtensibleFunction { } // match type against template + /** + * @deprecated, use assertPropertyValueAllowed + */ public isPropertyValueAllowed(property:any, value:any) { if (!this.#template) return true; else if (typeof property !== "string") return true; // only strings handled by templates else return (!this.#template[property] || Type.matches(value, this.#template[property])) // check if value allowed } + public assertPropertyValueAllowed(property:any, value:any) { + if (!this.#template) return true; + else if (typeof property !== "string") return true; // only strings handled by templates + else if (this.#template[property]) Type.assertMatches(value, this.#template[property]) // assert value allowed + } + // get type for value in template public getAllowedPropertyType(property:any):Type { if (!this.#template) return Type.std.Any; @@ -640,8 +649,8 @@ export class Type extends ExtensibleFunction { // type check (type is a subtype of matches_type) // TODO: swap arguments - public static matchesType(type:type_clause, against: type_clause, assertionValue?:any) { - return Logical.matches(type, against, Type, assertionValue); + public static matchesType(type:type_clause, against: type_clause, assertionValue?:any, throwInvalidAssertion = false) { + return Logical.matches(type, against, Type, assertionValue, throwInvalidAssertion); } @@ -656,6 +665,11 @@ export class Type extends ExtensibleFunction { } } + public static assertMatches(value:RefOrValue, type:type_clause): asserts value is (T extends Type ? TT : any) { + const res = Type.matchesType(Type.ofValue(value), type, value, true); + if (!res) throw new ValueError("Value must be of type " + type) + } + // check if root type of value matches exactly public static matches(value:RefOrValue, type:type_clause): value is (T extends Type ? TT : any) { value = Ref.collapseValue(value, true, true);