@cratis/fundamentals 7.16.8 → 7.17.1
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/ConceptAs.ts +3 -0
- package/DateOnly.ts +112 -0
- package/Guid.ts +3 -0
- package/JsonSerializer.ts +99 -39
- package/TimeOnly.ts +108 -0
- package/TimeSpan.ts +4 -0
- package/ValueMap.ts +3 -0
- package/dist/ConceptAs.d.ts +2 -0
- package/dist/ConceptAs.d.ts.map +1 -1
- package/dist/ConceptAs.js +2 -0
- package/dist/ConceptAs.js.map +1 -1
- package/dist/DateOnly.d.ts +14 -0
- package/dist/DateOnly.d.ts.map +1 -0
- package/dist/DateOnly.js +51 -0
- package/dist/DateOnly.js.map +1 -0
- package/dist/Guid.d.ts +2 -0
- package/dist/Guid.d.ts.map +1 -1
- package/dist/Guid.js +2 -0
- package/dist/Guid.js.map +1 -1
- package/dist/JsonSerializer.d.ts +2 -0
- package/dist/JsonSerializer.d.ts.map +1 -1
- package/dist/JsonSerializer.js +42 -35
- package/dist/JsonSerializer.js.map +1 -1
- package/dist/TimeOnly.d.ts +13 -0
- package/dist/TimeOnly.d.ts.map +1 -0
- package/dist/TimeOnly.js +58 -0
- package/dist/TimeOnly.js.map +1 -0
- package/dist/TimeSpan.d.ts +2 -0
- package/dist/TimeSpan.d.ts.map +1 -1
- package/dist/TimeSpan.js +2 -0
- package/dist/TimeSpan.js.map +1 -1
- package/dist/ValueMap.d.ts +2 -0
- package/dist/ValueMap.d.ts.map +1 -1
- package/dist/ValueMap.js +2 -0
- package/dist/ValueMap.js.map +1 -1
- package/dist/cjs/ConceptAs.d.ts +2 -0
- package/dist/cjs/ConceptAs.d.ts.map +1 -1
- package/dist/cjs/ConceptAs.js +3 -0
- package/dist/cjs/ConceptAs.js.map +1 -1
- package/dist/cjs/DateOnly.d.ts +14 -0
- package/dist/cjs/DateOnly.d.ts.map +1 -0
- package/dist/cjs/DateOnly.js +56 -0
- package/dist/cjs/DateOnly.js.map +1 -0
- package/dist/cjs/Guid.d.ts +2 -0
- package/dist/cjs/Guid.d.ts.map +1 -1
- package/dist/cjs/Guid.js +3 -0
- package/dist/cjs/Guid.js.map +1 -1
- package/dist/cjs/JsonSerializer.d.ts +2 -0
- package/dist/cjs/JsonSerializer.d.ts.map +1 -1
- package/dist/cjs/JsonSerializer.js +43 -34
- package/dist/cjs/JsonSerializer.js.map +1 -1
- package/dist/cjs/TimeOnly.d.ts +13 -0
- package/dist/cjs/TimeOnly.d.ts.map +1 -0
- package/dist/cjs/TimeOnly.js +63 -0
- package/dist/cjs/TimeOnly.js.map +1 -0
- package/dist/cjs/TimeSpan.d.ts +2 -0
- package/dist/cjs/TimeSpan.d.ts.map +1 -1
- package/dist/cjs/TimeSpan.js +2 -0
- package/dist/cjs/TimeSpan.js.map +1 -1
- package/dist/cjs/ValueMap.d.ts +2 -0
- package/dist/cjs/ValueMap.d.ts.map +1 -1
- package/dist/cjs/ValueMap.js +3 -0
- package/dist/cjs/ValueMap.js.map +1 -1
- package/dist/cjs/duplicateInstanceGuard.d.ts +2 -0
- package/dist/cjs/duplicateInstanceGuard.d.ts.map +1 -0
- package/dist/cjs/duplicateInstanceGuard.js +53 -0
- package/dist/cjs/duplicateInstanceGuard.js.map +1 -0
- package/dist/cjs/geospatial/LineString.d.ts +2 -0
- package/dist/cjs/geospatial/LineString.d.ts.map +1 -1
- package/dist/cjs/geospatial/LineString.js +3 -0
- package/dist/cjs/geospatial/LineString.js.map +1 -1
- package/dist/cjs/geospatial/Point.d.ts +2 -0
- package/dist/cjs/geospatial/Point.d.ts.map +1 -1
- package/dist/cjs/geospatial/Point.js +2 -0
- package/dist/cjs/geospatial/Point.js.map +1 -1
- package/dist/cjs/geospatial/Polygon.d.ts +2 -0
- package/dist/cjs/geospatial/Polygon.d.ts.map +1 -1
- package/dist/cjs/geospatial/Polygon.js +3 -0
- package/dist/cjs/geospatial/Polygon.js.map +1 -1
- package/dist/cjs/geospatial/index.js +14 -0
- package/dist/cjs/geospatial/index.js.map +1 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +14 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/json/DateOnlyJsonConverter.d.ts +9 -0
- package/dist/cjs/json/DateOnlyJsonConverter.d.ts.map +1 -0
- package/dist/cjs/json/DateOnlyJsonConverter.js +19 -0
- package/dist/cjs/json/DateOnlyJsonConverter.js.map +1 -0
- package/dist/cjs/json/JsonConverter.d.ts.map +1 -1
- package/dist/cjs/json/JsonConverter.js.map +1 -1
- package/dist/cjs/json/TimeOnlyJsonConverter.d.ts +9 -0
- package/dist/cjs/json/TimeOnlyJsonConverter.d.ts.map +1 -0
- package/dist/cjs/json/TimeOnlyJsonConverter.js +19 -0
- package/dist/cjs/json/TimeOnlyJsonConverter.js.map +1 -0
- package/dist/cjs/json/index.d.ts +2 -0
- package/dist/cjs/json/index.d.ts.map +1 -1
- package/dist/cjs/json/index.js +26 -0
- package/dist/cjs/json/index.js.map +1 -0
- package/dist/cjs/typeKey.d.ts +7 -0
- package/dist/cjs/typeKey.d.ts.map +1 -0
- package/dist/cjs/typeKey.js +14 -0
- package/dist/cjs/typeKey.js.map +1 -0
- package/dist/duplicateInstanceGuard.d.ts +2 -0
- package/dist/duplicateInstanceGuard.d.ts.map +1 -0
- package/dist/duplicateInstanceGuard.js +49 -0
- package/dist/duplicateInstanceGuard.js.map +1 -0
- package/dist/esm/ConceptAs.d.ts +2 -0
- package/dist/esm/ConceptAs.d.ts.map +1 -1
- package/dist/esm/ConceptAs.js +3 -0
- package/dist/esm/ConceptAs.js.map +1 -1
- package/dist/esm/DateOnly.d.ts +14 -0
- package/dist/esm/DateOnly.d.ts.map +1 -0
- package/dist/esm/DateOnly.js +54 -0
- package/dist/esm/DateOnly.js.map +1 -0
- package/dist/esm/Guid.d.ts +2 -0
- package/dist/esm/Guid.d.ts.map +1 -1
- package/dist/esm/Guid.js +3 -0
- package/dist/esm/Guid.js.map +1 -1
- package/dist/esm/JsonSerializer.d.ts +2 -0
- package/dist/esm/JsonSerializer.d.ts.map +1 -1
- package/dist/esm/JsonSerializer.js +43 -34
- package/dist/esm/JsonSerializer.js.map +1 -1
- package/dist/esm/TimeOnly.d.ts +13 -0
- package/dist/esm/TimeOnly.d.ts.map +1 -0
- package/dist/esm/TimeOnly.js +61 -0
- package/dist/esm/TimeOnly.js.map +1 -0
- package/dist/esm/TimeSpan.d.ts +2 -0
- package/dist/esm/TimeSpan.d.ts.map +1 -1
- package/dist/esm/TimeSpan.js +2 -0
- package/dist/esm/TimeSpan.js.map +1 -1
- package/dist/esm/ValueMap.d.ts +2 -0
- package/dist/esm/ValueMap.d.ts.map +1 -1
- package/dist/esm/ValueMap.js +3 -0
- package/dist/esm/ValueMap.js.map +1 -1
- package/dist/esm/duplicateInstanceGuard.d.ts +2 -0
- package/dist/esm/duplicateInstanceGuard.d.ts.map +1 -0
- package/dist/esm/duplicateInstanceGuard.js +51 -0
- package/dist/esm/duplicateInstanceGuard.js.map +1 -0
- package/dist/esm/geospatial/LineString.d.ts +2 -0
- package/dist/esm/geospatial/LineString.d.ts.map +1 -1
- package/dist/esm/geospatial/LineString.js +3 -0
- package/dist/esm/geospatial/LineString.js.map +1 -1
- package/dist/esm/geospatial/Point.d.ts +2 -0
- package/dist/esm/geospatial/Point.d.ts.map +1 -1
- package/dist/esm/geospatial/Point.js +2 -0
- package/dist/esm/geospatial/Point.js.map +1 -1
- package/dist/esm/geospatial/Polygon.d.ts +2 -0
- package/dist/esm/geospatial/Polygon.d.ts.map +1 -1
- package/dist/esm/geospatial/Polygon.js +3 -0
- package/dist/esm/geospatial/Polygon.js.map +1 -1
- package/dist/esm/geospatial/index.js +5 -0
- package/dist/esm/geospatial/index.js.map +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/json/DateOnlyJsonConverter.d.ts +9 -0
- package/dist/esm/json/DateOnlyJsonConverter.d.ts.map +1 -0
- package/dist/esm/json/DateOnlyJsonConverter.js +17 -0
- package/dist/esm/json/DateOnlyJsonConverter.js.map +1 -0
- package/dist/esm/json/JsonConverter.d.ts.map +1 -1
- package/dist/esm/json/JsonConverter.js.map +1 -1
- package/dist/esm/json/TimeOnlyJsonConverter.d.ts +9 -0
- package/dist/esm/json/TimeOnlyJsonConverter.d.ts.map +1 -0
- package/dist/esm/json/TimeOnlyJsonConverter.js +17 -0
- package/dist/esm/json/TimeOnlyJsonConverter.js.map +1 -0
- package/dist/esm/json/index.d.ts +2 -0
- package/dist/esm/json/index.d.ts.map +1 -1
- package/dist/esm/json/index.js +11 -0
- package/dist/esm/json/index.js.map +1 -0
- package/dist/esm/typeKey.d.ts +7 -0
- package/dist/esm/typeKey.d.ts.map +1 -0
- package/dist/esm/typeKey.js +8 -0
- package/dist/esm/typeKey.js.map +1 -0
- package/dist/geospatial/LineString.d.ts +2 -0
- package/dist/geospatial/LineString.d.ts.map +1 -1
- package/dist/geospatial/LineString.js +2 -0
- package/dist/geospatial/LineString.js.map +1 -1
- package/dist/geospatial/Point.d.ts +2 -0
- package/dist/geospatial/Point.d.ts.map +1 -1
- package/dist/geospatial/Point.js +2 -0
- package/dist/geospatial/Point.js.map +1 -1
- package/dist/geospatial/Polygon.d.ts +2 -0
- package/dist/geospatial/Polygon.d.ts.map +1 -1
- package/dist/geospatial/Polygon.js +2 -0
- package/dist/geospatial/Polygon.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/json/DateOnlyJsonConverter.d.ts +9 -0
- package/dist/json/DateOnlyJsonConverter.d.ts.map +1 -0
- package/dist/json/DateOnlyJsonConverter.js +14 -0
- package/dist/json/DateOnlyJsonConverter.js.map +1 -0
- package/dist/json/JsonConverter.d.ts.map +1 -1
- package/dist/json/JsonConverter.js.map +1 -1
- package/dist/json/TimeOnlyJsonConverter.d.ts +9 -0
- package/dist/json/TimeOnlyJsonConverter.d.ts.map +1 -0
- package/dist/json/TimeOnlyJsonConverter.js +14 -0
- package/dist/json/TimeOnlyJsonConverter.js.map +1 -0
- package/dist/json/index.d.ts +2 -0
- package/dist/json/index.d.ts.map +1 -1
- package/dist/json/index.js +2 -0
- package/dist/json/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typeKey.d.ts +7 -0
- package/dist/typeKey.d.ts.map +1 -0
- package/dist/typeKey.js +6 -0
- package/dist/typeKey.js.map +1 -0
- package/duplicateInstanceGuard.ts +114 -0
- package/for_DateOnly/when_parsing_a_calendar_date.ts +13 -0
- package/for_DateOnly/when_reading_it_west_of_utc.ts +24 -0
- package/for_JsonSerializer/RegisteredConverterTypes.ts +45 -0
- package/for_JsonSerializer/when_a_converter_is_registered_for_a_concept.ts +46 -0
- package/for_JsonSerializer/when_a_converter_is_registered_for_a_type_that_already_has_one.ts +25 -0
- package/for_JsonSerializer/when_a_converter_is_registered_for_a_type_the_package_already_converts.ts +51 -0
- package/for_JsonSerializer/when_a_converter_is_registered_for_a_value_map.ts +49 -0
- package/for_JsonSerializer/when_a_converter_is_registered_for_an_unknown_type.ts +30 -0
- package/for_JsonSerializer/when_a_type_comes_from_another_copy_of_the_package.ts +63 -0
- package/for_JsonSerializer/when_deserializing_temporal_values.ts +31 -0
- package/for_JsonSerializer/when_metadata_is_written_by_another_copy_of_the_package.ts +46 -0
- package/for_JsonSerializer/when_no_converter_is_registered_for_a_type.ts +32 -0
- package/for_JsonSerializer/when_round_tripping_a_value_map_of_primitive_values.ts +35 -0
- package/for_JsonSerializer/when_round_tripping_concepts_outside_a_declared_field.ts +39 -0
- package/for_TimeOnly/when_parsing_a_time_of_day.ts +17 -0
- package/for_TimeOnly/when_parsing_the_shapes_the_server_sends.ts +24 -0
- package/for_duplicateInstanceGuard/given/a_realm.ts +62 -0
- package/for_duplicateInstanceGuard/when_a_second_copy_is_loaded.ts +28 -0
- package/for_duplicateInstanceGuard/when_a_third_copy_is_loaded.ts +20 -0
- package/for_duplicateInstanceGuard/when_checking_the_package_manifest.ts +26 -0
- package/for_duplicateInstanceGuard/when_one_copy_is_loaded.ts +17 -0
- package/for_duplicateInstanceGuard/when_one_copy_registers_more_than_once.ts +20 -0
- package/for_duplicateInstanceGuard/when_something_else_holds_the_global_key.ts +25 -0
- package/for_duplicateInstanceGuard/when_the_runtime_has_no_console.ts +30 -0
- package/geospatial/LineString.ts +3 -0
- package/geospatial/Point.ts +3 -0
- package/geospatial/Polygon.ts +3 -0
- package/index.ts +3 -0
- package/json/DateOnlyJsonConverter.ts +28 -0
- package/json/JsonConverter.ts +5 -0
- package/json/TimeOnlyJsonConverter.ts +28 -0
- package/json/index.ts +2 -0
- package/package.json +1 -1
- package/typeKey.ts +54 -0
package/dist/esm/TimeSpan.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeSpan.js","sources":["../../TimeSpan.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { field } from './fieldDecorator';\n\nconst timeSpanRegex = /^(-)?(?:(\\d+)\\.)?(\\d{1,2}):(\\d{2}):(\\d{2})(?:\\.(\\d{1,7}))?$/;\n\n/**\n * Represents a time interval.\n */\nexport class TimeSpan {\n \n @field(Number)\n ticks!: number;\n\n @field(Number)\n days!: number;\n\n @field(Number)\n hours!: number;\n\n @field(Number)\n milliseconds!: number;\n\n @field(Number)\n microseconds!: number;\n\n @field(Number)\n nanoseconds!: number;\n\n @field(Number)\n minutes!: number;\n\n @field(Number)\n seconds!: number;\n\n @field(Number)\n totalDays!: number;\n\n @field(Number)\n totalHours!: number;\n\n @field(Number)\n totalMilliseconds!: number;\n\n @field(Number)\n totalMicroseconds!: number;\n\n @field(Number)\n totalNanoseconds!: number;\n\n @field(Number)\n totalMinutes!: number;\n\n @field(Number)\n totalSeconds!: number;\n\n /**\n * Parses a C# compatible TimeSpan string and returns a TimeSpan instance.\n * The string format should match: [-][d.]hh:mm:ss[.fffffff]\n * @param {string} value String representation of TimeSpan.\n * @returns {TimeSpan} A TimeSpan instance with all properties populated.\n * @throws {Error} If the string format is invalid.\n */\n static parse(value: string): TimeSpan {\n const match = timeSpanRegex.exec(value);\n if (match === null) {\n throw new Error(`Invalid TimeSpan format: ${value}`);\n }\n\n const isNegative = match[1] === '-';\n const days = match[2] ? parseInt(match[2], 10) : 0;\n const hours = parseInt(match[3], 10);\n const minutes = parseInt(match[4], 10);\n const seconds = parseInt(match[5], 10);\n const fractionalSeconds = match[6] ? match[6].padEnd(7, '0') : '0000000';\n\n const ticksPerDay = 864000000000;\n const ticksPerHour = 36000000000;\n const ticksPerMinute = 600000000;\n const ticksPerSecond = 10000000;\n\n const ticks =\n days * ticksPerDay +\n hours * ticksPerHour +\n minutes * ticksPerMinute +\n seconds * ticksPerSecond +\n parseInt(fractionalSeconds, 10);\n\n const finalTicks = isNegative ? -ticks : ticks;\n\n const timeSpan = new TimeSpan();\n timeSpan.ticks = finalTicks;\n timeSpan.days = Math.floor(Math.abs(finalTicks) / ticksPerDay) * (isNegative ? -1 : 1);\n timeSpan.hours = Math.floor((Math.abs(finalTicks) / ticksPerHour) % 24);\n timeSpan.minutes = Math.floor((Math.abs(finalTicks) / ticksPerMinute) % 60);\n timeSpan.seconds = Math.floor((Math.abs(finalTicks) / ticksPerSecond) % 60);\n timeSpan.milliseconds = Math.floor((Math.abs(finalTicks) / 10000) % 1000);\n timeSpan.microseconds = Math.floor((Math.abs(finalTicks) / 10) % 1000);\n timeSpan.nanoseconds = Math.floor((Math.abs(finalTicks) % 10) * 100);\n timeSpan.totalDays = finalTicks / ticksPerDay;\n timeSpan.totalHours = finalTicks / ticksPerHour;\n timeSpan.totalMinutes = finalTicks / ticksPerMinute;\n timeSpan.totalSeconds = finalTicks / ticksPerSecond;\n timeSpan.totalMilliseconds = finalTicks / 10000;\n timeSpan.totalMicroseconds = finalTicks / 10;\n timeSpan.totalNanoseconds = finalTicks * 100;\n\n return timeSpan;\n }\n\n /**\n * Converts the TimeSpan to a C# compatible string format.\n * Returns the TimeSpan in format: [-][d.]hh:mm:ss[.fffffff]\n * @returns {string} C# compatible TimeSpan string representation.\n */\n toString(): string {\n const isNegative = this.ticks < 0;\n const absTicks = Math.abs(this.ticks);\n\n const ticksPerDay = 864000000000;\n const ticksPerHour = 36000000000;\n const ticksPerMinute = 600000000;\n const ticksPerSecond = 10000000;\n\n const days = Math.floor(absTicks / ticksPerDay);\n const hours = Math.floor((absTicks / ticksPerHour) % 24);\n const minutes = Math.floor((absTicks / ticksPerMinute) % 60);\n const seconds = Math.floor((absTicks / ticksPerSecond) % 60);\n const fractionalTicks = absTicks % ticksPerSecond;\n\n const parts: string[] = [];\n\n if (isNegative) {\n parts.push('-');\n }\n\n if (days > 0) {\n parts.push(`${days}.`);\n }\n\n parts.push(`${hours.toString().padStart(2, '0')}:`);\n parts.push(`${minutes.toString().padStart(2, '0')}:`);\n parts.push(`${seconds.toString().padStart(2, '0')}`);\n\n if (fractionalTicks > 0) {\n const fractionalStr = fractionalTicks.toString().padStart(7, '0').replace(/0+$/, '');\n parts.push(`.${fractionalStr}`);\n }\n\n return parts.join('');\n }\n\n /**\n * Converts the TimeSpan to a JSON string that works in JSON serialization.\n * Returns the TimeSpan in C# compatible format: [-][d.]hh:mm:ss[.fffffff]\n * @returns {string} C# compatible TimeSpan string representation.\n */\n toJSON(): string {\n return this.toString();\n }\n}\n"],"names":[],"mappings":";;;AAKA,MAAM,aAAa,GAAG,6DAA6D;MAKtE,QAAQ,CAAA;AAGjB,IAAA,KAAK;AAGL,IAAA,IAAI;AAGJ,IAAA,KAAK;AAGL,IAAA,YAAY;AAGZ,IAAA,YAAY;AAGZ,IAAA,WAAW;AAGX,IAAA,OAAO;AAGP,IAAA,OAAO;AAGP,IAAA,SAAS;AAGT,IAAA,UAAU;AAGV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{"version":3,"file":"TimeSpan.js","sources":["../../TimeSpan.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { typeKey } from './typeKey';\n\nimport { field } from './fieldDecorator';\n\nconst timeSpanRegex = /^(-)?(?:(\\d+)\\.)?(\\d{1,2}):(\\d{2}):(\\d{2})(?:\\.(\\d{1,7}))?$/;\n\n/**\n * Represents a time interval.\n */\nexport class TimeSpan {\n static readonly [typeKey] = 'TimeSpan';\n\n \n @field(Number)\n ticks!: number;\n\n @field(Number)\n days!: number;\n\n @field(Number)\n hours!: number;\n\n @field(Number)\n milliseconds!: number;\n\n @field(Number)\n microseconds!: number;\n\n @field(Number)\n nanoseconds!: number;\n\n @field(Number)\n minutes!: number;\n\n @field(Number)\n seconds!: number;\n\n @field(Number)\n totalDays!: number;\n\n @field(Number)\n totalHours!: number;\n\n @field(Number)\n totalMilliseconds!: number;\n\n @field(Number)\n totalMicroseconds!: number;\n\n @field(Number)\n totalNanoseconds!: number;\n\n @field(Number)\n totalMinutes!: number;\n\n @field(Number)\n totalSeconds!: number;\n\n /**\n * Parses a C# compatible TimeSpan string and returns a TimeSpan instance.\n * The string format should match: [-][d.]hh:mm:ss[.fffffff]\n * @param {string} value String representation of TimeSpan.\n * @returns {TimeSpan} A TimeSpan instance with all properties populated.\n * @throws {Error} If the string format is invalid.\n */\n static parse(value: string): TimeSpan {\n const match = timeSpanRegex.exec(value);\n if (match === null) {\n throw new Error(`Invalid TimeSpan format: ${value}`);\n }\n\n const isNegative = match[1] === '-';\n const days = match[2] ? parseInt(match[2], 10) : 0;\n const hours = parseInt(match[3], 10);\n const minutes = parseInt(match[4], 10);\n const seconds = parseInt(match[5], 10);\n const fractionalSeconds = match[6] ? match[6].padEnd(7, '0') : '0000000';\n\n const ticksPerDay = 864000000000;\n const ticksPerHour = 36000000000;\n const ticksPerMinute = 600000000;\n const ticksPerSecond = 10000000;\n\n const ticks =\n days * ticksPerDay +\n hours * ticksPerHour +\n minutes * ticksPerMinute +\n seconds * ticksPerSecond +\n parseInt(fractionalSeconds, 10);\n\n const finalTicks = isNegative ? -ticks : ticks;\n\n const timeSpan = new TimeSpan();\n timeSpan.ticks = finalTicks;\n timeSpan.days = Math.floor(Math.abs(finalTicks) / ticksPerDay) * (isNegative ? -1 : 1);\n timeSpan.hours = Math.floor((Math.abs(finalTicks) / ticksPerHour) % 24);\n timeSpan.minutes = Math.floor((Math.abs(finalTicks) / ticksPerMinute) % 60);\n timeSpan.seconds = Math.floor((Math.abs(finalTicks) / ticksPerSecond) % 60);\n timeSpan.milliseconds = Math.floor((Math.abs(finalTicks) / 10000) % 1000);\n timeSpan.microseconds = Math.floor((Math.abs(finalTicks) / 10) % 1000);\n timeSpan.nanoseconds = Math.floor((Math.abs(finalTicks) % 10) * 100);\n timeSpan.totalDays = finalTicks / ticksPerDay;\n timeSpan.totalHours = finalTicks / ticksPerHour;\n timeSpan.totalMinutes = finalTicks / ticksPerMinute;\n timeSpan.totalSeconds = finalTicks / ticksPerSecond;\n timeSpan.totalMilliseconds = finalTicks / 10000;\n timeSpan.totalMicroseconds = finalTicks / 10;\n timeSpan.totalNanoseconds = finalTicks * 100;\n\n return timeSpan;\n }\n\n /**\n * Converts the TimeSpan to a C# compatible string format.\n * Returns the TimeSpan in format: [-][d.]hh:mm:ss[.fffffff]\n * @returns {string} C# compatible TimeSpan string representation.\n */\n toString(): string {\n const isNegative = this.ticks < 0;\n const absTicks = Math.abs(this.ticks);\n\n const ticksPerDay = 864000000000;\n const ticksPerHour = 36000000000;\n const ticksPerMinute = 600000000;\n const ticksPerSecond = 10000000;\n\n const days = Math.floor(absTicks / ticksPerDay);\n const hours = Math.floor((absTicks / ticksPerHour) % 24);\n const minutes = Math.floor((absTicks / ticksPerMinute) % 60);\n const seconds = Math.floor((absTicks / ticksPerSecond) % 60);\n const fractionalTicks = absTicks % ticksPerSecond;\n\n const parts: string[] = [];\n\n if (isNegative) {\n parts.push('-');\n }\n\n if (days > 0) {\n parts.push(`${days}.`);\n }\n\n parts.push(`${hours.toString().padStart(2, '0')}:`);\n parts.push(`${minutes.toString().padStart(2, '0')}:`);\n parts.push(`${seconds.toString().padStart(2, '0')}`);\n\n if (fractionalTicks > 0) {\n const fractionalStr = fractionalTicks.toString().padStart(7, '0').replace(/0+$/, '');\n parts.push(`.${fractionalStr}`);\n }\n\n return parts.join('');\n }\n\n /**\n * Converts the TimeSpan to a JSON string that works in JSON serialization.\n * Returns the TimeSpan in C# compatible format: [-][d.]hh:mm:ss[.fffffff]\n * @returns {string} C# compatible TimeSpan string representation.\n */\n toJSON(): string {\n return this.toString();\n }\n}\n"],"names":[],"mappings":";;;;AAOA,MAAM,aAAa,GAAG,6DAA6D;MAKtE,QAAQ,CAAA;AACjB,IAAA,QAAiB,OAAO,IAAI,UAAU;AAItC,IAAA,KAAK;AAGL,IAAA,IAAI;AAGJ,IAAA,KAAK;AAGL,IAAA,YAAY;AAGZ,IAAA,YAAY;AAGZ,IAAA,WAAW;AAGX,IAAA,OAAO;AAGP,IAAA,OAAO;AAGP,IAAA,SAAS;AAGT,IAAA,UAAU;AAGV,IAAA,iBAAiB;AAGjB,IAAA,iBAAiB;AAGjB,IAAA,gBAAgB;AAGhB,IAAA,YAAY;AAGZ,IAAA,YAAY;IASZ,OAAO,KAAK,CAAC,KAAa,EAAA;QACtB,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC;AACvC,QAAA,IAAI,KAAK,KAAK,IAAI,EAAE;AAChB,YAAA,MAAM,IAAI,KAAK,CAAC,4BAA4B,KAAK,CAAA,CAAE,CAAC;QACxD;QAEA,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG;QACnC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC;QAClD,MAAM,KAAK,GAAG,QAAQ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GnB,UAAA,CAAA;IADC,KAAK,CAAC,MAAM,CAAC;;AACM,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,YAAA,EAAA,MAAA,CAAA;AAGpB,UAAA,CAAA;IADC,KAAK,CAAC,MAAM,CAAC;;AACa,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,mBAAA,EAAA,MAAA,CAAA;AAG3B,UAAA,CAAA;IADC,KAAK,CAAC,MAAM,CAAC;;AACa,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,mBAAA,EAAA,MAAA,CAAA;AAG3B,UAAA,CAAA;IADC,KAAK,CAAC,MAAM,CAAC;;AACY,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,kBAAA,EAAA,MAAA,CAAA;AAG1B,UAAA,CAAA;IADC,KAAK,CAAC,MAAM,CAAC;;AACQ,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,cAAA,EAAA,MAAA,CAAA;AAGtB,UAAA,CAAA;IADC,KAAK,CAAC,MAAM,CAAC;;AACQ,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,cAAA,EAAA,MAAA,CAAA;;;;"}
|
package/dist/esm/ValueMap.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValueMap.d.ts","sourceRoot":"","sources":["../../ValueMap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ValueMap.d.ts","sourceRoot":"","sources":["../../ValueMap.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,qBAAa,QAAQ,CAAC,IAAI,EAAE,MAAM;IAC9B,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,cAAc;IAEvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;IAStD,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAiBnC,GAAG,CAAC,GAAG,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS;IASlC,OAAO,IAAI,gBAAgB,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAI3C,OAAO,CAAC,MAAM;CAejB"}
|
package/dist/esm/ValueMap.js
CHANGED
package/dist/esm/ValueMap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValueMap.js","sources":["../../ValueMap.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Represents a map that compares object keys by value.\n */\nexport class ValueMap<TKey, TValue> {\n private readonly _entries: Array<[TKey, TValue]> = [];\n\n /**\n * Adds a new entry or updates an existing entry for the provided key.\n *\n * @param key Key to add or update.\n * @param value Value to associate with the key.\n * @returns The current map instance for chaining.\n */\n set(key: TKey, value: TValue): this {\n const index = this._entries.findIndex(([existingKey]) => this.equals(existingKey, key));\n if (index >= 0) {\n this._entries[index][1] = value;\n } else {\n this._entries.push([key, value]);\n }\n\n return this;\n }\n\n /**\n * Gets the value associated with the provided key.\n *\n * @param key Key to look up.\n * @returns The matching value, or undefined when no entry matches.\n */\n get(key: TKey): TValue | undefined {\n return this._entries.find(([existingKey]) => this.equals(existingKey, key))?.[1];\n }\n\n /**\n * Gets an iterator over all key-value entries in insertion order.\n *\n * @returns Iterator for the map entries.\n */\n entries(): IterableIterator<[TKey, TValue]> {\n return this._entries.values();\n }\n\n private equals(first: TKey, second: TKey): boolean {\n if (first === second) {\n return true;\n }\n\n if (first === undefined || first === null || second === undefined || second === null) {\n return false;\n }\n\n if (typeof first === 'object' && typeof second === 'object') {\n return JSON.stringify(first) === JSON.stringify(second);\n }\n\n return false;\n }\n}"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ValueMap.js","sources":["../../ValueMap.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\nimport { typeKey } from './typeKey';\n\n/**\n * Represents a map that compares object keys by value.\n */\nexport class ValueMap<TKey, TValue> {\n static readonly [typeKey] = 'ValueMap';\n\n private readonly _entries: Array<[TKey, TValue]> = [];\n\n /**\n * Adds a new entry or updates an existing entry for the provided key.\n *\n * @param key Key to add or update.\n * @param value Value to associate with the key.\n * @returns The current map instance for chaining.\n */\n set(key: TKey, value: TValue): this {\n const index = this._entries.findIndex(([existingKey]) => this.equals(existingKey, key));\n if (index >= 0) {\n this._entries[index][1] = value;\n } else {\n this._entries.push([key, value]);\n }\n\n return this;\n }\n\n /**\n * Gets the value associated with the provided key.\n *\n * @param key Key to look up.\n * @returns The matching value, or undefined when no entry matches.\n */\n get(key: TKey): TValue | undefined {\n return this._entries.find(([existingKey]) => this.equals(existingKey, key))?.[1];\n }\n\n /**\n * Gets an iterator over all key-value entries in insertion order.\n *\n * @returns Iterator for the map entries.\n */\n entries(): IterableIterator<[TKey, TValue]> {\n return this._entries.values();\n }\n\n private equals(first: TKey, second: TKey): boolean {\n if (first === second) {\n return true;\n }\n\n if (first === undefined || first === null || second === undefined || second === null) {\n return false;\n }\n\n if (typeof first === 'object' && typeof second === 'object') {\n return JSON.stringify(first) === JSON.stringify(second);\n }\n\n return false;\n }\n}"],"names":[],"mappings":";;MAOa,QAAQ,CAAA;AACjB,IAAA,QAAiB,OAAO,IAAI,UAAU;IAErB,QAAQ,GAA0B,EAAE;IASrD,GAAG,CAAC,GAAS,EAAE,KAAa,EAAA;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;AACvF,QAAA,IAAI,KAAK,IAAI,CAAC,EAAE;YACZ,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK;QACnC;aAAO;YACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACpC;AAEA,QAAA,OAAO,IAAI;IACf;AAQA,IAAA,GAAG,CAAC,GAAS,EAAA;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACpF;IAOA,OAAO,GAAA;AACH,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;IACjC;IAEQ,MAAM,CAAC,KAAW,EAAE,MAAY,EAAA;AACpC,QAAA,IAAI,KAAK,KAAK,MAAM,EAAE;AAClB,YAAA,OAAO,IAAI;QACf;AAEA,QAAA,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,IAAI,EAAE;AAClF,YAAA,OAAO,KAAK;QAChB;QAEA,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;AACzD,YAAA,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;QAC3D;AAEA,QAAA,OAAO,KAAK;IAChB;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duplicateInstanceGuard.d.ts","sourceRoot":"","sources":["../../duplicateInstanceGuard.ts"],"names":[],"mappings":"AAkGA,eAAO,MAAM,sBAAsB,QAAO,IAezC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const loadedInstancesKey = Symbol.for('@cratis/fundamentals.loadedInstances');
|
|
2
|
+
const duplicateReportedKey = Symbol.for('@cratis/fundamentals.duplicateReported');
|
|
3
|
+
const globals = globalThis;
|
|
4
|
+
const unknownOrigin = 'unknown location';
|
|
5
|
+
let registered = false;
|
|
6
|
+
const resolveOrigin = () => {
|
|
7
|
+
try {
|
|
8
|
+
const frames = (new Error().stack ?? '')
|
|
9
|
+
.split('\n')
|
|
10
|
+
.map(line => line.trim())
|
|
11
|
+
.filter(line => line.length > 0 && line !== 'Error');
|
|
12
|
+
const frame = frames[0];
|
|
13
|
+
if (!frame)
|
|
14
|
+
return unknownOrigin;
|
|
15
|
+
return frame.match(/\((.+)\)$/)?.[1] ?? frame.replace(/^at\s+/, '');
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return unknownOrigin;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const reportDuplicate = (origins) => {
|
|
22
|
+
if (typeof console === 'undefined' || typeof console.warn !== 'function')
|
|
23
|
+
return;
|
|
24
|
+
const locations = origins.map((origin, index) => ` ${index + 1}. ${origin}`).join('\n');
|
|
25
|
+
console.warn(`[@cratis/fundamentals] Loaded ${origins.length} times into the same JavaScript realm, and it has to be loaded once.\n` +
|
|
26
|
+
'Each load builds its own converter registry and its own Guid and ConceptAs class objects. A converter registered through ' +
|
|
27
|
+
'JsonSerializer.registerConverter reaches only the copy it was registered on, an instanceof against the other copy\'s ' +
|
|
28
|
+
'class is false, and a version pinned at the top level does not reach a copy nested under a dependency - so an adopted ' +
|
|
29
|
+
`fix can reach nothing at all.\nLoaded from:\n${locations}\n` +
|
|
30
|
+
'If those are separate installs, collapse them with `yarn dedupe @cratis/fundamentals` (or `npm dedupe`) and confirm with ' +
|
|
31
|
+
'`yarn why @cratis/fundamentals`. If they differ only in dist/esm against dist/cjs it is one install reached as both ESM ' +
|
|
32
|
+
'and CommonJS, which no dedupe will fix - make every importer resolve the same one.');
|
|
33
|
+
};
|
|
34
|
+
const registerModuleInstance = () => {
|
|
35
|
+
if (registered)
|
|
36
|
+
return;
|
|
37
|
+
registered = true;
|
|
38
|
+
const existing = globals[loadedInstancesKey];
|
|
39
|
+
const origins = Array.isArray(existing) ? existing : [];
|
|
40
|
+
if (origins !== existing) {
|
|
41
|
+
globals[loadedInstancesKey] = origins;
|
|
42
|
+
}
|
|
43
|
+
origins.push(resolveOrigin());
|
|
44
|
+
if (origins.length < 2 || globals[duplicateReportedKey] === true)
|
|
45
|
+
return;
|
|
46
|
+
globals[duplicateReportedKey] = true;
|
|
47
|
+
reportDuplicate(origins);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export { registerModuleInstance };
|
|
51
|
+
//# sourceMappingURL=duplicateInstanceGuard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duplicateInstanceGuard.js","sources":["../../duplicateInstanceGuard.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Detects that more than one copy of this package has been loaded into the same JavaScript\n * realm and reports it, once.\n *\n * A second copy brings its own converter registry and its own `Guid` and `ConceptAs` class\n * objects. Values themselves survive the boundary - a convertible type is recognized by the key\n * it declares rather than by its class object - but three things do not, all of them silent:\n * a converter registered through `JsonSerializer.registerConverter` reaches only the copy it was\n * registered on, an `instanceof` against the other copy's class is false, and a version pinned at\n * the top level never reaches a copy nested under a dependency, so an adopted fix can reach\n * nothing at all.\n *\n * A package manager is free to produce that second copy, and this module does not try to stop\n * it. It makes it visible. Two installs is the usual cause, but one install reached as both ESM\n * and CommonJS is the same failure with no version mismatch anywhere to find it by - so the\n * report names where each load came from rather than only how many there were.\n *\n * A copy older than this guard does not register itself and leaves nothing behind for a newer\n * copy to find, so duplication is reported only once every copy in the realm carries the guard.\n * That is inherent to the approach, not a gap left to close.\n *\n * The bookkeeping lives on `globalThis`, because module scope is the very thing being\n * duplicated. Its two keys are a cross-version contract - a copy of a *different* version of\n * this package may have written them first - so the shapes are deliberately primitive: an\n * array of strings and a boolean.\n *\n * The registration is a load-bearing side effect. Do not declare `\"sideEffects\": false` in the\n * package manifest; a bundler would then be free to drop it, and the duplicate would go back\n * to being silent.\n */\n\n/** Holds one entry per loaded copy of this package, in load order. */\nconst loadedInstancesKey = Symbol.for('@cratis/fundamentals.loadedInstances');\n\n/** Records that the duplicate has been reported, so it is reported exactly once per realm. */\nconst duplicateReportedKey = Symbol.for('@cratis/fundamentals.duplicateReported');\n\nconst globals = globalThis as Record<symbol, unknown>;\n\n/** Placeholder used when the runtime offers no usable stack trace. */\nconst unknownOrigin = 'unknown location';\n\n/** Set once this copy has registered itself, so repeated calls count it only once. */\nlet registered = false;\n\n/**\n * Resolves where this copy of the package was loaded from, so the report can name the copies\n * rather than only their number.\n * @returns {string} A source location, or a placeholder when no stack trace is available.\n */\nconst resolveOrigin = (): string => {\n try {\n // The first frame is this function, which lives in this copy of the package - exactly\n // the location worth naming. V8 prefixes the stack with a bare `Error` line that other\n // engines omit, so drop it rather than indexing past it.\n const frames = (new Error().stack ?? '')\n .split('\\n')\n .map(line => line.trim())\n .filter(line => line.length > 0 && line !== 'Error');\n\n const frame = frames[0];\n if (!frame) return unknownOrigin;\n\n return frame.match(/\\((.+)\\)$/)?.[1] ?? frame.replace(/^at\\s+/, '');\n } catch {\n // A runtime that refuses stack traces is not a reason to skip the registration.\n return unknownOrigin;\n }\n};\n\n/**\n * Writes the diagnostic as a single console entry naming the problem, its consequence and the\n * way out.\n * @param {string[]} origins Where each loaded copy was loaded from, in load order.\n */\nconst reportDuplicate = (origins: string[]): void => {\n if (typeof console === 'undefined' || typeof console.warn !== 'function') return;\n\n const locations = origins.map((origin, index) => ` ${index + 1}. ${origin}`).join('\\n');\n\n console.warn(\n `[@cratis/fundamentals] Loaded ${origins.length} times into the same JavaScript realm, and it has to be loaded once.\\n` +\n 'Each load builds its own converter registry and its own Guid and ConceptAs class objects. A converter registered through ' +\n 'JsonSerializer.registerConverter reaches only the copy it was registered on, an instanceof against the other copy\\'s ' +\n 'class is false, and a version pinned at the top level does not reach a copy nested under a dependency - so an adopted ' +\n `fix can reach nothing at all.\\nLoaded from:\\n${locations}\\n` +\n 'If those are separate installs, collapse them with `yarn dedupe @cratis/fundamentals` (or `npm dedupe`) and confirm with ' +\n '`yarn why @cratis/fundamentals`. If they differ only in dist/esm against dist/cjs it is one install reached as both ESM ' +\n 'and CommonJS, which no dedupe will fix - make every importer resolve the same one.');\n};\n\n/**\n * Registers this copy of the package and reports, once per realm, when it is not the only one.\n * Calling this more than once from the same copy registers that copy once.\n */\nexport const registerModuleInstance = (): void => {\n if (registered) return;\n registered = true;\n\n const existing = globals[loadedInstancesKey];\n const origins: string[] = Array.isArray(existing) ? existing : [];\n if (origins !== existing) {\n globals[loadedInstancesKey] = origins;\n }\n origins.push(resolveOrigin());\n\n if (origins.length < 2 || globals[duplicateReportedKey] === true) return;\n\n globals[duplicateReportedKey] = true;\n reportDuplicate(origins);\n};\n"],"names":[],"mappings":"AAmCA,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,sCAAsC,CAAC;AAG7E,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,wCAAwC,CAAC;AAEjF,MAAM,OAAO,GAAG,UAAqC;AAGrD,MAAM,aAAa,GAAG,kBAAkB;AAGxC,IAAI,UAAU,GAAG,KAAK;AAOtB,MAAM,aAAa,GAAG,MAAa;AAC/B,IAAA,IAAI;QAIA,MAAM,MAAM,GAAG,CAAC,IAAI,KAAK,EAAE,CAAC,KAAK,IAAI,EAAE;aAClC,KAAK,CAAC,IAAI;aACV,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE;AACvB,aAAA,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,KAAK,OAAO,CAAC;AAExD,QAAA,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC;AACvB,QAAA,IAAI,CAAC,KAAK;AAAE,YAAA,OAAO,aAAa;AAEhC,QAAA,OAAO,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;IACvE;AAAE,IAAA,MAAM;AAEJ,QAAA,OAAO,aAAa;IACxB;AACJ,CAAC;AAOD,M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mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"LineString.d.ts","sourceRoot":"","sources":["../../../geospatial/LineString.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAKrC,qBAAa,UAAU;IACnB,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,gBAAgB;IAEzC,WAAW,EAAG,KAAK,EAAE,CAAC;gBAMV,WAAW,EAAE,KAAK,EAAE;IAWhC,MAAM,IAAI,MAAM;CAMnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineString.js","sources":["../../../geospatial/LineString.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Point } from './Point';\n\n/**\n * Represents a line string composed of two or more points.\n */\nexport class LineString {\n coordinates!: Point[];\n\n /**\n * Creates a new LineString instance.\n * @param {Point[]} coordinates - The points that make up the line string (minimum 2 points).\n */\n constructor(coordinates: Point[]) {\n if (coordinates.length < 2) {\n throw new Error('LineString must have at least 2 points');\n }\n this.coordinates = coordinates;\n }\n\n /**\n * Converts the LineString to a GeoJSON representation.\n * @returns {object} GeoJSON representation.\n */\n toJSON(): object {\n return {\n type: 'LineString',\n coordinates: this.coordinates.map(p => [p.longitude, p.latitude])\n };\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LineString.js","sources":["../../../geospatial/LineString.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Point } from './Point';\nimport { typeKey } from '../typeKey';\n\n/**\n * Represents a line string composed of two or more points.\n */\nexport class LineString {\n static readonly [typeKey] = 'LineString';\n\n coordinates!: Point[];\n\n /**\n * Creates a new LineString instance.\n * @param {Point[]} coordinates - The points that make up the line string (minimum 2 points).\n */\n constructor(coordinates: Point[]) {\n if (coordinates.length < 2) {\n throw new Error('LineString must have at least 2 points');\n }\n this.coordinates = coordinates;\n }\n\n /**\n * Converts the LineString to a GeoJSON representation.\n * @returns {object} GeoJSON representation.\n */\n toJSON(): object {\n return {\n type: 'LineString',\n coordinates: this.coordinates.map(p => [p.longitude, p.latitude])\n };\n }\n}\n"],"names":[],"mappings":";;MASa,UAAU,CAAA;AACnB,IAAA,QAAiB,OAAO,IAAI,YAAY;AAExC,IAAA,WAAW;AAMX,IAAA,WAAA,CAAY,WAAoB,EAAA;AAC5B,QAAA,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;AACxB,YAAA,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC;QAC7D;AACA,QAAA,IAAI,CAAC,WAAW,GAAG,WAAW;IAClC;IAMA,MAAM,GAAA;QACF,OAAO;AACH,YAAA,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC;SACnE;IACL;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Point.d.ts","sourceRoot":"","sources":["../../../geospatial/Point.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Point.d.ts","sourceRoot":"","sources":["../../../geospatial/Point.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAKrC,qBAAa,KAAK;IACd,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,WAAW;IAGpC,SAAS,EAAG,MAAM,CAAC;IAGnB,QAAQ,EAAG,MAAM,CAAC;gBAON,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAS/C,MAAM,IAAI,MAAM;CAMnB"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { __decorate, __metadata } from '../_virtual/_tslib.js';
|
|
2
2
|
import { field } from '../fieldDecorator.js';
|
|
3
|
+
import { typeKey } from '../typeKey.js';
|
|
3
4
|
|
|
4
5
|
class Point {
|
|
6
|
+
static [typeKey] = 'Point';
|
|
5
7
|
longitude;
|
|
6
8
|
latitude;
|
|
7
9
|
constructor(longitude, latitude) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Point.js","sources":["../../../geospatial/Point.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { field } from '../fieldDecorator';\n\n/**\n * Represents a geographic point with longitude and latitude.\n */\nexport class Point {\n @field(Number)\n longitude!: number;\n\n @field(Number)\n latitude!: number;\n\n /**\n * Creates a new Point instance.\n * @param {number} longitude - The longitude of the point.\n * @param {number} latitude - The latitude of the point.\n */\n constructor(longitude: number, latitude: number) {\n this.longitude = longitude;\n this.latitude = latitude;\n }\n\n /**\n * Converts the Point to a GeoJSON representation.\n * @returns {object} GeoJSON representation.\n */\n toJSON(): object {\n return {\n type: 'Point',\n coordinates: [this.longitude, this.latitude]\n };\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Point.js","sources":["../../../geospatial/Point.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { field } from '../fieldDecorator';\nimport { typeKey } from '../typeKey';\n\n/**\n * Represents a geographic point with longitude and latitude.\n */\nexport class Point {\n static readonly [typeKey] = 'Point';\n\n @field(Number)\n longitude!: number;\n\n @field(Number)\n latitude!: number;\n\n /**\n * Creates a new Point instance.\n * @param {number} longitude - The longitude of the point.\n * @param {number} latitude - The latitude of the point.\n */\n constructor(longitude: number, latitude: number) {\n this.longitude = longitude;\n this.latitude = latitude;\n }\n\n /**\n * Converts the Point to a GeoJSON representation.\n * @returns {object} GeoJSON representation.\n */\n toJSON(): object {\n return {\n type: 'Point',\n coordinates: [this.longitude, this.latitude]\n };\n }\n}\n"],"names":[],"mappings":";;;;MASa,KAAK,CAAA;AACd,IAAA,QAAiB,OAAO,IAAI,OAAO;AAGnC,IAAA,SAAS;AAGT,IAAA,QAAQ;IAOR,WAAA,CAAY,SAAiB,EAAE,QAAgB,EAAA;AAC3C,QAAA,IAAI,CAAC,SAAS,GAAG,SAAS;AAC1B,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ;IAC5B;IAMA,MAAM,GAAA;QACF,OAAO;AACH,YAAA,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ;SAC9C;IACL;;AAxBA,UAAA,CAAA;IADC,KAAK,CAAC,MAAM,CAAC;;AACK,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAGnB,UAAA,CAAA;IADC,KAAK,CAAC,MAAM,CAAC;;AACI,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Polygon.d.ts","sourceRoot":"","sources":["../../../geospatial/Polygon.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Polygon.d.ts","sourceRoot":"","sources":["../../../geospatial/Polygon.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAKrC,qBAAa,OAAO;IAChB,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,aAAa;IAEtC,KAAK,EAAG,UAAU,CAAC;IACnB,KAAK,EAAG,UAAU,EAAE,CAAC;gBAOT,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,UAAU,EAAE;IASnD,MAAM,IAAI,MAAM;CAUnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Polygon.js","sources":["../../../geospatial/Polygon.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { LinearRing } from './LinearRing';\n\n/**\n * Represents a polygon with an outer shell and optional holes.\n */\nexport class Polygon {\n shell!: LinearRing;\n holes!: LinearRing[];\n\n /**\n * Creates a new Polygon instance.\n * @param {LinearRing} shell - The outer boundary of the polygon.\n * @param {LinearRing[]} holes - Optional inner boundaries (holes) within the polygon.\n */\n constructor(shell: LinearRing, holes?: LinearRing[]) {\n this.shell = shell;\n this.holes = holes || [];\n }\n\n /**\n * Converts the Polygon to a GeoJSON representation.\n * @returns {object} GeoJSON representation.\n */\n toJSON(): object {\n const rings = [this.shell.toJSON()];\n if (this.holes && this.holes.length > 0) {\n rings.push(...this.holes.map(h => h.toJSON()));\n }\n return {\n type: 'Polygon',\n coordinates: rings\n };\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Polygon.js","sources":["../../../geospatial/Polygon.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { LinearRing } from './LinearRing';\nimport { typeKey } from '../typeKey';\n\n/**\n * Represents a polygon with an outer shell and optional holes.\n */\nexport class Polygon {\n static readonly [typeKey] = 'Polygon';\n\n shell!: LinearRing;\n holes!: LinearRing[];\n\n /**\n * Creates a new Polygon instance.\n * @param {LinearRing} shell - The outer boundary of the polygon.\n * @param {LinearRing[]} holes - Optional inner boundaries (holes) within the polygon.\n */\n constructor(shell: LinearRing, holes?: LinearRing[]) {\n this.shell = shell;\n this.holes = holes || [];\n }\n\n /**\n * Converts the Polygon to a GeoJSON representation.\n * @returns {object} GeoJSON representation.\n */\n toJSON(): object {\n const rings = [this.shell.toJSON()];\n if (this.holes && this.holes.length > 0) {\n rings.push(...this.holes.map(h => h.toJSON()));\n }\n return {\n type: 'Polygon',\n coordinates: rings\n };\n }\n}\n"],"names":[],"mappings":";;MASa,OAAO,CAAA;AAChB,IAAA,QAAiB,OAAO,IAAI,SAAS;AAErC,IAAA,KAAK;AACL,IAAA,KAAK;IAOL,WAAA,CAAY,KAAiB,EAAE,KAAoB,EAAA;AAC/C,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK;AAClB,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,EAAE;IAC5B;IAMA,MAAM,GAAA;QACF,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;AACnC,QAAA,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YACrC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAClD;QACA,OAAO;AACH,YAAA,IAAI,EAAE,SAAS;AACf,YAAA,WAAW,EAAE;SAChB;IACL;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -4,13 +4,16 @@ export * from './geospatial';
|
|
|
4
4
|
export * from './json';
|
|
5
5
|
export * from './Field';
|
|
6
6
|
export * from './Fields';
|
|
7
|
+
export * from './DateOnly';
|
|
7
8
|
export * from './Guid';
|
|
8
9
|
export * from './IEquatable';
|
|
9
10
|
export * from './PropertyAccessor';
|
|
10
11
|
export * from './PropertyAccessorDescriptor';
|
|
11
12
|
export * from './PropertyPathResolverProxyHandler';
|
|
13
|
+
export * from './TimeOnly';
|
|
12
14
|
export * from './TimeSpan';
|
|
13
15
|
export * from './ValueMap';
|
|
16
|
+
export * from './typeKey';
|
|
14
17
|
export * from './fieldDecorator';
|
|
15
18
|
export * from './derivedTypeDecorator';
|
|
16
19
|
export * from './JsonSerializer';
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAGA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oCAAoC,CAAC;AACnD,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAGA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oCAAoC,CAAC;AACnD,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -5,7 +5,9 @@ export { LineString } from './geospatial/LineString.js';
|
|
|
5
5
|
export { Polygon } from './geospatial/Polygon.js';
|
|
6
6
|
export { JsonConverter } from './json/JsonConverter.js';
|
|
7
7
|
export { DateJsonConverter } from './json/DateJsonConverter.js';
|
|
8
|
+
export { DateOnlyJsonConverter } from './json/DateOnlyJsonConverter.js';
|
|
8
9
|
export { GuidJsonConverter } from './json/GuidJsonConverter.js';
|
|
10
|
+
export { TimeOnlyJsonConverter } from './json/TimeOnlyJsonConverter.js';
|
|
9
11
|
export { TimeSpanJsonConverter } from './json/TimeSpanJsonConverter.js';
|
|
10
12
|
export { PointJsonConverter } from './json/PointJsonConverter.js';
|
|
11
13
|
export { LineStringJsonConverter } from './json/LineStringJsonConverter.js';
|
|
@@ -13,11 +15,14 @@ export { PolygonJsonConverter } from './json/PolygonJsonConverter.js';
|
|
|
13
15
|
export { ValueMapJsonConverter } from './json/ValueMapJsonConverter.js';
|
|
14
16
|
export { Field } from './Field.js';
|
|
15
17
|
export { Fields } from './Fields.js';
|
|
18
|
+
export { DateOnly } from './DateOnly.js';
|
|
16
19
|
export { Guid } from './Guid.js';
|
|
17
20
|
export { PropertyAccessorDescriptor } from './PropertyAccessorDescriptor.js';
|
|
18
21
|
export { PropertyPathResolverProxyHandler } from './PropertyPathResolverProxyHandler.js';
|
|
22
|
+
export { TimeOnly } from './TimeOnly.js';
|
|
19
23
|
export { TimeSpan } from './TimeSpan.js';
|
|
20
24
|
export { ValueMap } from './ValueMap.js';
|
|
25
|
+
export { conceptAsTypeKey, declaredTypeKey, typeKey, typeKeyOf, valueMapTypeKey } from './typeKey.js';
|
|
21
26
|
export { field } from './fieldDecorator.js';
|
|
22
27
|
export { derivedType } from './derivedTypeDecorator.js';
|
|
23
28
|
export { JsonSerializer } from './JsonSerializer.js';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Constructor } from '../Constructor';
|
|
2
|
+
import { DateOnly } from '../DateOnly';
|
|
3
|
+
import { JsonConverter } from './JsonConverter';
|
|
4
|
+
export declare class DateOnlyJsonConverter extends JsonConverter<DateOnly> {
|
|
5
|
+
get type(): Constructor<DateOnly>;
|
|
6
|
+
read(value: any): DateOnly;
|
|
7
|
+
write(value: any): any;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=DateOnlyJsonConverter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateOnlyJsonConverter.d.ts","sourceRoot":"","sources":["../../../json/DateOnlyJsonConverter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAOhD,qBAAa,qBAAsB,SAAQ,aAAa,CAAC,QAAQ,CAAC;IAE9D,IAAI,IAAI,IAAI,WAAW,CAAC,QAAQ,CAAC,CAEhC;IAGD,IAAI,CAAC,KAAK,EAAE,GAAG,GAAG,QAAQ;IAK1B,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG;CAGzB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DateOnly } from '../DateOnly.js';
|
|
2
|
+
import { JsonConverter } from './JsonConverter.js';
|
|
3
|
+
|
|
4
|
+
class DateOnlyJsonConverter extends JsonConverter {
|
|
5
|
+
get type() {
|
|
6
|
+
return DateOnly;
|
|
7
|
+
}
|
|
8
|
+
read(value) {
|
|
9
|
+
return DateOnly.parse(value.toString());
|
|
10
|
+
}
|
|
11
|
+
write(value) {
|
|
12
|
+
return value?.toString() ?? '';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { DateOnlyJsonConverter };
|
|
17
|
+
//# sourceMappingURL=DateOnlyJsonConverter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateOnlyJsonConverter.js","sources":["../../../json/DateOnlyJsonConverter.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Constructor } from '../Constructor';\nimport { DateOnly } from '../DateOnly';\nimport { JsonConverter } from './JsonConverter';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * JSON converter for DateOnly type.\n */\nexport class DateOnlyJsonConverter extends JsonConverter<DateOnly> {\n /** @inheritdoc */\n get type(): Constructor<DateOnly> {\n return DateOnly;\n }\n\n /** @inheritdoc */\n read(value: any): DateOnly {\n return DateOnly.parse(value.toString());\n }\n\n /** @inheritdoc */\n write(value: any): any {\n return value?.toString() ?? '';\n }\n}\n"],"names":[],"mappings":";;;AAYM,MAAO,qBAAsB,SAAQ,aAAuB,CAAA;AAE9D,IAAA,IAAI,IAAI,GAAA;AACJ,QAAA,OAAO,QAAQ;IACnB;AAGA,IAAA,IAAI,CAAC,KAAU,EAAA;QACX,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC3C;AAGA,IAAA,KAAK,CAAC,KAAU,EAAA;AACZ,QAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE;IAClC;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonConverter.d.ts","sourceRoot":"","sources":["../../../json/JsonConverter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAQ7C,8BAAsB,aAAa,CAAC,CAAC,GAAG,GAAG;IAIvC,QAAQ,KAAK,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"JsonConverter.d.ts","sourceRoot":"","sources":["../../../json/JsonConverter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAQ7C,8BAAsB,aAAa,CAAC,CAAC,GAAG,GAAG;IAIvC,QAAQ,KAAK,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;IAYpC,UAAU,CAAC,aAAa,EAAE,WAAW,GAAG,OAAO;IAS/C,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC;IAO5B,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,GAAG,GAAG;CAChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonConverter.js","sources":["../../../json/JsonConverter.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Constructor } from '../Constructor';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Base class for JSON converters that handle serialization and deserialization of specific types.\n * Similar to System.Text.Json.Serialization.JsonConverter<T>.\n */\nexport abstract class JsonConverter<T = any> {\n /**\n * Gets the type that this converter handles.\n */\n abstract get type(): Constructor<T>;\n\n /**\n * Determines whether the converter can convert the specified type.\n * @param {Constructor} typeToConvert - The type to check.\n * @returns {boolean} True if the converter can convert the type; otherwise, false.\n */\n canConvert(typeToConvert: Constructor): boolean {\n return typeToConvert === this.type;\n }\n\n /**\n * Reads and converts the JSON to the target type.\n * @param {any} value - The value to deserialize.\n * @returns {T} The deserialized value.\n */\n abstract read(value: any): T;\n\n /**\n * Writes the value as JSON.\n * @param {T} value - The value to serialize.\n * @returns {any} The serialized value.\n */\n abstract write(value: T): any;\n}\n"],"names":[],"mappings":"MAWsB,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"JsonConverter.js","sources":["../../../json/JsonConverter.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Constructor } from '../Constructor';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Base class for JSON converters that handle serialization and deserialization of specific types.\n * Similar to System.Text.Json.Serialization.JsonConverter<T>.\n */\nexport abstract class JsonConverter<T = any> {\n /**\n * Gets the type that this converter handles.\n */\n abstract get type(): Constructor<T>;\n\n /**\n * Determines whether the converter can convert the specified type.\n * @param {Constructor} typeToConvert - The type to check.\n * @returns {boolean} True if the converter can convert the type; otherwise, false.\n * @deprecated Not called by `JsonSerializer` and scheduled for removal in the next major version.\n * A converter is resolved by the type it declares through {@link type}, which is what this would\n * answer anyway, so overriding it has no effect - register a converter per type instead. Wiring it\n * into the lookup is not the plan either: it would force a scan of every converter on the path\n * taken by every plain object, to serve a case a second registration already covers.\n */\n canConvert(typeToConvert: Constructor): boolean {\n return typeToConvert === this.type;\n }\n\n /**\n * Reads and converts the JSON to the target type.\n * @param {any} value - The value to deserialize.\n * @returns {T} The deserialized value.\n */\n abstract read(value: any): T;\n\n /**\n * Writes the value as JSON.\n * @param {T} value - The value to serialize.\n * @returns {any} The serialized value.\n */\n abstract write(value: T): any;\n}\n"],"names":[],"mappings":"MAWsB,aAAa,CAAA;AAgB/B,IAAA,UAAU,CAAC,aAA0B,EAAA;AACjC,QAAA,OAAO,aAAa,KAAK,IAAI,CAAC,IAAI;IACtC;AAeH;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Constructor } from '../Constructor';
|
|
2
|
+
import { TimeOnly } from '../TimeOnly';
|
|
3
|
+
import { JsonConverter } from './JsonConverter';
|
|
4
|
+
export declare class TimeOnlyJsonConverter extends JsonConverter<TimeOnly> {
|
|
5
|
+
get type(): Constructor<TimeOnly>;
|
|
6
|
+
read(value: any): TimeOnly;
|
|
7
|
+
write(value: any): any;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=TimeOnlyJsonConverter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeOnlyJsonConverter.d.ts","sourceRoot":"","sources":["../../../json/TimeOnlyJsonConverter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAOhD,qBAAa,qBAAsB,SAAQ,aAAa,CAAC,QAAQ,CAAC;IAE9D,IAAI,IAAI,IAAI,WAAW,CAAC,QAAQ,CAAC,CAEhC;IAGD,IAAI,CAAC,KAAK,EAAE,GAAG,GAAG,QAAQ;IAK1B,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG;CAGzB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TimeOnly } from '../TimeOnly.js';
|
|
2
|
+
import { JsonConverter } from './JsonConverter.js';
|
|
3
|
+
|
|
4
|
+
class TimeOnlyJsonConverter extends JsonConverter {
|
|
5
|
+
get type() {
|
|
6
|
+
return TimeOnly;
|
|
7
|
+
}
|
|
8
|
+
read(value) {
|
|
9
|
+
return TimeOnly.parse(value.toString());
|
|
10
|
+
}
|
|
11
|
+
write(value) {
|
|
12
|
+
return value?.toString() ?? '';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { TimeOnlyJsonConverter };
|
|
17
|
+
//# sourceMappingURL=TimeOnlyJsonConverter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeOnlyJsonConverter.js","sources":["../../../json/TimeOnlyJsonConverter.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Constructor } from '../Constructor';\nimport { TimeOnly } from '../TimeOnly';\nimport { JsonConverter } from './JsonConverter';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * JSON converter for TimeOnly type.\n */\nexport class TimeOnlyJsonConverter extends JsonConverter<TimeOnly> {\n /** @inheritdoc */\n get type(): Constructor<TimeOnly> {\n return TimeOnly;\n }\n\n /** @inheritdoc */\n read(value: any): TimeOnly {\n return TimeOnly.parse(value.toString());\n }\n\n /** @inheritdoc */\n write(value: any): any {\n return value?.toString() ?? '';\n }\n}\n"],"names":[],"mappings":";;;AAYM,MAAO,qBAAsB,SAAQ,aAAuB,CAAA;AAE9D,IAAA,IAAI,IAAI,GAAA;AACJ,QAAA,OAAO,QAAQ;IACnB;AAGA,IAAA,IAAI,CAAC,KAAU,EAAA;QACX,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC3C;AAGA,IAAA,KAAK,CAAC,KAAU,EAAA;AACZ,QAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE;IAClC;AACH;;;;"}
|
package/dist/esm/json/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './JsonConverter';
|
|
2
2
|
export * from './DateJsonConverter';
|
|
3
|
+
export * from './DateOnlyJsonConverter';
|
|
3
4
|
export * from './GuidJsonConverter';
|
|
5
|
+
export * from './TimeOnlyJsonConverter';
|
|
4
6
|
export * from './TimeSpanJsonConverter';
|
|
5
7
|
export * from './PointJsonConverter';
|
|
6
8
|
export * from './LineStringJsonConverter';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../json/index.ts"],"names":[],"mappings":"AAGA,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../json/index.ts"],"names":[],"mappings":"AAGA,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { JsonConverter } from './JsonConverter.js';
|
|
2
|
+
export { DateJsonConverter } from './DateJsonConverter.js';
|
|
3
|
+
export { DateOnlyJsonConverter } from './DateOnlyJsonConverter.js';
|
|
4
|
+
export { GuidJsonConverter } from './GuidJsonConverter.js';
|
|
5
|
+
export { TimeOnlyJsonConverter } from './TimeOnlyJsonConverter.js';
|
|
6
|
+
export { TimeSpanJsonConverter } from './TimeSpanJsonConverter.js';
|
|
7
|
+
export { PointJsonConverter } from './PointJsonConverter.js';
|
|
8
|
+
export { LineStringJsonConverter } from './LineStringJsonConverter.js';
|
|
9
|
+
export { PolygonJsonConverter } from './PolygonJsonConverter.js';
|
|
10
|
+
export { ValueMapJsonConverter } from './ValueMapJsonConverter.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Constructor } from './Constructor';
|
|
2
|
+
export declare const typeKey: unique symbol;
|
|
3
|
+
export declare const declaredTypeKey: (type: Constructor | undefined) => string | undefined;
|
|
4
|
+
export declare const typeKeyOf: (type: Constructor | undefined) => string | undefined;
|
|
5
|
+
export declare const conceptAsTypeKey = "ConceptAs";
|
|
6
|
+
export declare const valueMapTypeKey = "ValueMap";
|
|
7
|
+
//# sourceMappingURL=typeKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeKey.d.ts","sourceRoot":"","sources":["../../typeKey.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAiB5C,eAAO,MAAM,OAAO,EAAE,OAAO,MAAmD,CAAC;AAcjF,eAAO,MAAM,eAAe,GAAI,MAAM,WAAW,GAAG,SAAS,KAAG,MAAM,GAAG,SACiC,CAAC;AAW3G,eAAO,MAAM,SAAS,GAAI,MAAM,WAAW,GAAG,SAAS,KAAG,MAAM,GAAG,SAChB,CAAC;AAGpD,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAG5C,eAAO,MAAM,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const typeKey = Symbol.for('@cratis/fundamentals.typeKey');
|
|
2
|
+
const declaredTypeKey = (type) => type && Object.prototype.hasOwnProperty.call(type, typeKey) ? type[typeKey] : undefined;
|
|
3
|
+
const typeKeyOf = (type) => type ? type[typeKey] : undefined;
|
|
4
|
+
const conceptAsTypeKey = 'ConceptAs';
|
|
5
|
+
const valueMapTypeKey = 'ValueMap';
|
|
6
|
+
|
|
7
|
+
export { conceptAsTypeKey, declaredTypeKey, typeKey, typeKeyOf, valueMapTypeKey };
|
|
8
|
+
//# sourceMappingURL=typeKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeKey.js","sources":["../../typeKey.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Constructor } from './Constructor';\n\n/**\n * Identifies a type this package converts, by name rather than by the class object itself.\n *\n * `JsonSerializer` recognized a type by comparing constructors, which holds until a second copy of this\n * package is loaded into the same realm - a nested install, or one install reached as both ESM and\n * CommonJS. Each copy then had its own `Guid`, `ConceptAs` and `ValueMap` class objects and neither\n * recognized the other's, so a `Guid` crossing that boundary was written as an object rather than a\n * string, and a concept as `{\"value\": ...}` rather than its underlying value. Both silently.\n *\n * A name survives the boundary where a class object does not: the key is a registered symbol, so every\n * copy resolves the same one, and the values are plain strings.\n *\n * The key is deliberately a symbol rather than a plain static: a string static would appear in\n * `Object.keys(Guid)` and could be shadowed by an unrelated member of the same name.\n */\nexport const typeKey: unique symbol = Symbol.for('@cratis/fundamentals.typeKey');\n\n/** A type carrying the key. Only this package's own convertible types declare one. */\ntype KeyedType = Constructor & { readonly [typeKey]?: string };\n\n/**\n * Gets the key a type declares itself, ignoring any inherited from a base type.\n *\n * Converter lookup uses this, because a key is inherited: a consumer's `class CustomerId extends\n * ConceptAs<string>` reports `ConceptAs`, and registering a converter under that would take the place\n * of concept handling for every concept in the application.\n * @param {Constructor} type The type to read the key from.\n * @returns {string | undefined} The declared key, or undefined when the type declares none.\n */\nexport const declaredTypeKey = (type: Constructor | undefined): string | undefined =>\n type && Object.prototype.hasOwnProperty.call(type, typeKey) ? (type as KeyedType)[typeKey] : undefined;\n\n/**\n * Gets the key a type carries, whether it declares the key or inherits it from a base type.\n *\n * This is what makes a concept recognizable across copies: the key is a static, and a static is\n * inherited through the constructor's prototype chain, so every type deriving from `ConceptAs` reports\n * `ConceptAs` without anything having to compare class objects.\n * @param {Constructor} type The type to read the key from.\n * @returns {string | undefined} The key carried, or undefined when the type carries none.\n */\nexport const typeKeyOf = (type: Constructor | undefined): string | undefined =>\n type ? (type as KeyedType)[typeKey] : undefined;\n\n/** The key every type deriving from `ConceptAs` carries. */\nexport const conceptAsTypeKey = 'ConceptAs';\n\n/** The key `ValueMap` declares. */\nexport const valueMapTypeKey = 'ValueMap';\n"],"names":[],"mappings":"AAoBO,MAAM,OAAO,GAAkB,MAAM,CAAC,GAAG,CAAC,8BAA8B;AAcxE,MAAM,eAAe,GAAG,CAAC,IAA6B,KACzD,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,GAAI,IAAkB,CAAC,OAAO,CAAC,GAAG;MAWpF,SAAS,GAAG,CAAC,IAA6B,KACnD,IAAI,GAAI,IAAkB,CAAC,OAAO,CAAC,GAAG;AAGnC,MAAM,gBAAgB,GAAG;AAGzB,MAAM,eAAe,GAAG;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineString.d.ts","sourceRoot":"","sources":["../../geospatial/LineString.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"LineString.d.ts","sourceRoot":"","sources":["../../geospatial/LineString.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAKrC,qBAAa,UAAU;IACnB,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,gBAAgB;IAEzC,WAAW,EAAG,KAAK,EAAE,CAAC;gBAMV,WAAW,EAAE,KAAK,EAAE;IAWhC,MAAM,IAAI,MAAM;CAMnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineString.js","sourceRoot":"","sources":["../../geospatial/LineString.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LineString.js","sourceRoot":"","sources":["../../geospatial/LineString.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAKrC,MAAM,OAAO,UAAU;IACnB,MAAM,CAAU,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC;IAEzC,WAAW,CAAW;IAMtB,YAAY,WAAoB;QAC5B,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC9D,CAAC;QACD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;IAMD,MAAM;QACF,OAAO;YACH,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;SACpE,CAAC;IACN,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Point.d.ts","sourceRoot":"","sources":["../../geospatial/Point.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Point.d.ts","sourceRoot":"","sources":["../../geospatial/Point.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAKrC,qBAAa,KAAK;IACd,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,WAAW;IAGpC,SAAS,EAAG,MAAM,CAAC;IAGnB,QAAQ,EAAG,MAAM,CAAC;gBAON,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAS/C,MAAM,IAAI,MAAM;CAMnB"}
|
package/dist/geospatial/Point.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Point.js","sourceRoot":"","sources":["../../geospatial/Point.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"Point.js","sourceRoot":"","sources":["../../geospatial/Point.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAKrC,MAAM,OAAO,KAAK;IACd,MAAM,CAAU,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAGpC,SAAS,CAAU;IAGnB,QAAQ,CAAU;IAOlB,YAAY,SAAiB,EAAE,QAAgB;QAC3C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAMD,MAAM;QACF,OAAO;YACH,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC;SAC/C,CAAC;IACN,CAAC;;AAxBD;IADC,KAAK,CAAC,MAAM,CAAC;;wCACK;AAGnB;IADC,KAAK,CAAC,MAAM,CAAC;;uCACI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Polygon.d.ts","sourceRoot":"","sources":["../../geospatial/Polygon.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Polygon.d.ts","sourceRoot":"","sources":["../../geospatial/Polygon.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAKrC,qBAAa,OAAO;IAChB,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,aAAa;IAEtC,KAAK,EAAG,UAAU,CAAC;IACnB,KAAK,EAAG,UAAU,EAAE,CAAC;gBAOT,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,UAAU,EAAE;IASnD,MAAM,IAAI,MAAM;CAUnB"}
|