@rvoh/dream 2.2.3 → 2.3.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (298) hide show
  1. package/dist/cjs/src/Dream.js +5 -5
  2. package/dist/cjs/src/db/dataTypes.js +1 -0
  3. package/dist/cjs/src/db/index.js +2 -2
  4. package/dist/cjs/src/dream/QueryDriver/Base.js +2 -2
  5. package/dist/cjs/src/dream/QueryDriver/Kysely.js +2 -2
  6. package/dist/cjs/src/dream/QueryDriver/helpers/kysely/checkForNeedToBeRunMigrations.js +2 -2
  7. package/dist/cjs/src/dream/QueryDriver/helpers/kysely/migrationFolderPath.js +6 -1
  8. package/dist/cjs/src/dream/QueryDriver/helpers/kysely/runMigration.js +2 -2
  9. package/dist/cjs/src/dream/internal/saveDream.js +1 -1
  10. package/dist/cjs/src/dream/internal/softDeleteDream.js +1 -1
  11. package/dist/cjs/src/dream-app/helpers/globalModelKeyFromPath.js +5 -2
  12. package/dist/cjs/src/dream-app/helpers/globalSerializerKeyFromPath.js +5 -2
  13. package/dist/cjs/src/dream-app/helpers/normalizeFilePath.js +3 -0
  14. package/dist/cjs/src/dream-app/index.js +3 -3
  15. package/dist/cjs/src/helpers/areEqual.js +2 -2
  16. package/dist/cjs/src/helpers/cli/ASTBuilder.js +2 -2
  17. package/dist/cjs/src/helpers/cloneDeepSafe.js +2 -2
  18. package/dist/cjs/src/helpers/customPgParsers.js +2 -2
  19. package/dist/cjs/src/helpers/loadRepl.js +2 -2
  20. package/dist/cjs/src/helpers/path/PathHelpers.js +27 -0
  21. package/dist/cjs/src/helpers/path/convertToFileURL.js +7 -0
  22. package/dist/cjs/src/helpers/path/windowsSafePath.js +22 -0
  23. package/dist/cjs/src/helpers/sortBy.js +2 -2
  24. package/dist/cjs/src/helpers/sqlAttributes.js +2 -2
  25. package/dist/cjs/src/helpers/stringCasing.js +2 -2
  26. package/dist/cjs/src/package-exports/errors.js +2 -1
  27. package/dist/cjs/src/package-exports/index.js +2 -2
  28. package/dist/cjs/src/package-exports/system.js +1 -0
  29. package/dist/cjs/src/serializer/SerializerRenderer.js +2 -2
  30. package/dist/cjs/src/types/calendardate.js +1 -0
  31. package/dist/cjs/src/types/datetime.js +1 -0
  32. package/dist/cjs/src/utils/datetime/CalendarDate.js +489 -0
  33. package/dist/cjs/src/utils/datetime/DateTime.js +1140 -0
  34. package/dist/cjs/src/utils/datetime/helpers/isoTimeDecimalString.js +8 -0
  35. package/dist/cjs/src/utils/datetime/helpers/microsecondParts.js +16 -0
  36. package/dist/cjs/src/utils/datetime/helpers/replaceISOMicroseconds.js +10 -0
  37. package/dist/esm/src/Dream.js +5 -5
  38. package/dist/esm/src/db/dataTypes.js +1 -0
  39. package/dist/esm/src/db/index.js +2 -2
  40. package/dist/esm/src/dream/QueryDriver/Base.js +2 -2
  41. package/dist/esm/src/dream/QueryDriver/Kysely.js +2 -2
  42. package/dist/esm/src/dream/QueryDriver/helpers/kysely/checkForNeedToBeRunMigrations.js +2 -2
  43. package/dist/esm/src/dream/QueryDriver/helpers/kysely/migrationFolderPath.js +6 -1
  44. package/dist/esm/src/dream/QueryDriver/helpers/kysely/runMigration.js +2 -2
  45. package/dist/esm/src/dream/internal/saveDream.js +1 -1
  46. package/dist/esm/src/dream/internal/softDeleteDream.js +1 -1
  47. package/dist/esm/src/dream-app/helpers/globalModelKeyFromPath.js +5 -2
  48. package/dist/esm/src/dream-app/helpers/globalSerializerKeyFromPath.js +5 -2
  49. package/dist/esm/src/dream-app/helpers/normalizeFilePath.js +3 -0
  50. package/dist/esm/src/dream-app/index.js +3 -3
  51. package/dist/esm/src/helpers/areEqual.js +2 -2
  52. package/dist/esm/src/helpers/cli/ASTBuilder.js +2 -2
  53. package/dist/esm/src/helpers/cloneDeepSafe.js +2 -2
  54. package/dist/esm/src/helpers/customPgParsers.js +2 -2
  55. package/dist/esm/src/helpers/loadRepl.js +2 -2
  56. package/dist/esm/src/helpers/path/PathHelpers.js +27 -0
  57. package/dist/esm/src/helpers/path/convertToFileURL.js +7 -0
  58. package/dist/esm/src/helpers/path/windowsSafePath.js +22 -0
  59. package/dist/esm/src/helpers/sortBy.js +2 -2
  60. package/dist/esm/src/helpers/sqlAttributes.js +2 -2
  61. package/dist/esm/src/helpers/stringCasing.js +2 -2
  62. package/dist/esm/src/package-exports/errors.js +2 -1
  63. package/dist/esm/src/package-exports/index.js +2 -2
  64. package/dist/esm/src/package-exports/system.js +1 -0
  65. package/dist/esm/src/serializer/SerializerRenderer.js +2 -2
  66. package/dist/esm/src/types/calendardate.js +1 -0
  67. package/dist/esm/src/types/datetime.js +1 -0
  68. package/dist/esm/src/utils/datetime/CalendarDate.js +489 -0
  69. package/dist/esm/src/utils/datetime/DateTime.js +1140 -0
  70. package/dist/esm/src/utils/datetime/helpers/isoTimeDecimalString.js +8 -0
  71. package/dist/esm/src/utils/datetime/helpers/microsecondParts.js +16 -0
  72. package/dist/esm/src/utils/datetime/helpers/replaceISOMicroseconds.js +10 -0
  73. package/dist/types/src/Dream.d.ts +1 -1
  74. package/dist/types/src/db/dataTypes.d.ts +2 -2
  75. package/dist/types/src/dream-app/helpers/normalizeFilePath.d.ts +1 -0
  76. package/dist/types/src/helpers/customPgParsers.d.ts +3 -2
  77. package/dist/types/src/helpers/path/PathHelpers.d.ts +21 -0
  78. package/dist/types/src/helpers/path/convertToFileURL.d.ts +1 -0
  79. package/dist/types/src/helpers/path/windowsSafePath.d.ts +20 -0
  80. package/dist/types/src/helpers/range.d.ts +2 -2
  81. package/dist/types/src/helpers/sort.d.ts +2 -2
  82. package/dist/types/src/helpers/sortBy.d.ts +2 -2
  83. package/dist/types/src/package-exports/errors.d.ts +2 -1
  84. package/dist/types/src/package-exports/index.d.ts +2 -2
  85. package/dist/types/src/package-exports/system.d.ts +1 -0
  86. package/dist/types/src/package-exports/types.d.ts +2 -0
  87. package/dist/types/src/types/associations/shared.d.ts +2 -2
  88. package/dist/types/src/types/associations/shared.ts +2 -2
  89. package/dist/types/src/types/calendardate.d.ts +4 -0
  90. package/dist/types/src/types/calendardate.ts +8 -0
  91. package/dist/types/src/types/datetime.d.ts +102 -0
  92. package/dist/types/src/types/datetime.ts +141 -0
  93. package/dist/types/src/types/dream.d.ts +2 -2
  94. package/dist/types/src/types/dream.ts +2 -2
  95. package/dist/types/src/types/moduleDeclarations/luxon.d.ts +5 -6
  96. package/dist/types/src/utils/datetime/CalendarDate.d.ts +375 -0
  97. package/dist/types/src/utils/datetime/DateTime.d.ts +773 -0
  98. package/dist/types/src/utils/datetime/helpers/isoTimeDecimalString.d.ts +4 -0
  99. package/dist/types/src/utils/datetime/helpers/microsecondParts.d.ts +10 -0
  100. package/dist/types/src/utils/datetime/helpers/replaceISOMicroseconds.d.ts +3 -0
  101. package/docs/assets/highlight.css +7 -0
  102. package/docs/assets/navigation.js +1 -1
  103. package/docs/assets/search.js +1 -1
  104. package/docs/classes/db.DreamMigrationHelpers.html +9 -9
  105. package/docs/classes/db.KyselyQueryDriver.html +33 -33
  106. package/docs/classes/db.PostgresQueryDriver.html +34 -34
  107. package/docs/classes/db.QueryDriverBase.html +32 -32
  108. package/docs/classes/errors.CheckConstraintViolation.html +3 -3
  109. package/docs/classes/errors.ColumnOverflow.html +3 -3
  110. package/docs/classes/errors.CreateOrFindByFailedToCreateAndFind.html +3 -3
  111. package/docs/classes/errors.DataIncompatibleWithDatabaseField.html +3 -3
  112. package/docs/classes/errors.DataTypeColumnTypeMismatch.html +3 -3
  113. package/docs/classes/errors.GlobalNameNotSet.html +3 -3
  114. package/docs/classes/errors.InvalidCalendarDate.html +7 -2
  115. package/docs/classes/errors.InvalidDateTime.html +17 -0
  116. package/docs/classes/errors.MissingSerializersDefinition.html +3 -3
  117. package/docs/classes/errors.NonLoadedAssociation.html +3 -3
  118. package/docs/classes/errors.NotNullViolation.html +3 -3
  119. package/docs/classes/errors.RecordNotFound.html +3 -3
  120. package/docs/classes/errors.ValidationError.html +3 -3
  121. package/docs/classes/index.CalendarDate.html +195 -2
  122. package/docs/classes/index.DateTime.html +485 -0
  123. package/docs/classes/index.Decorators.html +19 -19
  124. package/docs/classes/index.Dream.html +121 -121
  125. package/docs/classes/index.DreamApp.html +5 -5
  126. package/docs/classes/index.DreamTransaction.html +2 -2
  127. package/docs/classes/index.Env.html +2 -2
  128. package/docs/classes/index.Query.html +59 -59
  129. package/docs/classes/system.CliFileWriter.html +2 -2
  130. package/docs/classes/system.DreamBin.html +2 -2
  131. package/docs/classes/system.DreamCLI.html +5 -5
  132. package/docs/classes/system.DreamImporter.html +2 -2
  133. package/docs/classes/system.DreamLogos.html +2 -2
  134. package/docs/classes/system.DreamSerializerBuilder.html +8 -8
  135. package/docs/classes/system.ObjectSerializerBuilder.html +8 -8
  136. package/docs/classes/system.PathHelpers.html +13 -0
  137. package/docs/classes/utils.Encrypt.html +2 -2
  138. package/docs/classes/utils.Range.html +2 -2
  139. package/docs/functions/db.closeAllDbConnections.html +1 -1
  140. package/docs/functions/db.dreamDbConnections.html +1 -1
  141. package/docs/functions/db.untypedDb.html +1 -1
  142. package/docs/functions/db.validateColumn.html +1 -1
  143. package/docs/functions/db.validateTable.html +1 -1
  144. package/docs/functions/errors.pgErrorType.html +1 -1
  145. package/docs/functions/index.DreamSerializer.html +1 -1
  146. package/docs/functions/index.ObjectSerializer.html +1 -1
  147. package/docs/functions/index.ReplicaSafe.html +1 -1
  148. package/docs/functions/index.STI.html +1 -1
  149. package/docs/functions/index.SoftDelete.html +1 -1
  150. package/docs/functions/utils.camelize.html +1 -1
  151. package/docs/functions/utils.capitalize.html +1 -1
  152. package/docs/functions/utils.cloneDeepSafe.html +1 -1
  153. package/docs/functions/utils.compact.html +2 -2
  154. package/docs/functions/utils.groupBy.html +1 -1
  155. package/docs/functions/utils.hyphenize.html +1 -1
  156. package/docs/functions/utils.intersection.html +1 -1
  157. package/docs/functions/utils.isEmpty.html +1 -1
  158. package/docs/functions/utils.normalizeUnicode.html +1 -1
  159. package/docs/functions/utils.pascalize.html +1 -1
  160. package/docs/functions/utils.percent.html +1 -1
  161. package/docs/functions/utils.range-1.html +1 -1
  162. package/docs/functions/utils.round.html +1 -1
  163. package/docs/functions/utils.sanitizeString.html +1 -1
  164. package/docs/functions/utils.snakeify.html +1 -1
  165. package/docs/functions/utils.sort.html +1 -1
  166. package/docs/functions/utils.sortBy.html +1 -1
  167. package/docs/functions/utils.sortObjectByKey.html +1 -1
  168. package/docs/functions/utils.sortObjectByValue.html +1 -1
  169. package/docs/functions/utils.uncapitalize.html +1 -1
  170. package/docs/functions/utils.uniq.html +1 -1
  171. package/docs/interfaces/openapi.OpenapiDescription.html +2 -2
  172. package/docs/interfaces/openapi.OpenapiSchemaProperties.html +1 -1
  173. package/docs/interfaces/openapi.OpenapiSchemaPropertiesShorthand.html +1 -1
  174. package/docs/interfaces/openapi.OpenapiTypeFieldObject.html +1 -1
  175. package/docs/interfaces/types.BelongsToStatement.html +2 -2
  176. package/docs/interfaces/types.DecoratorContext.html +2 -2
  177. package/docs/interfaces/types.DreamAppInitOptions.html +2 -2
  178. package/docs/interfaces/types.DreamAppOpts.html +2 -2
  179. package/docs/interfaces/types.DurationObject.html +12 -0
  180. package/docs/interfaces/types.EncryptOptions.html +2 -2
  181. package/docs/interfaces/types.InternalAnyTypedSerializerRendersMany.html +2 -2
  182. package/docs/interfaces/types.InternalAnyTypedSerializerRendersOne.html +2 -2
  183. package/docs/interfaces/types.SerializerRendererOpts.html +2 -2
  184. package/docs/modules/db.html +1 -1
  185. package/docs/modules/errors.html +2 -1
  186. package/docs/modules/index.html +3 -4
  187. package/docs/modules/openapi.html +1 -1
  188. package/docs/modules/system.html +2 -1
  189. package/docs/modules/types.html +6 -2
  190. package/docs/modules/utils.html +1 -1
  191. package/docs/types/openapi.CommonOpenapiSchemaObjectFields.html +1 -1
  192. package/docs/types/openapi.OpenapiAllTypes.html +1 -1
  193. package/docs/types/openapi.OpenapiFormats.html +1 -1
  194. package/docs/types/openapi.OpenapiNumberFormats.html +1 -1
  195. package/docs/types/openapi.OpenapiPrimitiveBaseTypes.html +1 -1
  196. package/docs/types/openapi.OpenapiPrimitiveTypes.html +1 -1
  197. package/docs/types/openapi.OpenapiSchemaArray.html +1 -1
  198. package/docs/types/openapi.OpenapiSchemaArrayShorthand.html +1 -1
  199. package/docs/types/openapi.OpenapiSchemaBase.html +1 -1
  200. package/docs/types/openapi.OpenapiSchemaBody.html +1 -1
  201. package/docs/types/openapi.OpenapiSchemaBodyShorthand.html +1 -1
  202. package/docs/types/openapi.OpenapiSchemaCommonFields.html +1 -1
  203. package/docs/types/openapi.OpenapiSchemaExpressionAllOf.html +1 -1
  204. package/docs/types/openapi.OpenapiSchemaExpressionAnyOf.html +1 -1
  205. package/docs/types/openapi.OpenapiSchemaExpressionOneOf.html +1 -1
  206. package/docs/types/openapi.OpenapiSchemaExpressionRef.html +1 -1
  207. package/docs/types/openapi.OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
  208. package/docs/types/openapi.OpenapiSchemaInteger.html +1 -1
  209. package/docs/types/openapi.OpenapiSchemaNull.html +1 -1
  210. package/docs/types/openapi.OpenapiSchemaNumber.html +1 -1
  211. package/docs/types/openapi.OpenapiSchemaObject.html +1 -1
  212. package/docs/types/openapi.OpenapiSchemaObjectAllOf.html +1 -1
  213. package/docs/types/openapi.OpenapiSchemaObjectAllOfShorthand.html +1 -1
  214. package/docs/types/openapi.OpenapiSchemaObjectAnyOf.html +1 -1
  215. package/docs/types/openapi.OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  216. package/docs/types/openapi.OpenapiSchemaObjectBase.html +1 -1
  217. package/docs/types/openapi.OpenapiSchemaObjectBaseShorthand.html +1 -1
  218. package/docs/types/openapi.OpenapiSchemaObjectOneOf.html +1 -1
  219. package/docs/types/openapi.OpenapiSchemaObjectOneOfShorthand.html +1 -1
  220. package/docs/types/openapi.OpenapiSchemaObjectShorthand.html +1 -1
  221. package/docs/types/openapi.OpenapiSchemaPrimitiveGeneric.html +1 -1
  222. package/docs/types/openapi.OpenapiSchemaShorthandExpressionAllOf.html +1 -1
  223. package/docs/types/openapi.OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
  224. package/docs/types/openapi.OpenapiSchemaShorthandExpressionOneOf.html +1 -1
  225. package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
  226. package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
  227. package/docs/types/openapi.OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  228. package/docs/types/openapi.OpenapiSchemaString.html +1 -1
  229. package/docs/types/openapi.OpenapiShorthandAllTypes.html +1 -1
  230. package/docs/types/openapi.OpenapiShorthandPrimitiveBaseTypes.html +1 -1
  231. package/docs/types/openapi.OpenapiShorthandPrimitiveTypes.html +1 -1
  232. package/docs/types/openapi.OpenapiTypeField.html +1 -1
  233. package/docs/types/system.DreamAppAllowedPackageManagersEnum.html +1 -1
  234. package/docs/types/types.CalendarDateDurationUnit.html +1 -0
  235. package/docs/types/types.Camelized.html +1 -1
  236. package/docs/types/types.DbConnectionType.html +1 -1
  237. package/docs/types/types.DbTypes.html +1 -1
  238. package/docs/types/types.DreamAssociationMetadata.html +1 -1
  239. package/docs/types/types.DreamAttributes.html +1 -1
  240. package/docs/types/types.DreamClassAssociationAndStatement.html +1 -1
  241. package/docs/types/types.DreamClassColumn.html +1 -1
  242. package/docs/types/types.DreamColumn.html +1 -1
  243. package/docs/types/types.DreamColumnNames.html +1 -1
  244. package/docs/types/types.DreamLogLevel.html +1 -1
  245. package/docs/types/types.DreamLogger.html +1 -1
  246. package/docs/types/types.DreamModelSerializerType.html +1 -1
  247. package/docs/types/types.DreamOrViewModelClassSerializerKey.html +1 -1
  248. package/docs/types/types.DreamOrViewModelSerializerKey.html +1 -1
  249. package/docs/types/types.DreamParamSafeAttributes.html +1 -1
  250. package/docs/types/types.DreamParamSafeColumnNames.html +1 -1
  251. package/docs/types/types.DreamSerializable.html +1 -1
  252. package/docs/types/types.DreamSerializableArray.html +1 -1
  253. package/docs/types/types.DreamSerializerKey.html +1 -1
  254. package/docs/types/types.DreamSerializers.html +1 -1
  255. package/docs/types/types.DreamVirtualColumns.html +1 -1
  256. package/docs/types/types.DurationUnit.html +4 -0
  257. package/docs/types/types.EncryptAlgorithm.html +1 -1
  258. package/docs/types/types.HasManyStatement.html +1 -1
  259. package/docs/types/types.HasOneStatement.html +1 -1
  260. package/docs/types/types.Hyphenized.html +1 -1
  261. package/docs/types/types.Pascalized.html +1 -1
  262. package/docs/types/types.PrimaryKeyType.html +1 -1
  263. package/docs/types/types.RoundingPrecision.html +1 -1
  264. package/docs/types/types.SerializerCasing.html +1 -1
  265. package/docs/types/types.SimpleObjectSerializerType.html +1 -1
  266. package/docs/types/types.Snakeified.html +1 -1
  267. package/docs/types/types.StrictInterface.html +1 -1
  268. package/docs/types/types.UpdateableAssociationProperties.html +1 -1
  269. package/docs/types/types.UpdateableProperties.html +1 -1
  270. package/docs/types/types.ValidationType.html +1 -1
  271. package/docs/types/types.ViewModel.html +1 -1
  272. package/docs/types/types.ViewModelClass.html +1 -1
  273. package/docs/types/types.WeekdayName.html +2 -0
  274. package/docs/types/types.WhereStatementForDream.html +1 -1
  275. package/docs/types/types.WhereStatementForDreamClass.html +1 -1
  276. package/docs/variables/index.DreamConst.html +1 -1
  277. package/docs/variables/index.ops.html +1 -1
  278. package/docs/variables/openapi.openapiPrimitiveTypes-1.html +1 -1
  279. package/docs/variables/openapi.openapiShorthandPrimitiveTypes-1.html +1 -1
  280. package/docs/variables/system.DreamAppAllowedPackageManagersEnumValues.html +1 -1
  281. package/docs/variables/system.primaryKeyTypes.html +1 -1
  282. package/package.json +3 -2
  283. package/dist/cjs/src/helpers/CalendarDate.js +0 -151
  284. package/dist/cjs/src/helpers/DateTime.js +0 -4
  285. package/dist/esm/src/helpers/CalendarDate.js +0 -151
  286. package/dist/esm/src/helpers/DateTime.js +0 -4
  287. package/dist/types/src/helpers/CalendarDate.d.ts +0 -56
  288. package/dist/types/src/helpers/DateTime.d.ts +0 -6
  289. package/dist/types/src/types/luxon/_util.d.ts +0 -20
  290. package/dist/types/src/types/luxon/datetime.d.ts +0 -1759
  291. package/dist/types/src/types/luxon/duration.d.ts +0 -494
  292. package/dist/types/src/types/luxon/info.d.ts +0 -217
  293. package/dist/types/src/types/luxon/interval.d.ts +0 -357
  294. package/dist/types/src/types/luxon/misc.d.ts +0 -67
  295. package/dist/types/src/types/luxon/settings.d.ts +0 -91
  296. package/dist/types/src/types/luxon/zone.d.ts +0 -172
  297. package/docs/types/index.DateTime.html +0 -1
  298. package/docs/variables/index.DateTime-1.html +0 -1
@@ -1,494 +0,0 @@
1
- import { CanBeInvalid, DefaultValidity, IfValid, Invalid, Valid } from './_util.js'
2
- import { ConversionAccuracy } from './datetime.js'
3
- import { NumberingSystem } from './misc.js'
4
-
5
- export interface DurationOptions {
6
- locale?: string | undefined
7
- numberingSystem?: NumberingSystem | undefined
8
- conversionAccuracy?: ConversionAccuracy | undefined
9
- }
10
-
11
- export interface DurationObjectUnits {
12
- years?: number | undefined
13
- quarters?: number | undefined
14
- months?: number | undefined
15
- weeks?: number | undefined
16
- days?: number | undefined
17
- hours?: number | undefined
18
- minutes?: number | undefined
19
- seconds?: number | undefined
20
- milliseconds?: number | undefined
21
- }
22
-
23
- export interface DurationLikeObject extends DurationObjectUnits {
24
- year?: number | undefined
25
- quarter?: number | undefined
26
- month?: number | undefined
27
- week?: number | undefined
28
- day?: number | undefined
29
- hour?: number | undefined
30
- minute?: number | undefined
31
- second?: number | undefined
32
- millisecond?: number | undefined
33
- }
34
-
35
- export type DurationUnit = keyof DurationLikeObject
36
- export type DurationUnits = DurationUnit | DurationUnit[]
37
-
38
- export type ToISOFormat = 'basic' | 'extended'
39
-
40
- export interface ToISOTimeDurationOptions {
41
- /**
42
- * Include the `T` prefix
43
- * @default false
44
- */
45
- includePrefix?: boolean | undefined
46
- /**
47
- * Exclude milliseconds from the format if they are 0
48
- * @default false
49
- */
50
- suppressMilliseconds?: boolean | undefined
51
- /**
52
- * Exclude seconds from the format if they are 0
53
- * @default false
54
- */
55
- suppressSeconds?: boolean | undefined
56
- /**
57
- * Choose between the basic and extended format
58
- * @default 'extended'
59
- */
60
- format?: ToISOFormat | undefined
61
- }
62
-
63
- export interface ToHumanDurationOptions extends Intl.NumberFormatOptions {
64
- listStyle?: 'long' | 'short' | 'narrow' | undefined
65
- }
66
-
67
- /**
68
- * Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
69
- *
70
- * @deprecated Use DurationLike instead.
71
- */
72
- export type DurationInput = Duration | number | DurationLikeObject
73
-
74
- /**
75
- * Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
76
- */
77
- export type DurationLike = Duration | DurationLikeObject | number
78
-
79
- export type DurationMaybeValid = CanBeInvalid extends true ? Duration<Valid> | Duration<Invalid> : Duration
80
-
81
- /**
82
- * A Duration object represents a period of time, like "2 months" or "1 day, 1 hour".
83
- * Conceptually, it is just a map of units to their quantities, accompanied by some additional configuration and methods for creating, parsing, interrogating, transforming, and formatting them.
84
- * They can be used on their own or in conjunction with other Luxon types; for example, you can use {@link DateTime.plus} to add a Duration object to a DateTime, producing another DateTime.
85
- *
86
- * Here is a brief overview of commonly used methods and getters in Duration:
87
- *
88
- * * **Creation** To create a Duration, use {@link Duration.fromMillis}, {@link Duration.fromObject}, or {@link Duration.fromISO}.
89
- * * **Unit values** See the {@link Duration#years}, {@link Duration.months}, {@link Duration#weeks}, {@link Duration#days}, {@link Duration#hours}, {@link Duration#minutes},
90
- * * {@link Duration#seconds}, {@link Duration#milliseconds} accessors.
91
- * * **Configuration** See {@link Duration#locale} and {@link Duration#numberingSystem} accessors.
92
- * * **Transformation** To create new Durations out of old ones use {@link Duration#plus}, {@link Duration#minus}, {@link Duration#normalize}, {@link Duration#set}, {@link Duration#reconfigure},
93
- * * {@link Duration#shiftTo}, and {@link Duration#negate}.
94
- * * **Output** To convert the Duration into other representations, see {@link Duration#as}, {@link Duration#toISO}, {@link Duration#toFormat}, and {@link Duration#toJSON}
95
- *
96
- * There's are more methods documented below. In addition, for more information on subtler topics like internationalization and validity, see the external documentation.
97
- */
98
- export class Duration<IsValid extends boolean = DefaultValidity> {
99
- /**
100
- * Create Duration from a number of milliseconds.
101
- *
102
- * @param count - of milliseconds
103
- * @param opts - options for parsing
104
- * @param opts.locale - the locale to use
105
- * @param opts.numberingSystem - the numbering system to use
106
- * @param opts.conversionAccuracy - the conversion system to use
107
- */
108
- static fromMillis(count: number, opts?: DurationOptions): Duration<Valid>
109
-
110
- /**
111
- * Create a Duration from a JavaScript object with keys like 'years' and 'hours'.
112
- * If this object is empty then a zero milliseconds duration is returned.
113
- *
114
- * @param obj - the object to create the Duration from
115
- * @param obj.years
116
- * @param obj.quarters
117
- * @param obj.months
118
- * @param obj.weeks
119
- * @param obj.days
120
- * @param obj.hours
121
- * @param obj.minutes
122
- * @param obj.seconds
123
- * @param obj.milliseconds
124
- * @param opts - options for creating this Duration. Defaults to {}.
125
- * @param opts.locale - the locale to use. Defaults to 'en-US'.
126
- * @param opts.numberingSystem - the numbering system to use
127
- * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'.
128
- */
129
- static fromObject(obj: DurationLikeObject, opts?: DurationOptions): Duration<Valid>
130
-
131
- /**
132
- * Create a Duration from DurationLike.
133
- *
134
- * @param durationLike
135
- * Either a Luxon Duration, a number of milliseconds, or the object argument to Duration.fromObject()
136
- */
137
- static fromDurationLike(durationLike: DurationLike): Duration<Valid>
138
-
139
- /**
140
- * Create a Duration from an ISO 8601 duration string.
141
- * @see https://en.wikipedia.org/wiki/ISO_8601#Durations
142
- *
143
- * @param text - text to parse
144
- * @param opts - options for parsing
145
- * @param opts.locale - the locale to use. Defaults to 'en-US'.
146
- * @param opts.numberingSystem - the numbering system to use
147
- * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'.
148
- *
149
- * @example
150
- * Duration.fromISO('P3Y6M1W4DT12H30M5S').toObject() //=> { years: 3, months: 6, weeks: 1, days: 4, hours: 12, minutes: 30, seconds: 5 }
151
- * @example
152
- * Duration.fromISO('PT23H').toObject() //=> { hours: 23 }
153
- * @example
154
- * Duration.fromISO('P5Y3M').toObject() //=> { years: 5, months: 3 }
155
- */
156
- static fromISO(text: string, opts?: DurationOptions): DurationMaybeValid
157
-
158
- /**
159
- * Create a Duration from an ISO 8601 time string.
160
- * @see https://en.wikipedia.org/wiki/ISO_8601#Times
161
- *
162
- * @param text - text to parse
163
- * @param opts - options for parsing
164
- * @param opts.locale - the locale to use. Defaults to 'en-US'.
165
- * @param opts.numberingSystem - the numbering system to use
166
- * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'.
167
- *
168
- * @example
169
- * Duration.fromISOTime('11:22:33.444').toObject() //=> { hours: 11, minutes: 22, seconds: 33, milliseconds: 444 }
170
- * @example
171
- * Duration.fromISOTime('11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }
172
- * @example
173
- * Duration.fromISOTime('T11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }
174
- * @example
175
- * Duration.fromISOTime('1100').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }
176
- * @example
177
- * Duration.fromISOTime('T1100').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }
178
- */
179
- static fromISOTime(text: string, opts?: DurationOptions): DurationMaybeValid
180
-
181
- /**
182
- * Create an invalid Duration.
183
- *
184
- * @param reason - simple string of why this datetime is invalid. Should not contain parameters or anything else data-dependent
185
- * @param explanation - longer explanation, may include parameters and other useful debugging information. Defaults to null.
186
- */
187
- static invalid(reason: string, explanation?: string): Duration<Invalid>
188
-
189
- /**
190
- * Check if an object is a Duration. Works across context boundaries
191
- *
192
- * @param o
193
- */
194
- static isDuration(o: unknown): o is DurationMaybeValid
195
-
196
- private constructor(config: unknown)
197
-
198
- /**
199
- * Get the locale of a Duration, such as 'en-GB'
200
- */
201
- get locale(): IfValid<string, null, IsValid>
202
-
203
- /**
204
- * Get the numbering system of a Duration, such as 'beng'. The numbering system is used when formatting the Duration
205
- */
206
- get numberingSystem(): IfValid<string, null, IsValid>
207
-
208
- /**
209
- * Returns a string representation of this Duration formatted according to the specified format string. You may use these tokens:
210
- * * `S` for milliseconds
211
- * * `s` for seconds
212
- * * `m` for minutes
213
- * * `h` for hours
214
- * * `d` for days
215
- * * `M` for months
216
- * * `y` for years
217
- * Notes:
218
- * * Add padding by repeating the token, e.g. "yy" pads the years to two digits, "hhhh" pads the hours out to four digits
219
- * * The duration will be converted to the set of units in the format string using {@link Duration.shiftTo} and the Duration's conversion accuracy setting.
220
- *
221
- * @param fmt - the format string
222
- * @param opts - options
223
- * @param opts.floor - floor numerical values. Defaults to true.
224
- *
225
- * @example
226
- * Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("y d s") //=> "1 6 2"
227
- * @example
228
- * Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("yy dd sss") //=> "01 06 002"
229
- * @example
230
- * Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("M S") //=> "12 518402000"
231
- */
232
- toFormat(fmt: string, opts?: { floor?: boolean | undefined }): IfValid<string, 'Invalid Duration', IsValid>
233
-
234
- /**
235
- * Returns a string representation of a Duration with all units included
236
- * To modify its behavior use the `listStyle` and any Intl.NumberFormat option, though `unitDisplay` is especially relevant. See {@link Intl.NumberFormat}.
237
- *
238
- * @example
239
- * ```js
240
- * var dur = Duration.fromObject({ days: 1, hours: 5, minutes: 6 })
241
- * dur.toHuman() //=> '1 day, 5 hours, 6 minutes'
242
- * dur.toHuman({ listStyle: "long" }) //=> '1 day, 5 hours, and 6 minutes'
243
- * dur.toHuman({ unitDisplay: "short" }) //=> '1 day, 5 hr, 6 min'
244
- * ```
245
- */
246
- toHuman(opts?: ToHumanDurationOptions): string
247
-
248
- /**
249
- * Returns a JavaScript object with this Duration's values.
250
- *
251
- * @example
252
- * Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toObject() //=> { years: 1, days: 6, seconds: 2 }
253
- */
254
- toObject(): DurationObjectUnits
255
-
256
- /**
257
- * Returns an ISO 8601-compliant string representation of this Duration.
258
- * @see https://en.wikipedia.org/wiki/ISO_8601#Durations
259
- *
260
- * @example
261
- * Duration.fromObject({ years: 3, seconds: 45 }).toISO() //=> 'P3YT45S'
262
- * @example
263
- * Duration.fromObject({ months: 4, seconds: 45 }).toISO() //=> 'P4MT45S'
264
- * @example
265
- * Duration.fromObject({ months: 5 }).toISO() //=> 'P5M'
266
- * @example
267
- * Duration.fromObject({ minutes: 5 }).toISO() //=> 'PT5M'
268
- * @example
269
- * Duration.fromObject({ milliseconds: 6 }).toISO() //=> 'PT0.006S'
270
- */
271
- toISO(): IfValid<string, null, IsValid>
272
-
273
- /**
274
- * Returns an ISO 8601-compliant string representation of this Duration, formatted as a time of day.
275
- * @see https://en.wikipedia.org/wiki/ISO_8601#Times
276
- *
277
- * @param opts - options
278
- * @param opts.suppressMilliseconds - exclude milliseconds from the format if they are 0. Defaults to false.
279
- * @param opts.suppressSeconds - exclude seconds from the format if they're 0. Defaults to false.
280
- * @param opts.includePrefix - include the `T` prefix. Defaults to false.
281
- * @param opts.format - choose between the basic and extended format. Defaults to 'extended'.
282
- *
283
- * @example
284
- * Duration.fromObject({ hours: 11 }).toISOTime() //=> '11:00:00.000'
285
- * @example
286
- * Duration.fromObject({ hours: 11 }).toISOTime({ suppressMilliseconds: true }) //=> '11:00:00'
287
- * @example
288
- * Duration.fromObject({ hours: 11 }).toISOTime({ suppressSeconds: true }) //=> '11:00'
289
- * @example
290
- * Duration.fromObject({ hours: 11 }).toISOTime({ includePrefix: true }) //=> 'T11:00:00.000'
291
- * @example
292
- * Duration.fromObject({ hours: 11 }).toISOTime({ format: 'basic' }) //=> '110000.000'
293
- */
294
- toISOTime(opts?: ToISOTimeDurationOptions): IfValid<string, null, IsValid>
295
-
296
- /**
297
- * Returns an ISO 8601 representation of this Duration appropriate for use in JSON.
298
- */
299
- toJSON(): IfValid<string, null, IsValid>
300
-
301
- /**
302
- * Returns an ISO 8601 representation of this Duration appropriate for use in debugging.
303
- */
304
- toString(): IfValid<string, null, IsValid>
305
-
306
- /**
307
- * Returns a millisecond value of this Duration.
308
- */
309
- toMillis(): IfValid<number, typeof NaN, IsValid>
310
-
311
- /**
312
- * Returns a millisecond value of this Duration. Alias of {@link toMillis}
313
- */
314
- valueOf(): IfValid<number, typeof NaN, IsValid>
315
-
316
- /**
317
- * Make this Duration longer by the specified amount. Return a newly-constructed Duration.
318
- *
319
- * @param duration - The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
320
- */
321
- plus(duration: DurationLike): this
322
-
323
- /**
324
- * Make this Duration shorter by the specified amount. Return a newly-constructed Duration.
325
- *
326
- * @param duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
327
- */
328
- minus(duration: DurationLike): this
329
-
330
- /**
331
- * Scale this Duration by the specified amount. Return a newly-constructed Duration.
332
- *
333
- * @example
334
- * Duration.fromObject({ hours: 1, minutes: 30 }).mapUnit(x => x * 2) //=> { hours: 2, minutes: 60 }
335
- * @example
336
- * Duration.fromObject({ hours: 1, minutes: 30 }).mapUnit((x, u) => u === "hour" ? x * 2 : x) //=> { hours: 2, minutes: 30 }
337
- */
338
- mapUnits(fn: (x: number, u?: DurationUnit) => number): this
339
-
340
- /**
341
- * Get the value of unit.
342
- *
343
- * @param unit - a unit such as 'minute' or 'day'
344
- *
345
- * @example
346
- * Duration.fromObject({years: 2, days: 3}).get('years') //=> 2
347
- * @example
348
- * Duration.fromObject({years: 2, days: 3}).get('months') //=> 0
349
- * @example
350
- * Duration.fromObject({years: 2, days: 3}).get('days') //=> 3
351
- */
352
- get(unit: DurationUnit): IfValid<number, typeof NaN, IsValid>
353
-
354
- /**
355
- * "Set" the values of specified units. Return a newly-constructed Duration.
356
- *
357
- * @param values - a mapping of units to numbers
358
- *
359
- * @example
360
- * dur.set({ years: 2017 })
361
- * @example
362
- * dur.set({ hours: 8, minutes: 30 })
363
- */
364
- set(values: DurationLikeObject): this
365
-
366
- /**
367
- * "Set" the locale and/or numberingSystem. Returns a newly-constructed Duration.
368
- *
369
- * @example
370
- * dur.reconfigure({ locale: 'en-GB' })
371
- */
372
- reconfigure(opts?: DurationOptions): this
373
-
374
- /**
375
- * Return the length of the duration in the specified unit.
376
- *
377
- * @param unit - a unit such as 'minutes' or 'days'
378
- *
379
- * @example
380
- * Duration.fromObject({years: 1}).as('days') //=> 365
381
- * @example
382
- * Duration.fromObject({years: 1}).as('months') //=> 12
383
- * @example
384
- * Duration.fromObject({hours: 60}).as('days') //=> 2.5
385
- */
386
- as(unit: DurationUnit): IfValid<number, typeof NaN, IsValid>
387
-
388
- /**
389
- * Reduce this Duration to its canonical representation in its current units.
390
- *
391
- * @example
392
- * Duration.fromObject({ years: 2, days: 5000 }).normalize().toObject() //=> { years: 15, days: 255 }
393
- * @example
394
- * Duration.fromObject({ hours: 12, minutes: -45 }).normalize().toObject() //=> { hours: 11, minutes: 15 }
395
- */
396
- normalize(): this
397
-
398
- /**
399
- * Rescale units to its largest representation.
400
- *
401
- * @example
402
- * Duration.fromObject({ milliseconds: 90000 }).rescale().toObject() //=> { minutes: 1, seconds: 30 }
403
- */
404
- rescale(): this
405
-
406
- /**
407
- * Convert this Duration into its representation in a different set of units.
408
- *
409
- * @example
410
- * Duration.fromObject({ hours: 1, seconds: 30 }).shiftTo('minutes', 'milliseconds').toObject() //=> { minutes: 60, milliseconds: 30000 }
411
- */
412
- shiftTo(...units: DurationUnit[]): this
413
-
414
- /**
415
- * Shift this Duration to all available units.
416
- * Same as shiftTo("years", "months", "weeks", "days", "hours", "minutes", "seconds", "milliseconds")
417
- */
418
- shiftToAll(): this
419
-
420
- /**
421
- * Return the negative of this Duration.
422
- *
423
- * @example
424
- * Duration.fromObject({ hours: 1, seconds: 30 }).negate().toObject() //=> { hours: -1, seconds: -30 }
425
- */
426
- negate(): this
427
-
428
- /**
429
- * Get the years.
430
- */
431
- get years(): IfValid<number, typeof NaN, IsValid>
432
-
433
- /**
434
- * Get the quarters.
435
- */
436
- get quarters(): IfValid<number, typeof NaN, IsValid>
437
-
438
- /**
439
- * Get the months.
440
- */
441
- get months(): IfValid<number, typeof NaN, IsValid>
442
-
443
- /**
444
- * Get the weeks
445
- */
446
- get weeks(): IfValid<number, typeof NaN, IsValid>
447
-
448
- /**
449
- * Get the days.
450
- */
451
- get days(): IfValid<number, typeof NaN, IsValid>
452
-
453
- /**
454
- * Get the hours.
455
- */
456
- get hours(): IfValid<number, typeof NaN, IsValid>
457
-
458
- /**
459
- * Get the minutes.
460
- */
461
- get minutes(): IfValid<number, typeof NaN, IsValid>
462
-
463
- /**
464
- * Get the seconds.
465
- */
466
- get seconds(): IfValid<number, typeof NaN, IsValid>
467
-
468
- /**
469
- * Get the milliseconds.
470
- */
471
- get milliseconds(): IfValid<number, typeof NaN, IsValid>
472
-
473
- /**
474
- * Returns whether the Duration is invalid.
475
- * Diff operations on invalid DateTimes or Intervals return invalid Durations.
476
- */
477
- get isValid(): IfValid<true, false, IsValid>
478
-
479
- /**
480
- * Returns an error code if this Duration became invalid, or null if the Duration is valid
481
- */
482
- get invalidReason(): IfValid<null, string, IsValid>
483
-
484
- /**
485
- * Returns an explanation of why this Duration became invalid, or null if the Duration is valid
486
- */
487
- get invalidExplanation(): IfValid<null, string | null, IsValid>
488
-
489
- /**
490
- * Equality check
491
- * Two Durations are equal iff they have the same units and the same values for each unit.
492
- */
493
- equals(other: Duration): IfValid<boolean, false, IsValid>
494
- }