Merge pull request #14277 from backstage/freben/human-types
move `HumanDuration` to `@backstage/types`
This commit is contained in:
@@ -7,19 +7,11 @@ import { AbortSignal as AbortSignal_2 } from 'node-abort-controller';
|
||||
import { Config } from '@backstage/config';
|
||||
import { DatabaseManager } from '@backstage/backend-common';
|
||||
import { Duration } from 'luxon';
|
||||
import { HumanDuration as HumanDuration_2 } from '@backstage/types';
|
||||
import { Logger } from 'winston';
|
||||
|
||||
// @public
|
||||
export type HumanDuration = {
|
||||
years?: number;
|
||||
months?: number;
|
||||
weeks?: number;
|
||||
days?: number;
|
||||
hours?: number;
|
||||
minutes?: number;
|
||||
seconds?: number;
|
||||
milliseconds?: number;
|
||||
};
|
||||
// @public @deprecated
|
||||
export type HumanDuration = HumanDuration_2;
|
||||
|
||||
// @public
|
||||
export interface PluginTaskScheduler {
|
||||
@@ -59,10 +51,10 @@ export interface TaskScheduleDefinition {
|
||||
cron: string;
|
||||
}
|
||||
| Duration
|
||||
| HumanDuration;
|
||||
initialDelay?: Duration | HumanDuration;
|
||||
| HumanDuration_2;
|
||||
initialDelay?: Duration | HumanDuration_2;
|
||||
scope?: 'global' | 'local';
|
||||
timeout: Duration | HumanDuration;
|
||||
timeout: Duration | HumanDuration_2;
|
||||
}
|
||||
|
||||
// @public
|
||||
@@ -72,10 +64,10 @@ export interface TaskScheduleDefinitionConfig {
|
||||
cron: string;
|
||||
}
|
||||
| string
|
||||
| HumanDuration;
|
||||
initialDelay?: string | HumanDuration;
|
||||
| HumanDuration_2;
|
||||
initialDelay?: string | HumanDuration_2;
|
||||
scope?: 'global' | 'local';
|
||||
timeout: string | HumanDuration;
|
||||
timeout: string | HumanDuration_2;
|
||||
}
|
||||
|
||||
// @public
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2022 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { HumanDuration as TypesHumanDuration } from '@backstage/types';
|
||||
|
||||
/**
|
||||
* Human friendly durations object.
|
||||
*
|
||||
* @public
|
||||
* @deprecated Import from `@backstage/types` instead
|
||||
*/
|
||||
export type HumanDuration = TypesHumanDuration;
|
||||
@@ -21,3 +21,4 @@
|
||||
*/
|
||||
|
||||
export * from './tasks';
|
||||
export * from './deprecated';
|
||||
|
||||
@@ -23,5 +23,4 @@ export type {
|
||||
TaskRunner,
|
||||
TaskScheduleDefinition,
|
||||
TaskScheduleDefinitionConfig,
|
||||
HumanDuration,
|
||||
} from './types';
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import { HumanDuration } from '@backstage/types';
|
||||
import { Duration } from 'luxon';
|
||||
import { readTaskScheduleDefinitionFromConfig } from './readTaskScheduleDefinitionFromConfig';
|
||||
import { HumanDuration } from './types';
|
||||
|
||||
describe('readTaskScheduleDefinitionFromConfig', () => {
|
||||
it('all valid values', () => {
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
|
||||
import { Config } from '@backstage/config';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
import { HumanDuration, TaskScheduleDefinition } from './types';
|
||||
import { HumanDuration, JsonObject } from '@backstage/types';
|
||||
import { TaskScheduleDefinition } from './types';
|
||||
import { Duration } from 'luxon';
|
||||
|
||||
const propsOfHumanDuration = [
|
||||
|
||||
@@ -14,26 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { HumanDuration } from '@backstage/types';
|
||||
import { CronTime } from 'cron';
|
||||
import { Duration } from 'luxon';
|
||||
import { AbortSignal } from 'node-abort-controller';
|
||||
import { z } from 'zod';
|
||||
|
||||
/**
|
||||
* Human friendly durations object
|
||||
* @public
|
||||
*/
|
||||
export type HumanDuration = {
|
||||
years?: number;
|
||||
months?: number;
|
||||
weeks?: number;
|
||||
days?: number;
|
||||
hours?: number;
|
||||
minutes?: number;
|
||||
seconds?: number;
|
||||
milliseconds?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* A function that can be called as a scheduled task.
|
||||
*
|
||||
|
||||
@@ -3,6 +3,18 @@
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
// @public
|
||||
export type HumanDuration = {
|
||||
years?: number;
|
||||
months?: number;
|
||||
weeks?: number;
|
||||
days?: number;
|
||||
hours?: number;
|
||||
minutes?: number;
|
||||
seconds?: number;
|
||||
milliseconds?: number;
|
||||
};
|
||||
|
||||
// @public
|
||||
export interface JsonArray extends Array<JsonValue> {}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
"devDependencies": {
|
||||
"@backstage/cli": "workspace:^",
|
||||
"@types/zen-observable": "^0.8.0",
|
||||
"luxon": "^3.0.0",
|
||||
"zen-observable": "^0.8.15"
|
||||
},
|
||||
"files": [
|
||||
|
||||
@@ -22,3 +22,4 @@
|
||||
|
||||
export type { JsonArray, JsonObject, JsonPrimitive, JsonValue } from './json';
|
||||
export type { Observable, Observer, Subscription } from './observable';
|
||||
export type { HumanDuration } from './time';
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2022 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { HumanDuration } from './time';
|
||||
import { Duration } from 'luxon';
|
||||
|
||||
describe('time', () => {
|
||||
describe('HumanDuration', () => {
|
||||
const durations: HumanDuration[] = [
|
||||
{ years: 1 },
|
||||
{ months: 1 },
|
||||
{ weeks: 1 },
|
||||
{ days: 1 },
|
||||
{ hours: 1 },
|
||||
{ minutes: 1 },
|
||||
{ seconds: 1 },
|
||||
{ milliseconds: 1 },
|
||||
];
|
||||
it.each(durations)('successfully parsed by luxon, %p', d => {
|
||||
expect(Duration.fromObject(d).toObject()).toEqual(d);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2022 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Human friendly durations object.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type HumanDuration = {
|
||||
years?: number;
|
||||
months?: number;
|
||||
weeks?: number;
|
||||
days?: number;
|
||||
hours?: number;
|
||||
minutes?: number;
|
||||
seconds?: number;
|
||||
milliseconds?: number;
|
||||
};
|
||||
Reference in New Issue
Block a user