@nocobase/plugin-workflow 0.11.1-alpha.5 → 0.12.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.
- package/client.d.ts +2 -3
- package/client.js +1 -1
- package/dist/client/index.js +7802 -0
- package/{lib → dist}/client/nodes/aggregate.d.ts +1 -5
- package/{lib → dist}/client/nodes/create.d.ts +1 -2
- package/{lib → dist}/client/nodes/destroy.d.ts +1 -1
- package/{lib → dist}/client/nodes/query.d.ts +1 -2
- package/{lib → dist}/client/nodes/request.d.ts +1 -2
- package/{lib → dist}/client/nodes/update.d.ts +1 -1
- package/{lib → dist}/client/schemas/collection.d.ts +1 -2
- package/{lib → dist}/client/triggers/collection.d.ts +6 -7
- package/{lib → dist}/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/locale/en-US.js +133 -0
- package/{lib → dist}/locale/es-ES.js +51 -54
- package/dist/locale/fr-FR.js +133 -0
- package/dist/locale/ja-JP.js +91 -0
- package/dist/locale/pt-BR.js +133 -0
- package/dist/locale/ru-RU.js +91 -0
- package/dist/locale/tr-TR.js +91 -0
- package/dist/locale/zh-CN.js +216 -0
- package/dist/node_modules/cron-parser/.eslintrc.json +15 -0
- package/dist/node_modules/cron-parser/.travis.yml +7 -0
- package/dist/node_modules/cron-parser/LICENSE +21 -0
- package/dist/node_modules/cron-parser/component.json +11 -0
- package/dist/node_modules/cron-parser/index.d.ts +1 -0
- package/dist/node_modules/cron-parser/lib/date.js +252 -0
- package/dist/node_modules/cron-parser/lib/expression.js +983 -0
- package/dist/node_modules/cron-parser/lib/field_compactor.js +70 -0
- package/dist/node_modules/cron-parser/lib/field_stringify.js +38 -0
- package/dist/node_modules/cron-parser/lib/parser.js +1 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/build/amd/luxon.js +8489 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/build/cjs-browser/luxon.js +8487 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/build/global/luxon.js +8490 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/build/global/luxon.min.js +1 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/build/node/luxon.js +7522 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/package.json +96 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/datetime.js +2169 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/duration.js +880 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/errors.js +61 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/conversions.js +157 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/diff.js +80 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/digits.js +76 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/english.js +233 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/formats.js +191 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/formatter.js +386 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/invalid.js +14 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/locale.js +482 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/regexParser.js +335 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/tokenParser.js +424 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/util.js +292 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/zoneUtil.js +36 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/info.js +193 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/interval.js +602 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/luxon.js +26 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/luxonFilled.js +13 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/settings.js +137 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zone.js +88 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/IANAZone.js +191 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/fixedOffsetZone.js +94 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/invalidZone.js +53 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/localZone.js +63 -0
- package/dist/node_modules/cron-parser/package.json +1 -0
- package/dist/node_modules/cron-parser/test/31_of_month.js +17 -0
- package/dist/node_modules/cron-parser/test/bug.js +29 -0
- package/dist/node_modules/cron-parser/test/crondate.js +16 -0
- package/dist/node_modules/cron-parser/test/crontab.example +7 -0
- package/dist/node_modules/cron-parser/test/empty_around_comma.js +22 -0
- package/dist/node_modules/cron-parser/test/expression.js +1489 -0
- package/dist/node_modules/cron-parser/test/field_compactor.js +250 -0
- package/dist/node_modules/cron-parser/test/field_stringify.js +84 -0
- package/dist/node_modules/cron-parser/test/fields.js +32 -0
- package/dist/node_modules/cron-parser/test/increment_on_first_iteration.js +22 -0
- package/dist/node_modules/cron-parser/test/index-ts3.test-d.ts +133 -0
- package/dist/node_modules/cron-parser/test/index.test-d.ts +138 -0
- package/dist/node_modules/cron-parser/test/leap_year.js +17 -0
- package/dist/node_modules/cron-parser/test/parser.js +46 -0
- package/dist/node_modules/cron-parser/test/parser_crondate_formats.js +145 -0
- package/dist/node_modules/cron-parser/test/parser_day_of_month.js +169 -0
- package/dist/node_modules/cron-parser/test/prev_date.js +32 -0
- package/dist/node_modules/cron-parser/test/stringify.js +402 -0
- package/dist/node_modules/cron-parser/test/timezone.js +422 -0
- package/dist/node_modules/cron-parser/types/common.d.ts +131 -0
- package/dist/node_modules/cron-parser/types/index.d.ts +45 -0
- package/dist/node_modules/cron-parser/types/ts3/index.d.ts +28 -0
- package/dist/node_modules/lru-cache/index-cjs.d.ts +7 -0
- package/dist/node_modules/lru-cache/index-cjs.js +1 -0
- package/dist/node_modules/lru-cache/index.d.ts +807 -0
- package/dist/node_modules/lru-cache/index.js +1334 -0
- package/dist/node_modules/lru-cache/index.min.js +2 -0
- package/dist/node_modules/lru-cache/package.json +1 -0
- package/dist/server/Plugin.js +297 -0
- package/{src/server/Processor.ts → dist/server/Processor.js} +80 -147
- package/dist/server/actions/index.js +49 -0
- package/{src/server/actions/nodes.ts → dist/server/actions/nodes.js} +55 -81
- package/{src/server/actions/workflows.ts → dist/server/actions/workflows.js} +60 -72
- package/dist/server/collections/executions.js +37 -0
- package/dist/server/collections/flow_nodes.js +56 -0
- package/dist/server/collections/jobs.js +33 -0
- package/dist/server/collections/workflows.js +90 -0
- package/{lib → dist}/server/constants.js +5 -8
- package/dist/server/fields/expression-field.js +11 -0
- package/dist/server/fields/index.js +11 -0
- package/dist/server/functions/index.js +13 -0
- package/dist/server/index.js +41 -0
- package/dist/server/instructions/aggregate.js +37 -0
- package/dist/server/instructions/calculation.js +34 -0
- package/dist/server/instructions/condition.js +123 -0
- package/{src/server/instructions/create.ts → dist/server/instructions/create.js} +17 -17
- package/dist/server/instructions/delay.js +87 -0
- package/dist/server/instructions/destroy.js +24 -0
- package/dist/server/instructions/index.js +40 -0
- package/{src/server/instructions/loop.ts → dist/server/instructions/loop.js} +21 -43
- package/{src/server/instructions/manual/actions.ts → dist/server/instructions/manual/actions.js} +18 -44
- package/dist/server/instructions/manual/collecions/jobs.js +21 -0
- package/dist/server/instructions/manual/collecions/users.js +19 -0
- package/dist/server/instructions/manual/collecions/users_jobs.js +52 -0
- package/{src/server/instructions/manual/forms/create.ts → dist/server/instructions/manual/forms/create.js} +8 -8
- package/dist/server/instructions/manual/forms/index.js +16 -0
- package/{src/server/instructions/manual/forms/update.ts → dist/server/instructions/manual/forms/update.js} +8 -8
- package/dist/server/instructions/manual/index.js +160 -0
- package/dist/server/instructions/parallel.js +105 -0
- package/dist/server/instructions/query.js +36 -0
- package/dist/server/instructions/request.js +69 -0
- package/dist/server/instructions/sql.js +26 -0
- package/dist/server/instructions/update.js +24 -0
- package/{src/server/migrations/20221129153547-calculation-variables.ts → dist/server/migrations/20221129153547-calculation-variables.js} +20 -19
- package/dist/server/migrations/20230221032941-change-request-body-type.js +71 -0
- package/dist/server/migrations/20230221071831-calculation-expression.js +94 -0
- package/dist/server/migrations/20230221121203-condition-calculation.js +41 -0
- package/dist/server/migrations/20230221162902-jsonb-to-json.js +52 -0
- package/dist/server/migrations/20230411034722-manual-multi-form.js +252 -0
- package/dist/server/migrations/20230612021134-manual-collection-block.js +126 -0
- package/dist/server/migrations/20230710115902-manual-action-values.js +74 -0
- package/{src/server/triggers/collection.ts → dist/server/triggers/collection.js} +34 -64
- package/dist/server/triggers/index.js +27 -0
- package/{src/server/triggers/schedule.ts → dist/server/triggers/schedule.js} +108 -220
- package/dist/server/types/Execution.js +8 -0
- package/dist/server/types/FlowNode.js +8 -0
- package/dist/server/types/Job.js +8 -0
- package/dist/server/types/Workflow.js +8 -0
- package/dist/server/types/index.js +2 -0
- package/{lib → dist}/server/utils.js +6 -8
- package/package.json +26 -37
- package/server.d.ts +2 -3
- package/server.js +1 -1
- package/lib/client/AddButton.js +0 -161
- package/lib/client/Branch.js +0 -50
- package/lib/client/CanvasContent.js +0 -51
- package/lib/client/ExecutionCanvas.js +0 -218
- package/lib/client/ExecutionLink.js +0 -48
- package/lib/client/ExecutionPage.js +0 -68
- package/lib/client/ExecutionResourceProvider.js +0 -48
- package/lib/client/FlowContext.js +0 -21
- package/lib/client/WorkflowCanvas.js +0 -300
- package/lib/client/WorkflowLink.js +0 -48
- package/lib/client/WorkflowPage.js +0 -70
- package/lib/client/WorkflowProvider.js +0 -100
- package/lib/client/components/CollectionBlockInitializer.js +0 -103
- package/lib/client/components/CollectionFieldset.js +0 -198
- package/lib/client/components/Duration.js +0 -72
- package/lib/client/components/DynamicExpression.js +0 -117
- package/lib/client/components/FieldsSelect.js +0 -72
- package/lib/client/components/FilterDynamicComponent.js +0 -34
- package/lib/client/components/NodeDescription.js +0 -73
- package/lib/client/components/NullRender.js +0 -9
- package/lib/client/components/OpenDrawer.js +0 -68
- package/lib/client/components/RadioWithTooltip.js +0 -65
- package/lib/client/components/ValueBlock.js +0 -103
- package/lib/client/components/renderEngineReference.js +0 -49
- package/lib/client/constants.js +0 -126
- package/lib/client/index.js +0 -121
- package/lib/client/interfaces/expression.js +0 -38
- package/lib/client/locale/index.js +0 -42
- package/lib/client/nodes/aggregate.js +0 -353
- package/lib/client/nodes/calculation.js +0 -292
- package/lib/client/nodes/condition.js +0 -531
- package/lib/client/nodes/create.js +0 -110
- package/lib/client/nodes/delay.js +0 -47
- package/lib/client/nodes/destroy.js +0 -49
- package/lib/client/nodes/index.js +0 -550
- package/lib/client/nodes/loop.js +0 -171
- package/lib/client/nodes/manual/AssigneesSelect.js +0 -56
- package/lib/client/nodes/manual/DetailsBlockProvider.js +0 -106
- package/lib/client/nodes/manual/FormBlockInitializer.js +0 -107
- package/lib/client/nodes/manual/FormBlockProvider.js +0 -113
- package/lib/client/nodes/manual/ModeConfig.js +0 -126
- package/lib/client/nodes/manual/SchemaConfig.js +0 -468
- package/lib/client/nodes/manual/WorkflowTodo.js +0 -642
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.js +0 -60
- package/lib/client/nodes/manual/forms/create.js +0 -111
- package/lib/client/nodes/manual/forms/custom.js +0 -428
- package/lib/client/nodes/manual/forms/update.js +0 -168
- package/lib/client/nodes/manual/index.js +0 -168
- package/lib/client/nodes/manual/utils.js +0 -31
- package/lib/client/nodes/parallel.js +0 -162
- package/lib/client/nodes/query.js +0 -112
- package/lib/client/nodes/request.js +0 -225
- package/lib/client/nodes/sql.js +0 -61
- package/lib/client/nodes/update.js +0 -127
- package/lib/client/schemas/collection.js +0 -93
- package/lib/client/schemas/executions.js +0 -190
- package/lib/client/schemas/workflows.js +0 -397
- package/lib/client/style.js +0 -350
- package/lib/client/triggers/collection.js +0 -188
- package/lib/client/triggers/index.js +0 -356
- package/lib/client/triggers/schedule/EndsByField.js +0 -71
- package/lib/client/triggers/schedule/OnField.js +0 -117
- package/lib/client/triggers/schedule/RepeatField.js +0 -155
- package/lib/client/triggers/schedule/ScheduleConfig.js +0 -251
- package/lib/client/triggers/schedule/constants.js +0 -11
- package/lib/client/triggers/schedule/index.js +0 -101
- package/lib/client/triggers/schedule/locale/Cron.zh-CN.js +0 -48
- package/lib/client/utils.js +0 -59
- package/lib/client/variable.js +0 -319
- package/lib/index.js +0 -13
- package/lib/locale/en-US.js +0 -136
- package/lib/locale/fr-FR.js +0 -136
- package/lib/locale/ja-JP.js +0 -94
- package/lib/locale/pt-BR.js +0 -136
- package/lib/locale/ru-RU.js +0 -94
- package/lib/locale/tr-TR.js +0 -94
- package/lib/locale/zh-CN.js +0 -219
- package/lib/server/Plugin.js +0 -382
- package/lib/server/Processor.js +0 -394
- package/lib/server/actions/index.js +0 -30
- package/lib/server/actions/nodes.js +0 -269
- package/lib/server/actions/workflows.js +0 -273
- package/lib/server/collections/executions.js +0 -33
- package/lib/server/collections/flow_nodes.js +0 -53
- package/lib/server/collections/jobs.js +0 -30
- package/lib/server/collections/workflows.js +0 -76
- package/lib/server/fields/expression-field.js +0 -19
- package/lib/server/fields/index.js +0 -12
- package/lib/server/functions/index.js +0 -26
- package/lib/server/index.js +0 -55
- package/lib/server/instructions/aggregate.js +0 -57
- package/lib/server/instructions/calculation.js +0 -59
- package/lib/server/instructions/condition.js +0 -150
- package/lib/server/instructions/create.js +0 -60
- package/lib/server/instructions/delay.js +0 -118
- package/lib/server/instructions/destroy.js +0 -37
- package/lib/server/instructions/index.js +0 -44
- package/lib/server/instructions/loop.js +0 -107
- package/lib/server/instructions/manual/actions.js +0 -99
- package/lib/server/instructions/manual/collecions/jobs.js +0 -21
- package/lib/server/instructions/manual/collecions/users.js +0 -19
- package/lib/server/instructions/manual/collecions/users_jobs.js +0 -46
- package/lib/server/instructions/manual/forms/create.js +0 -52
- package/lib/server/instructions/manual/forms/index.js +0 -15
- package/lib/server/instructions/manual/forms/update.js +0 -53
- package/lib/server/instructions/manual/index.js +0 -174
- package/lib/server/instructions/parallel.js +0 -128
- package/lib/server/instructions/query.js +0 -53
- package/lib/server/instructions/request.js +0 -99
- package/lib/server/instructions/sql.js +0 -34
- package/lib/server/instructions/update.js +0 -38
- package/lib/server/migrations/20221129153547-calculation-variables.js +0 -92
- package/lib/server/migrations/20230221032941-change-request-body-type.js +0 -90
- package/lib/server/migrations/20230221071831-calculation-expression.js +0 -111
- package/lib/server/migrations/20230221121203-condition-calculation.js +0 -103
- package/lib/server/migrations/20230221162902-jsonb-to-json.js +0 -64
- package/lib/server/migrations/20230411034722-manual-multi-form.js +0 -297
- package/lib/server/migrations/20230612021134-manual-collection-block.js +0 -155
- package/lib/server/migrations/20230710115902-manual-action-values.js +0 -97
- package/lib/server/triggers/collection.js +0 -175
- package/lib/server/triggers/index.js +0 -46
- package/lib/server/triggers/schedule.js +0 -582
- package/lib/server/types/Execution.js +0 -15
- package/lib/server/types/FlowNode.js +0 -15
- package/lib/server/types/Job.js +0 -15
- package/lib/server/types/Workflow.js +0 -15
- package/lib/server/types/index.js +0 -5
- package/src/client/AddButton.tsx +0 -111
- package/src/client/Branch.tsx +0 -37
- package/src/client/CanvasContent.tsx +0 -25
- package/src/client/ExecutionCanvas.tsx +0 -166
- package/src/client/ExecutionLink.tsx +0 -16
- package/src/client/ExecutionPage.tsx +0 -45
- package/src/client/ExecutionResourceProvider.tsx +0 -21
- package/src/client/FlowContext.ts +0 -7
- package/src/client/WorkflowCanvas.tsx +0 -221
- package/src/client/WorkflowLink.tsx +0 -16
- package/src/client/WorkflowPage.tsx +0 -52
- package/src/client/WorkflowProvider.tsx +0 -84
- package/src/client/components/CollectionBlockInitializer.tsx +0 -71
- package/src/client/components/CollectionFieldset.tsx +0 -152
- package/src/client/components/Duration.tsx +0 -45
- package/src/client/components/DynamicExpression.tsx +0 -57
- package/src/client/components/FieldsSelect.tsx +0 -32
- package/src/client/components/FilterDynamicComponent.tsx +0 -15
- package/src/client/components/NodeDescription.tsx +0 -51
- package/src/client/components/NullRender.tsx +0 -3
- package/src/client/components/OpenDrawer.tsx +0 -24
- package/src/client/components/RadioWithTooltip.tsx +0 -38
- package/src/client/components/ValueBlock.tsx +0 -67
- package/src/client/components/renderEngineReference.tsx +0 -30
- package/src/client/constants.tsx +0 -91
- package/src/client/index.tsx +0 -51
- package/src/client/interfaces/expression.tsx +0 -25
- package/src/client/locale/index.ts +0 -18
- package/src/client/nodes/aggregate.tsx +0 -327
- package/src/client/nodes/calculation.tsx +0 -216
- package/src/client/nodes/condition.tsx +0 -463
- package/src/client/nodes/create.tsx +0 -85
- package/src/client/nodes/delay.tsx +0 -37
- package/src/client/nodes/destroy.tsx +0 -34
- package/src/client/nodes/index.tsx +0 -500
- package/src/client/nodes/loop.tsx +0 -144
- package/src/client/nodes/manual/AssigneesSelect.tsx +0 -33
- package/src/client/nodes/manual/DetailsBlockProvider.tsx +0 -80
- package/src/client/nodes/manual/FormBlockInitializer.tsx +0 -69
- package/src/client/nodes/manual/FormBlockProvider.tsx +0 -75
- package/src/client/nodes/manual/ModeConfig.tsx +0 -84
- package/src/client/nodes/manual/SchemaConfig.tsx +0 -509
- package/src/client/nodes/manual/WorkflowTodo.tsx +0 -607
- package/src/client/nodes/manual/WorkflowTodoBlockInitializer.tsx +0 -28
- package/src/client/nodes/manual/forms/create.tsx +0 -92
- package/src/client/nodes/manual/forms/custom.tsx +0 -392
- package/src/client/nodes/manual/forms/update.tsx +0 -134
- package/src/client/nodes/manual/index.tsx +0 -162
- package/src/client/nodes/manual/utils.ts +0 -28
- package/src/client/nodes/parallel.tsx +0 -138
- package/src/client/nodes/query.tsx +0 -88
- package/src/client/nodes/request.tsx +0 -185
- package/src/client/nodes/sql.tsx +0 -37
- package/src/client/nodes/update.tsx +0 -100
- package/src/client/schemas/collection.ts +0 -75
- package/src/client/schemas/executions.tsx +0 -169
- package/src/client/schemas/workflows.ts +0 -364
- package/src/client/style.tsx +0 -350
- package/src/client/triggers/collection.tsx +0 -190
- package/src/client/triggers/index.tsx +0 -311
- package/src/client/triggers/schedule/EndsByField.tsx +0 -40
- package/src/client/triggers/schedule/OnField.tsx +0 -64
- package/src/client/triggers/schedule/RepeatField.tsx +0 -116
- package/src/client/triggers/schedule/ScheduleConfig.tsx +0 -227
- package/src/client/triggers/schedule/constants.ts +0 -4
- package/src/client/triggers/schedule/index.tsx +0 -78
- package/src/client/triggers/schedule/locale/Cron.zh-CN.ts +0 -79
- package/src/client/utils.ts +0 -36
- package/src/client/variable.tsx +0 -318
- package/src/index.ts +0 -1
- package/src/locale/en-US.ts +0 -136
- package/src/locale/es-ES.ts +0 -129
- package/src/locale/fr-FR.ts +0 -137
- package/src/locale/ja-JP.ts +0 -90
- package/src/locale/pt-BR.ts +0 -136
- package/src/locale/ru-RU.ts +0 -90
- package/src/locale/tr-TR.ts +0 -90
- package/src/locale/zh-CN.ts +0 -248
- package/src/server/Plugin.ts +0 -355
- package/src/server/__tests__/Plugin.test.ts +0 -398
- package/src/server/__tests__/Processor.test.ts +0 -474
- package/src/server/__tests__/actions/workflows.test.ts +0 -419
- package/src/server/__tests__/collections/categories.ts +0 -27
- package/src/server/__tests__/collections/comments.ts +0 -24
- package/src/server/__tests__/collections/posts.ts +0 -42
- package/src/server/__tests__/collections/replies.ts +0 -9
- package/src/server/__tests__/collections/tags.ts +0 -15
- package/src/server/__tests__/index.ts +0 -89
- package/src/server/__tests__/instructions/aggregate.test.ts +0 -294
- package/src/server/__tests__/instructions/calculation.test.ts +0 -265
- package/src/server/__tests__/instructions/condition.test.ts +0 -434
- package/src/server/__tests__/instructions/create.test.ts +0 -129
- package/src/server/__tests__/instructions/delay.test.ts +0 -182
- package/src/server/__tests__/instructions/destroy.test.ts +0 -58
- package/src/server/__tests__/instructions/loop.test.ts +0 -331
- package/src/server/__tests__/instructions/manual.test.ts +0 -1173
- package/src/server/__tests__/instructions/parallel.test.ts +0 -445
- package/src/server/__tests__/instructions/query.test.ts +0 -359
- package/src/server/__tests__/instructions/request.test.ts +0 -247
- package/src/server/__tests__/instructions/sql.test.ts +0 -162
- package/src/server/__tests__/instructions/update.test.ts +0 -189
- package/src/server/__tests__/triggers/collection.test.ts +0 -333
- package/src/server/__tests__/triggers/schedule.test.ts +0 -369
- package/src/server/actions/index.ts +0 -25
- package/src/server/collections/executions.ts +0 -35
- package/src/server/collections/flow_nodes.ts +0 -54
- package/src/server/collections/jobs.ts +0 -31
- package/src/server/collections/workflows.ts +0 -88
- package/src/server/constants.ts +0 -26
- package/src/server/fields/expression-field.ts +0 -11
- package/src/server/fields/index.ts +0 -7
- package/src/server/functions/index.ts +0 -16
- package/src/server/index.ts +0 -6
- package/src/server/instructions/aggregate.ts +0 -42
- package/src/server/instructions/calculation.ts +0 -41
- package/src/server/instructions/condition.ts +0 -172
- package/src/server/instructions/delay.ts +0 -105
- package/src/server/instructions/destroy.ts +0 -23
- package/src/server/instructions/index.ts +0 -64
- package/src/server/instructions/manual/collecions/jobs.ts +0 -17
- package/src/server/instructions/manual/collecions/users.ts +0 -15
- package/src/server/instructions/manual/collecions/users_jobs.ts +0 -50
- package/src/server/instructions/manual/forms/index.ts +0 -12
- package/src/server/instructions/manual/index.ts +0 -184
- package/src/server/instructions/parallel.ts +0 -121
- package/src/server/instructions/query.ts +0 -42
- package/src/server/instructions/request.ts +0 -88
- package/src/server/instructions/sql.ts +0 -25
- package/src/server/instructions/update.ts +0 -24
- package/src/server/migrations/20230221032941-change-request-body-type.ts +0 -76
- package/src/server/migrations/20230221071831-calculation-expression.ts +0 -102
- package/src/server/migrations/20230221121203-condition-calculation.ts +0 -82
- package/src/server/migrations/20230221162902-jsonb-to-json.ts +0 -51
- package/src/server/migrations/20230411034722-manual-multi-form.ts +0 -282
- package/src/server/migrations/20230612021134-manual-collection-block.ts +0 -138
- package/src/server/migrations/20230710115902-manual-action-values.ts +0 -78
- package/src/server/triggers/index.ts +0 -22
- package/src/server/types/Execution.ts +0 -26
- package/src/server/types/FlowNode.ts +0 -21
- package/src/server/types/Job.ts +0 -18
- package/src/server/types/Workflow.ts +0 -36
- package/src/server/types/index.ts +0 -4
- package/src/server/utils.ts +0 -17
- /package/{lib → dist}/client/AddButton.d.ts +0 -0
- /package/{lib → dist}/client/Branch.d.ts +0 -0
- /package/{lib → dist}/client/CanvasContent.d.ts +0 -0
- /package/{lib → dist}/client/ExecutionCanvas.d.ts +0 -0
- /package/{lib → dist}/client/ExecutionLink.d.ts +0 -0
- /package/{lib → dist}/client/ExecutionPage.d.ts +0 -0
- /package/{lib → dist}/client/ExecutionResourceProvider.d.ts +0 -0
- /package/{lib → dist}/client/FlowContext.d.ts +0 -0
- /package/{lib → dist}/client/WorkflowCanvas.d.ts +0 -0
- /package/{lib → dist}/client/WorkflowLink.d.ts +0 -0
- /package/{lib → dist}/client/WorkflowPage.d.ts +0 -0
- /package/{lib → dist}/client/WorkflowProvider.d.ts +0 -0
- /package/{lib → dist}/client/components/CollectionBlockInitializer.d.ts +0 -0
- /package/{lib → dist}/client/components/CollectionFieldset.d.ts +0 -0
- /package/{lib → dist}/client/components/Duration.d.ts +0 -0
- /package/{lib → dist}/client/components/DynamicExpression.d.ts +0 -0
- /package/{lib → dist}/client/components/FieldsSelect.d.ts +0 -0
- /package/{lib → dist}/client/components/FilterDynamicComponent.d.ts +0 -0
- /package/{lib → dist}/client/components/NodeDescription.d.ts +0 -0
- /package/{lib → dist}/client/components/NullRender.d.ts +0 -0
- /package/{lib → dist}/client/components/OpenDrawer.d.ts +0 -0
- /package/{lib → dist}/client/components/RadioWithTooltip.d.ts +0 -0
- /package/{lib → dist}/client/components/ValueBlock.d.ts +0 -0
- /package/{lib → dist}/client/components/renderEngineReference.d.ts +0 -0
- /package/{lib → dist}/client/constants.d.ts +0 -0
- /package/{lib → dist}/client/index.d.ts +0 -0
- /package/{lib → dist}/client/interfaces/expression.d.ts +0 -0
- /package/{lib → dist}/client/locale/index.d.ts +0 -0
- /package/{lib → dist}/client/nodes/calculation.d.ts +0 -0
- /package/{lib → dist}/client/nodes/condition.d.ts +0 -0
- /package/{lib → dist}/client/nodes/delay.d.ts +0 -0
- /package/{lib → dist}/client/nodes/index.d.ts +0 -0
- /package/{lib → dist}/client/nodes/loop.d.ts +0 -0
- /package/{lib → dist}/client/nodes/manual/AssigneesSelect.d.ts +0 -0
- /package/{lib → dist}/client/nodes/manual/DetailsBlockProvider.d.ts +0 -0
- /package/{lib → dist}/client/nodes/manual/FormBlockInitializer.d.ts +0 -0
- /package/{lib → dist}/client/nodes/manual/FormBlockProvider.d.ts +0 -0
- /package/{lib → dist}/client/nodes/manual/ModeConfig.d.ts +0 -0
- /package/{lib → dist}/client/nodes/manual/SchemaConfig.d.ts +0 -0
- /package/{lib → dist}/client/nodes/manual/WorkflowTodo.d.ts +0 -0
- /package/{lib → dist}/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +0 -0
- /package/{lib → dist}/client/nodes/manual/forms/create.d.ts +0 -0
- /package/{lib → dist}/client/nodes/manual/forms/custom.d.ts +0 -0
- /package/{lib → dist}/client/nodes/manual/forms/update.d.ts +0 -0
- /package/{lib → dist}/client/nodes/manual/index.d.ts +0 -0
- /package/{lib → dist}/client/nodes/manual/utils.d.ts +0 -0
- /package/{lib → dist}/client/nodes/parallel.d.ts +0 -0
- /package/{lib → dist}/client/nodes/sql.d.ts +0 -0
- /package/{lib → dist}/client/schemas/executions.d.ts +0 -0
- /package/{lib → dist}/client/schemas/workflows.d.ts +0 -0
- /package/{lib → dist}/client/style.d.ts +0 -0
- /package/{lib → dist}/client/triggers/index.d.ts +0 -0
- /package/{lib → dist}/client/triggers/schedule/EndsByField.d.ts +0 -0
- /package/{lib → dist}/client/triggers/schedule/OnField.d.ts +0 -0
- /package/{lib → dist}/client/triggers/schedule/RepeatField.d.ts +0 -0
- /package/{lib → dist}/client/triggers/schedule/ScheduleConfig.d.ts +0 -0
- /package/{lib → dist}/client/triggers/schedule/constants.d.ts +0 -0
- /package/{lib → dist}/client/triggers/schedule/index.d.ts +0 -0
- /package/{lib → dist}/client/triggers/schedule/locale/Cron.zh-CN.d.ts +0 -0
- /package/{lib → dist}/client/utils.d.ts +0 -0
- /package/{lib → dist}/client/variable.d.ts +0 -0
- /package/{lib → dist}/locale/en-US.d.ts +0 -0
- /package/{lib → dist}/locale/es-ES.d.ts +0 -0
- /package/{lib → dist}/locale/fr-FR.d.ts +0 -0
- /package/{lib → dist}/locale/ja-JP.d.ts +0 -0
- /package/{lib → dist}/locale/pt-BR.d.ts +0 -0
- /package/{lib → dist}/locale/ru-RU.d.ts +0 -0
- /package/{lib → dist}/locale/tr-TR.d.ts +0 -0
- /package/{lib → dist}/locale/zh-CN.d.ts +0 -0
- /package/{lib → dist}/server/Plugin.d.ts +0 -0
- /package/{lib → dist}/server/Processor.d.ts +0 -0
- /package/{lib → dist}/server/actions/index.d.ts +0 -0
- /package/{lib → dist}/server/actions/nodes.d.ts +0 -0
- /package/{lib → dist}/server/actions/workflows.d.ts +0 -0
- /package/{lib → dist}/server/collections/executions.d.ts +0 -0
- /package/{lib → dist}/server/collections/flow_nodes.d.ts +0 -0
- /package/{lib → dist}/server/collections/jobs.d.ts +0 -0
- /package/{lib → dist}/server/collections/workflows.d.ts +0 -0
- /package/{lib → dist}/server/constants.d.ts +0 -0
- /package/{lib → dist}/server/fields/expression-field.d.ts +0 -0
- /package/{lib → dist}/server/fields/index.d.ts +0 -0
- /package/{lib → dist}/server/functions/index.d.ts +0 -0
- /package/{lib → dist}/server/index.d.ts +0 -0
- /package/{lib → dist}/server/instructions/aggregate.d.ts +0 -0
- /package/{lib → dist}/server/instructions/calculation.d.ts +0 -0
- /package/{lib → dist}/server/instructions/condition.d.ts +0 -0
- /package/{lib → dist}/server/instructions/create.d.ts +0 -0
- /package/{lib → dist}/server/instructions/delay.d.ts +0 -0
- /package/{lib → dist}/server/instructions/destroy.d.ts +0 -0
- /package/{lib → dist}/server/instructions/index.d.ts +0 -0
- /package/{lib → dist}/server/instructions/loop.d.ts +0 -0
- /package/{lib → dist}/server/instructions/manual/actions.d.ts +0 -0
- /package/{lib → dist}/server/instructions/manual/collecions/jobs.d.ts +0 -0
- /package/{lib → dist}/server/instructions/manual/collecions/users.d.ts +0 -0
- /package/{lib → dist}/server/instructions/manual/collecions/users_jobs.d.ts +0 -0
- /package/{lib → dist}/server/instructions/manual/forms/create.d.ts +0 -0
- /package/{lib → dist}/server/instructions/manual/forms/index.d.ts +0 -0
- /package/{lib → dist}/server/instructions/manual/forms/update.d.ts +0 -0
- /package/{lib → dist}/server/instructions/manual/index.d.ts +0 -0
- /package/{lib → dist}/server/instructions/parallel.d.ts +0 -0
- /package/{lib → dist}/server/instructions/query.d.ts +0 -0
- /package/{lib → dist}/server/instructions/request.d.ts +0 -0
- /package/{lib → dist}/server/instructions/sql.d.ts +0 -0
- /package/{lib → dist}/server/instructions/update.d.ts +0 -0
- /package/{lib → dist}/server/migrations/20221129153547-calculation-variables.d.ts +0 -0
- /package/{lib → dist}/server/migrations/20230221032941-change-request-body-type.d.ts +0 -0
- /package/{lib → dist}/server/migrations/20230221071831-calculation-expression.d.ts +0 -0
- /package/{lib → dist}/server/migrations/20230221121203-condition-calculation.d.ts +0 -0
- /package/{lib → dist}/server/migrations/20230221162902-jsonb-to-json.d.ts +0 -0
- /package/{lib → dist}/server/migrations/20230411034722-manual-multi-form.d.ts +0 -0
- /package/{lib → dist}/server/migrations/20230612021134-manual-collection-block.d.ts +0 -0
- /package/{lib → dist}/server/migrations/20230710115902-manual-action-values.d.ts +0 -0
- /package/{lib → dist}/server/triggers/collection.d.ts +0 -0
- /package/{lib → dist}/server/triggers/index.d.ts +0 -0
- /package/{lib → dist}/server/triggers/schedule.d.ts +0 -0
- /package/{lib → dist}/server/types/Execution.d.ts +0 -0
- /package/{lib → dist}/server/types/FlowNode.d.ts +0 -0
- /package/{lib → dist}/server/types/Job.d.ts +0 -0
- /package/{lib → dist}/server/types/Workflow.d.ts +0 -0
- /package/{lib → dist}/server/types/index.d.ts +0 -0
- /package/{lib → dist}/server/utils.d.ts +0 -0
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import { parseMillis, isUndefined, untruncateYear, signedOffset, hasOwnProperty } from "./util.js";
|
|
2
|
+
import Formatter from "./formatter.js";
|
|
3
|
+
import FixedOffsetZone from "../zones/fixedOffsetZone.js";
|
|
4
|
+
import IANAZone from "../zones/IANAZone.js";
|
|
5
|
+
import DateTime from "../datetime.js";
|
|
6
|
+
import { digitRegex, parseDigits } from "./digits.js";
|
|
7
|
+
import { ConflictingSpecificationError } from "../errors.js";
|
|
8
|
+
|
|
9
|
+
const MISSING_FTP = "missing Intl.DateTimeFormat.formatToParts support";
|
|
10
|
+
|
|
11
|
+
function intUnit(regex, post = i => i) {
|
|
12
|
+
return { regex, deser: ([s]) => post(parseDigits(s)) };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const NBSP = String.fromCharCode(160);
|
|
16
|
+
const spaceOrNBSP = `( |${NBSP})`;
|
|
17
|
+
const spaceOrNBSPRegExp = new RegExp(spaceOrNBSP, "g");
|
|
18
|
+
|
|
19
|
+
function fixListRegex(s) {
|
|
20
|
+
// make dots optional and also make them literal
|
|
21
|
+
// make space and non breakable space characters interchangeable
|
|
22
|
+
return s.replace(/\./g, "\\.?").replace(spaceOrNBSPRegExp, spaceOrNBSP);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function stripInsensitivities(s) {
|
|
26
|
+
return s
|
|
27
|
+
.replace(/\./g, "") // ignore dots that were made optional
|
|
28
|
+
.replace(spaceOrNBSPRegExp, " ") // interchange space and nbsp
|
|
29
|
+
.toLowerCase();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function oneOf(strings, startIndex) {
|
|
33
|
+
if (strings === null) {
|
|
34
|
+
return null;
|
|
35
|
+
} else {
|
|
36
|
+
return {
|
|
37
|
+
regex: RegExp(strings.map(fixListRegex).join("|")),
|
|
38
|
+
deser: ([s]) =>
|
|
39
|
+
strings.findIndex(i => stripInsensitivities(s) === stripInsensitivities(i)) + startIndex
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function offset(regex, groups) {
|
|
45
|
+
return { regex, deser: ([, h, m]) => signedOffset(h, m), groups };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function simple(regex) {
|
|
49
|
+
return { regex, deser: ([s]) => s };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function escapeToken(value) {
|
|
53
|
+
// eslint-disable-next-line no-useless-escape
|
|
54
|
+
return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function unitForToken(token, loc) {
|
|
58
|
+
const one = digitRegex(loc),
|
|
59
|
+
two = digitRegex(loc, "{2}"),
|
|
60
|
+
three = digitRegex(loc, "{3}"),
|
|
61
|
+
four = digitRegex(loc, "{4}"),
|
|
62
|
+
six = digitRegex(loc, "{6}"),
|
|
63
|
+
oneOrTwo = digitRegex(loc, "{1,2}"),
|
|
64
|
+
oneToThree = digitRegex(loc, "{1,3}"),
|
|
65
|
+
oneToSix = digitRegex(loc, "{1,6}"),
|
|
66
|
+
oneToNine = digitRegex(loc, "{1,9}"),
|
|
67
|
+
twoToFour = digitRegex(loc, "{2,4}"),
|
|
68
|
+
fourToSix = digitRegex(loc, "{4,6}"),
|
|
69
|
+
literal = t => ({ regex: RegExp(escapeToken(t.val)), deser: ([s]) => s, literal: true }),
|
|
70
|
+
unitate = t => {
|
|
71
|
+
if (token.literal) {
|
|
72
|
+
return literal(t);
|
|
73
|
+
}
|
|
74
|
+
switch (t.val) {
|
|
75
|
+
// era
|
|
76
|
+
case "G":
|
|
77
|
+
return oneOf(loc.eras("short", false), 0);
|
|
78
|
+
case "GG":
|
|
79
|
+
return oneOf(loc.eras("long", false), 0);
|
|
80
|
+
// years
|
|
81
|
+
case "y":
|
|
82
|
+
return intUnit(oneToSix);
|
|
83
|
+
case "yy":
|
|
84
|
+
return intUnit(twoToFour, untruncateYear);
|
|
85
|
+
case "yyyy":
|
|
86
|
+
return intUnit(four);
|
|
87
|
+
case "yyyyy":
|
|
88
|
+
return intUnit(fourToSix);
|
|
89
|
+
case "yyyyyy":
|
|
90
|
+
return intUnit(six);
|
|
91
|
+
// months
|
|
92
|
+
case "M":
|
|
93
|
+
return intUnit(oneOrTwo);
|
|
94
|
+
case "MM":
|
|
95
|
+
return intUnit(two);
|
|
96
|
+
case "MMM":
|
|
97
|
+
return oneOf(loc.months("short", true, false), 1);
|
|
98
|
+
case "MMMM":
|
|
99
|
+
return oneOf(loc.months("long", true, false), 1);
|
|
100
|
+
case "L":
|
|
101
|
+
return intUnit(oneOrTwo);
|
|
102
|
+
case "LL":
|
|
103
|
+
return intUnit(two);
|
|
104
|
+
case "LLL":
|
|
105
|
+
return oneOf(loc.months("short", false, false), 1);
|
|
106
|
+
case "LLLL":
|
|
107
|
+
return oneOf(loc.months("long", false, false), 1);
|
|
108
|
+
// dates
|
|
109
|
+
case "d":
|
|
110
|
+
return intUnit(oneOrTwo);
|
|
111
|
+
case "dd":
|
|
112
|
+
return intUnit(two);
|
|
113
|
+
// ordinals
|
|
114
|
+
case "o":
|
|
115
|
+
return intUnit(oneToThree);
|
|
116
|
+
case "ooo":
|
|
117
|
+
return intUnit(three);
|
|
118
|
+
// time
|
|
119
|
+
case "HH":
|
|
120
|
+
return intUnit(two);
|
|
121
|
+
case "H":
|
|
122
|
+
return intUnit(oneOrTwo);
|
|
123
|
+
case "hh":
|
|
124
|
+
return intUnit(two);
|
|
125
|
+
case "h":
|
|
126
|
+
return intUnit(oneOrTwo);
|
|
127
|
+
case "mm":
|
|
128
|
+
return intUnit(two);
|
|
129
|
+
case "m":
|
|
130
|
+
return intUnit(oneOrTwo);
|
|
131
|
+
case "q":
|
|
132
|
+
return intUnit(oneOrTwo);
|
|
133
|
+
case "qq":
|
|
134
|
+
return intUnit(two);
|
|
135
|
+
case "s":
|
|
136
|
+
return intUnit(oneOrTwo);
|
|
137
|
+
case "ss":
|
|
138
|
+
return intUnit(two);
|
|
139
|
+
case "S":
|
|
140
|
+
return intUnit(oneToThree);
|
|
141
|
+
case "SSS":
|
|
142
|
+
return intUnit(three);
|
|
143
|
+
case "u":
|
|
144
|
+
return simple(oneToNine);
|
|
145
|
+
// meridiem
|
|
146
|
+
case "a":
|
|
147
|
+
return oneOf(loc.meridiems(), 0);
|
|
148
|
+
// weekYear (k)
|
|
149
|
+
case "kkkk":
|
|
150
|
+
return intUnit(four);
|
|
151
|
+
case "kk":
|
|
152
|
+
return intUnit(twoToFour, untruncateYear);
|
|
153
|
+
// weekNumber (W)
|
|
154
|
+
case "W":
|
|
155
|
+
return intUnit(oneOrTwo);
|
|
156
|
+
case "WW":
|
|
157
|
+
return intUnit(two);
|
|
158
|
+
// weekdays
|
|
159
|
+
case "E":
|
|
160
|
+
case "c":
|
|
161
|
+
return intUnit(one);
|
|
162
|
+
case "EEE":
|
|
163
|
+
return oneOf(loc.weekdays("short", false, false), 1);
|
|
164
|
+
case "EEEE":
|
|
165
|
+
return oneOf(loc.weekdays("long", false, false), 1);
|
|
166
|
+
case "ccc":
|
|
167
|
+
return oneOf(loc.weekdays("short", true, false), 1);
|
|
168
|
+
case "cccc":
|
|
169
|
+
return oneOf(loc.weekdays("long", true, false), 1);
|
|
170
|
+
// offset/zone
|
|
171
|
+
case "Z":
|
|
172
|
+
case "ZZ":
|
|
173
|
+
return offset(new RegExp(`([+-]${oneOrTwo.source})(?::(${two.source}))?`), 2);
|
|
174
|
+
case "ZZZ":
|
|
175
|
+
return offset(new RegExp(`([+-]${oneOrTwo.source})(${two.source})?`), 2);
|
|
176
|
+
// we don't support ZZZZ (PST) or ZZZZZ (Pacific Standard Time) in parsing
|
|
177
|
+
// because we don't have any way to figure out what they are
|
|
178
|
+
case "z":
|
|
179
|
+
return simple(/[a-z_+-/]{1,256}?/i);
|
|
180
|
+
default:
|
|
181
|
+
return literal(t);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const unit = unitate(token) || {
|
|
186
|
+
invalidReason: MISSING_FTP
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
unit.token = token;
|
|
190
|
+
|
|
191
|
+
return unit;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const partTypeStyleToTokenVal = {
|
|
195
|
+
year: {
|
|
196
|
+
"2-digit": "yy",
|
|
197
|
+
numeric: "yyyyy"
|
|
198
|
+
},
|
|
199
|
+
month: {
|
|
200
|
+
numeric: "M",
|
|
201
|
+
"2-digit": "MM",
|
|
202
|
+
short: "MMM",
|
|
203
|
+
long: "MMMM"
|
|
204
|
+
},
|
|
205
|
+
day: {
|
|
206
|
+
numeric: "d",
|
|
207
|
+
"2-digit": "dd"
|
|
208
|
+
},
|
|
209
|
+
weekday: {
|
|
210
|
+
short: "EEE",
|
|
211
|
+
long: "EEEE"
|
|
212
|
+
},
|
|
213
|
+
dayperiod: "a",
|
|
214
|
+
dayPeriod: "a",
|
|
215
|
+
hour: {
|
|
216
|
+
numeric: "h",
|
|
217
|
+
"2-digit": "hh"
|
|
218
|
+
},
|
|
219
|
+
minute: {
|
|
220
|
+
numeric: "m",
|
|
221
|
+
"2-digit": "mm"
|
|
222
|
+
},
|
|
223
|
+
second: {
|
|
224
|
+
numeric: "s",
|
|
225
|
+
"2-digit": "ss"
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
function tokenForPart(part, locale, formatOpts) {
|
|
230
|
+
const { type, value } = part;
|
|
231
|
+
|
|
232
|
+
if (type === "literal") {
|
|
233
|
+
return {
|
|
234
|
+
literal: true,
|
|
235
|
+
val: value
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const style = formatOpts[type];
|
|
240
|
+
|
|
241
|
+
let val = partTypeStyleToTokenVal[type];
|
|
242
|
+
if (typeof val === "object") {
|
|
243
|
+
val = val[style];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (val) {
|
|
247
|
+
return {
|
|
248
|
+
literal: false,
|
|
249
|
+
val
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return undefined;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function buildRegex(units) {
|
|
257
|
+
const re = units.map(u => u.regex).reduce((f, r) => `${f}(${r.source})`, "");
|
|
258
|
+
return [`^${re}$`, units];
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function match(input, regex, handlers) {
|
|
262
|
+
const matches = input.match(regex);
|
|
263
|
+
|
|
264
|
+
if (matches) {
|
|
265
|
+
const all = {};
|
|
266
|
+
let matchIndex = 1;
|
|
267
|
+
for (const i in handlers) {
|
|
268
|
+
if (hasOwnProperty(handlers, i)) {
|
|
269
|
+
const h = handlers[i],
|
|
270
|
+
groups = h.groups ? h.groups + 1 : 1;
|
|
271
|
+
if (!h.literal && h.token) {
|
|
272
|
+
all[h.token.val[0]] = h.deser(matches.slice(matchIndex, matchIndex + groups));
|
|
273
|
+
}
|
|
274
|
+
matchIndex += groups;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return [matches, all];
|
|
278
|
+
} else {
|
|
279
|
+
return [matches, {}];
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function dateTimeFromMatches(matches) {
|
|
284
|
+
const toField = token => {
|
|
285
|
+
switch (token) {
|
|
286
|
+
case "S":
|
|
287
|
+
return "millisecond";
|
|
288
|
+
case "s":
|
|
289
|
+
return "second";
|
|
290
|
+
case "m":
|
|
291
|
+
return "minute";
|
|
292
|
+
case "h":
|
|
293
|
+
case "H":
|
|
294
|
+
return "hour";
|
|
295
|
+
case "d":
|
|
296
|
+
return "day";
|
|
297
|
+
case "o":
|
|
298
|
+
return "ordinal";
|
|
299
|
+
case "L":
|
|
300
|
+
case "M":
|
|
301
|
+
return "month";
|
|
302
|
+
case "y":
|
|
303
|
+
return "year";
|
|
304
|
+
case "E":
|
|
305
|
+
case "c":
|
|
306
|
+
return "weekday";
|
|
307
|
+
case "W":
|
|
308
|
+
return "weekNumber";
|
|
309
|
+
case "k":
|
|
310
|
+
return "weekYear";
|
|
311
|
+
case "q":
|
|
312
|
+
return "quarter";
|
|
313
|
+
default:
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
let zone;
|
|
319
|
+
if (!isUndefined(matches.Z)) {
|
|
320
|
+
zone = new FixedOffsetZone(matches.Z);
|
|
321
|
+
} else if (!isUndefined(matches.z)) {
|
|
322
|
+
zone = IANAZone.create(matches.z);
|
|
323
|
+
} else {
|
|
324
|
+
zone = null;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (!isUndefined(matches.q)) {
|
|
328
|
+
matches.M = (matches.q - 1) * 3 + 1;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
if (!isUndefined(matches.h)) {
|
|
332
|
+
if (matches.h < 12 && matches.a === 1) {
|
|
333
|
+
matches.h += 12;
|
|
334
|
+
} else if (matches.h === 12 && matches.a === 0) {
|
|
335
|
+
matches.h = 0;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if (matches.G === 0 && matches.y) {
|
|
340
|
+
matches.y = -matches.y;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (!isUndefined(matches.u)) {
|
|
344
|
+
matches.S = parseMillis(matches.u);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const vals = Object.keys(matches).reduce((r, k) => {
|
|
348
|
+
const f = toField(k);
|
|
349
|
+
if (f) {
|
|
350
|
+
r[f] = matches[k];
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return r;
|
|
354
|
+
}, {});
|
|
355
|
+
|
|
356
|
+
return [vals, zone];
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
let dummyDateTimeCache = null;
|
|
360
|
+
|
|
361
|
+
function getDummyDateTime() {
|
|
362
|
+
if (!dummyDateTimeCache) {
|
|
363
|
+
dummyDateTimeCache = DateTime.fromMillis(1555555555555);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
return dummyDateTimeCache;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function maybeExpandMacroToken(token, locale) {
|
|
370
|
+
if (token.literal) {
|
|
371
|
+
return token;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const formatOpts = Formatter.macroTokenToFormatOpts(token.val);
|
|
375
|
+
|
|
376
|
+
if (!formatOpts) {
|
|
377
|
+
return token;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const formatter = Formatter.create(locale, formatOpts);
|
|
381
|
+
const parts = formatter.formatDateTimeParts(getDummyDateTime());
|
|
382
|
+
|
|
383
|
+
const tokens = parts.map(p => tokenForPart(p, locale, formatOpts));
|
|
384
|
+
|
|
385
|
+
if (tokens.includes(undefined)) {
|
|
386
|
+
return token;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
return tokens;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
function expandMacroTokens(tokens, locale) {
|
|
393
|
+
return Array.prototype.concat(...tokens.map(t => maybeExpandMacroToken(t, locale)));
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* @private
|
|
398
|
+
*/
|
|
399
|
+
|
|
400
|
+
export function explainFromTokens(locale, input, format) {
|
|
401
|
+
const tokens = expandMacroTokens(Formatter.parseFormat(format), locale),
|
|
402
|
+
units = tokens.map(t => unitForToken(t, locale)),
|
|
403
|
+
disqualifyingUnit = units.find(t => t.invalidReason);
|
|
404
|
+
|
|
405
|
+
if (disqualifyingUnit) {
|
|
406
|
+
return { input, tokens, invalidReason: disqualifyingUnit.invalidReason };
|
|
407
|
+
} else {
|
|
408
|
+
const [regexString, handlers] = buildRegex(units),
|
|
409
|
+
regex = RegExp(regexString, "i"),
|
|
410
|
+
[rawMatches, matches] = match(input, regex, handlers),
|
|
411
|
+
[result, zone] = matches ? dateTimeFromMatches(matches) : [null, null];
|
|
412
|
+
if (hasOwnProperty(matches, "a") && hasOwnProperty(matches, "H")) {
|
|
413
|
+
throw new ConflictingSpecificationError(
|
|
414
|
+
"Can't include meridiem when specifying 24-hour format"
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
return { input, tokens, regex, rawMatches, matches, result, zone };
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
export function parseFromTokens(locale, input, format) {
|
|
422
|
+
const { result, zone, invalidReason } = explainFromTokens(locale, input, format);
|
|
423
|
+
return [result, zone, invalidReason];
|
|
424
|
+
}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This is just a junk drawer, containing anything used across multiple classes.
|
|
3
|
+
Because Luxon is small(ish), this should stay small and we won't worry about splitting
|
|
4
|
+
it up into, say, parsingUtil.js and basicUtil.js and so on. But they are divided up by feature area.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { InvalidArgumentError } from "../errors.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// TYPES
|
|
14
|
+
|
|
15
|
+
export function isUndefined(o) {
|
|
16
|
+
return typeof o === "undefined";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function isNumber(o) {
|
|
20
|
+
return typeof o === "number";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function isInteger(o) {
|
|
24
|
+
return typeof o === "number" && o % 1 === 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function isString(o) {
|
|
28
|
+
return typeof o === "string";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function isDate(o) {
|
|
32
|
+
return Object.prototype.toString.call(o) === "[object Date]";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// CAPABILITIES
|
|
36
|
+
|
|
37
|
+
export function hasIntl() {
|
|
38
|
+
try {
|
|
39
|
+
return typeof Intl !== "undefined" && Intl.DateTimeFormat;
|
|
40
|
+
} catch (e) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function hasFormatToParts() {
|
|
46
|
+
return !isUndefined(Intl.DateTimeFormat.prototype.formatToParts);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function hasRelative() {
|
|
50
|
+
try {
|
|
51
|
+
return typeof Intl !== "undefined" && !!Intl.RelativeTimeFormat;
|
|
52
|
+
} catch (e) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// OBJECTS AND ARRAYS
|
|
58
|
+
|
|
59
|
+
export function maybeArray(thing) {
|
|
60
|
+
return Array.isArray(thing) ? thing : [thing];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function bestBy(arr, by, compare) {
|
|
64
|
+
if (arr.length === 0) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
return arr.reduce((best, next) => {
|
|
68
|
+
const pair = [by(next), next];
|
|
69
|
+
if (!best) {
|
|
70
|
+
return pair;
|
|
71
|
+
} else if (compare(best[0], pair[0]) === best[0]) {
|
|
72
|
+
return best;
|
|
73
|
+
} else {
|
|
74
|
+
return pair;
|
|
75
|
+
}
|
|
76
|
+
}, null)[1];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function pick(obj, keys) {
|
|
80
|
+
return keys.reduce((a, k) => {
|
|
81
|
+
a[k] = obj[k];
|
|
82
|
+
return a;
|
|
83
|
+
}, {});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function hasOwnProperty(obj, prop) {
|
|
87
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// NUMBERS AND STRINGS
|
|
91
|
+
|
|
92
|
+
export function integerBetween(thing, bottom, top) {
|
|
93
|
+
return isInteger(thing) && thing >= bottom && thing <= top;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// x % n but takes the sign of n instead of x
|
|
97
|
+
export function floorMod(x, n) {
|
|
98
|
+
return x - n * Math.floor(x / n);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function padStart(input, n = 2) {
|
|
102
|
+
const minus = input < 0 ? "-" : "";
|
|
103
|
+
const target = minus ? input * -1 : input;
|
|
104
|
+
let result;
|
|
105
|
+
|
|
106
|
+
if (target.toString().length < n) {
|
|
107
|
+
result = ("0".repeat(n) + target).slice(-n);
|
|
108
|
+
} else {
|
|
109
|
+
result = target.toString();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return `${minus}${result}`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function parseInteger(string) {
|
|
116
|
+
if (isUndefined(string) || string === null || string === "") {
|
|
117
|
+
return undefined;
|
|
118
|
+
} else {
|
|
119
|
+
return parseInt(string, 10);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function parseMillis(fraction) {
|
|
124
|
+
// Return undefined (instead of 0) in these cases, where fraction is not set
|
|
125
|
+
if (isUndefined(fraction) || fraction === null || fraction === "") {
|
|
126
|
+
return undefined;
|
|
127
|
+
} else {
|
|
128
|
+
const f = parseFloat("0." + fraction) * 1000;
|
|
129
|
+
return Math.floor(f);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function roundTo(number, digits, towardZero = false) {
|
|
134
|
+
const factor = 10 ** digits,
|
|
135
|
+
rounder = towardZero ? Math.trunc : Math.round;
|
|
136
|
+
return rounder(number * factor) / factor;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// DATE BASICS
|
|
140
|
+
|
|
141
|
+
export function isLeapYear(year) {
|
|
142
|
+
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function daysInYear(year) {
|
|
146
|
+
return isLeapYear(year) ? 366 : 365;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function daysInMonth(year, month) {
|
|
150
|
+
const modMonth = floorMod(month - 1, 12) + 1,
|
|
151
|
+
modYear = year + (month - modMonth) / 12;
|
|
152
|
+
|
|
153
|
+
if (modMonth === 2) {
|
|
154
|
+
return isLeapYear(modYear) ? 29 : 28;
|
|
155
|
+
} else {
|
|
156
|
+
return [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][modMonth - 1];
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// covert a calendar object to a local timestamp (epoch, but with the offset baked in)
|
|
161
|
+
export function objToLocalTS(obj) {
|
|
162
|
+
let d = Date.UTC(
|
|
163
|
+
obj.year,
|
|
164
|
+
obj.month - 1,
|
|
165
|
+
obj.day,
|
|
166
|
+
obj.hour,
|
|
167
|
+
obj.minute,
|
|
168
|
+
obj.second,
|
|
169
|
+
obj.millisecond
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
// for legacy reasons, years between 0 and 99 are interpreted as 19XX; revert that
|
|
173
|
+
if (obj.year < 100 && obj.year >= 0) {
|
|
174
|
+
d = new Date(d);
|
|
175
|
+
d.setUTCFullYear(d.getUTCFullYear() - 1900);
|
|
176
|
+
}
|
|
177
|
+
return +d;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function weeksInWeekYear(weekYear) {
|
|
181
|
+
const p1 =
|
|
182
|
+
(weekYear +
|
|
183
|
+
Math.floor(weekYear / 4) -
|
|
184
|
+
Math.floor(weekYear / 100) +
|
|
185
|
+
Math.floor(weekYear / 400)) %
|
|
186
|
+
7,
|
|
187
|
+
last = weekYear - 1,
|
|
188
|
+
p2 = (last + Math.floor(last / 4) - Math.floor(last / 100) + Math.floor(last / 400)) % 7;
|
|
189
|
+
return p1 === 4 || p2 === 3 ? 53 : 52;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function untruncateYear(year) {
|
|
193
|
+
if (year > 99) {
|
|
194
|
+
return year;
|
|
195
|
+
} else return year > 60 ? 1900 + year : 2000 + year;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// PARSING
|
|
199
|
+
|
|
200
|
+
export function parseZoneInfo(ts, offsetFormat, locale, timeZone = null) {
|
|
201
|
+
const date = new Date(ts),
|
|
202
|
+
intlOpts = {
|
|
203
|
+
hour12: false,
|
|
204
|
+
year: "numeric",
|
|
205
|
+
month: "2-digit",
|
|
206
|
+
day: "2-digit",
|
|
207
|
+
hour: "2-digit",
|
|
208
|
+
minute: "2-digit"
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
if (timeZone) {
|
|
212
|
+
intlOpts.timeZone = timeZone;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const modified = Object.assign({ timeZoneName: offsetFormat }, intlOpts),
|
|
216
|
+
intl = hasIntl();
|
|
217
|
+
|
|
218
|
+
if (intl && hasFormatToParts()) {
|
|
219
|
+
const parsed = new Intl.DateTimeFormat(locale, modified)
|
|
220
|
+
.formatToParts(date)
|
|
221
|
+
.find(m => m.type.toLowerCase() === "timezonename");
|
|
222
|
+
return parsed ? parsed.value : null;
|
|
223
|
+
} else if (intl) {
|
|
224
|
+
// this probably doesn't work for all locales
|
|
225
|
+
const without = new Intl.DateTimeFormat(locale, intlOpts).format(date),
|
|
226
|
+
included = new Intl.DateTimeFormat(locale, modified).format(date),
|
|
227
|
+
diffed = included.substring(without.length),
|
|
228
|
+
trimmed = diffed.replace(/^[, \u200e]+/, "");
|
|
229
|
+
return trimmed;
|
|
230
|
+
} else {
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// signedOffset('-5', '30') -> -330
|
|
236
|
+
export function signedOffset(offHourStr, offMinuteStr) {
|
|
237
|
+
let offHour = parseInt(offHourStr, 10);
|
|
238
|
+
|
|
239
|
+
// don't || this because we want to preserve -0
|
|
240
|
+
if (Number.isNaN(offHour)) {
|
|
241
|
+
offHour = 0;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const offMin = parseInt(offMinuteStr, 10) || 0,
|
|
245
|
+
offMinSigned = offHour < 0 || Object.is(offHour, -0) ? -offMin : offMin;
|
|
246
|
+
return offHour * 60 + offMinSigned;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// COERCION
|
|
250
|
+
|
|
251
|
+
export function asNumber(value) {
|
|
252
|
+
const numericValue = Number(value);
|
|
253
|
+
if (typeof value === "boolean" || value === "" || Number.isNaN(numericValue))
|
|
254
|
+
throw new InvalidArgumentError(`Invalid unit value ${value}`);
|
|
255
|
+
return numericValue;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export function normalizeObject(obj, normalizer, nonUnitKeys) {
|
|
259
|
+
const normalized = {};
|
|
260
|
+
for (const u in obj) {
|
|
261
|
+
if (hasOwnProperty(obj, u)) {
|
|
262
|
+
if (nonUnitKeys.indexOf(u) >= 0) continue;
|
|
263
|
+
const v = obj[u];
|
|
264
|
+
if (v === undefined || v === null) continue;
|
|
265
|
+
normalized[normalizer(u)] = asNumber(v);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return normalized;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export function formatOffset(offset, format) {
|
|
272
|
+
const hours = Math.trunc(Math.abs(offset / 60)),
|
|
273
|
+
minutes = Math.trunc(Math.abs(offset % 60)),
|
|
274
|
+
sign = offset >= 0 ? "+" : "-";
|
|
275
|
+
|
|
276
|
+
switch (format) {
|
|
277
|
+
case "short":
|
|
278
|
+
return `${sign}${padStart(hours, 2)}:${padStart(minutes, 2)}`;
|
|
279
|
+
case "narrow":
|
|
280
|
+
return `${sign}${hours}${minutes > 0 ? `:${minutes}` : ""}`;
|
|
281
|
+
case "techie":
|
|
282
|
+
return `${sign}${padStart(hours, 2)}${padStart(minutes, 2)}`;
|
|
283
|
+
default:
|
|
284
|
+
throw new RangeError(`Value format ${format} is out of range for property format`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export function timeObject(obj) {
|
|
289
|
+
return pick(obj, ["hour", "minute", "second", "millisecond"]);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export const ianaRegex = /[A-Za-z_+-]{1,256}(:?\/[A-Za-z_+-]{1,256}(\/[A-Za-z_+-]{1,256})?)?/;
|