@backstage/backend-plugin-api 0.6.18 → 0.6.19-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/alpha/package.json +1 -1
- package/dist/index.cjs.js +58 -16
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +391 -13
- package/dist/testUtils.cjs.js +1 -2
- package/dist/testUtils.cjs.js.map +1 -1
- package/package.json +7 -6
- package/testUtils/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @backstage/backend-plugin-api
|
|
2
2
|
|
|
3
|
+
## 0.6.19-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9e63318: Added an optional `accessRestrictions` to external access service tokens and service principals in general, such that you can limit their access to certain plugins or permissions.
|
|
8
|
+
- 0665b7e: Renamed `BackendPluginConfig`, `BackendModuleConfig`, and `ExtensionPointConfig` respectively to `CreateBackendPluginOptions`, `CreateBackendModuleOptions`, and `CreateExtensionPointOptions` to standardize frontend and backend factories signatures.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @backstage/plugin-auth-node@0.4.14-next.1
|
|
11
|
+
|
|
12
|
+
## 0.6.19-next.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 6551b3d: Moved the declaration of the `SchedulerService` here, along with prefixed versions of all of the types it depends on, from `@backstage/backend-tasks`
|
|
17
|
+
- 1779188: Start using the `isDatabaseConflictError` helper from the `@backstage/backend-plugin-api` package in order to avoid dependency with the soon to deprecate `@backstage/backend-common` package.
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @backstage/plugin-auth-node@0.4.14-next.0
|
|
20
|
+
- @backstage/cli-common@0.1.13
|
|
21
|
+
- @backstage/config@1.2.0
|
|
22
|
+
- @backstage/errors@1.2.4
|
|
23
|
+
- @backstage/types@1.1.1
|
|
24
|
+
- @backstage/plugin-permission-common@0.7.13
|
|
25
|
+
|
|
3
26
|
## 0.6.18
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/alpha/package.json
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var config = require('@backstage/config');
|
|
4
|
+
var luxon = require('luxon');
|
|
3
5
|
var paths = require('./cjs/paths-D7KGMZeP.cjs.js');
|
|
4
6
|
var cliCommon = require('@backstage/cli-common');
|
|
5
7
|
require('@backstage/errors');
|
|
@@ -43,10 +45,7 @@ function createServiceFactory(config) {
|
|
|
43
45
|
service: c.service,
|
|
44
46
|
initialization: c.initialization,
|
|
45
47
|
..."createRootContext" in c ? {
|
|
46
|
-
createRootContext: async (deps) =>
|
|
47
|
-
var _a;
|
|
48
|
-
return (_a = c == null ? void 0 : c.createRootContext) == null ? void 0 : _a.call(c, deps);
|
|
49
|
-
}
|
|
48
|
+
createRootContext: async (deps) => c?.createRootContext?.(deps)
|
|
50
49
|
} : {},
|
|
51
50
|
deps: c.deps,
|
|
52
51
|
factory: async (deps, ctx) => c.factory(deps, ctx)
|
|
@@ -85,19 +84,60 @@ exports.coreServices = void 0;
|
|
|
85
84
|
coreServices2.identity = createServiceRef({ id: "core.identity" });
|
|
86
85
|
})(exports.coreServices || (exports.coreServices = {}));
|
|
87
86
|
|
|
88
|
-
function
|
|
87
|
+
function readDuration(config$1, key) {
|
|
88
|
+
if (typeof config$1.get(key) === "string") {
|
|
89
|
+
const value = config$1.getString(key);
|
|
90
|
+
const duration = luxon.Duration.fromISO(value);
|
|
91
|
+
if (!duration.isValid) {
|
|
92
|
+
throw new Error(`Invalid duration: ${value}`);
|
|
93
|
+
}
|
|
94
|
+
return duration;
|
|
95
|
+
}
|
|
96
|
+
return config.readDurationFromConfig(config$1, { key });
|
|
97
|
+
}
|
|
98
|
+
function readCronOrDuration(config, key) {
|
|
99
|
+
const value = config.get(key);
|
|
100
|
+
if (typeof value === "object" && value.cron) {
|
|
101
|
+
return value;
|
|
102
|
+
}
|
|
103
|
+
return readDuration(config, key);
|
|
104
|
+
}
|
|
105
|
+
function readSchedulerServiceTaskScheduleDefinitionFromConfig(config) {
|
|
106
|
+
const frequency = readCronOrDuration(config, "frequency");
|
|
107
|
+
const timeout = readDuration(config, "timeout");
|
|
108
|
+
const initialDelay = config.has("initialDelay") ? readDuration(config, "initialDelay") : void 0;
|
|
109
|
+
const scope = config.getOptionalString("scope");
|
|
110
|
+
if (scope && !["global", "local"].includes(scope)) {
|
|
111
|
+
throw new Error(
|
|
112
|
+
`Only "global" or "local" are allowed for TaskScheduleDefinition.scope, but got: ${scope}`
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
frequency,
|
|
117
|
+
timeout,
|
|
118
|
+
initialDelay,
|
|
119
|
+
scope
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function isDatabaseConflictError(e) {
|
|
124
|
+
const message = e?.message;
|
|
125
|
+
return typeof message === "string" && (/SQLITE_CONSTRAINT(?:_UNIQUE)?: UNIQUE/.test(message) || /UNIQUE constraint failed:/.test(message) || /unique constraint/.test(message) || /Duplicate entry/.test(message));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function createExtensionPoint(options) {
|
|
89
129
|
return {
|
|
90
|
-
id:
|
|
130
|
+
id: options.id,
|
|
91
131
|
get T() {
|
|
92
132
|
throw new Error(`tried to read ExtensionPoint.T of ${this}`);
|
|
93
133
|
},
|
|
94
134
|
toString() {
|
|
95
|
-
return `extensionPoint{${
|
|
135
|
+
return `extensionPoint{${options.id}}`;
|
|
96
136
|
},
|
|
97
137
|
$$type: "@backstage/ExtensionPoint"
|
|
98
138
|
};
|
|
99
139
|
}
|
|
100
|
-
function createBackendPlugin(
|
|
140
|
+
function createBackendPlugin(options) {
|
|
101
141
|
const factory = () => {
|
|
102
142
|
let registrations;
|
|
103
143
|
return {
|
|
@@ -109,7 +149,7 @@ function createBackendPlugin(config) {
|
|
|
109
149
|
}
|
|
110
150
|
const extensionPoints = [];
|
|
111
151
|
let init = void 0;
|
|
112
|
-
|
|
152
|
+
options.register({
|
|
113
153
|
registerExtensionPoint(ext, impl) {
|
|
114
154
|
if (init) {
|
|
115
155
|
throw new Error(
|
|
@@ -130,13 +170,13 @@ function createBackendPlugin(config) {
|
|
|
130
170
|
});
|
|
131
171
|
if (!init) {
|
|
132
172
|
throw new Error(
|
|
133
|
-
`registerInit was not called by register in ${
|
|
173
|
+
`registerInit was not called by register in ${options.pluginId}`
|
|
134
174
|
);
|
|
135
175
|
}
|
|
136
176
|
registrations = [
|
|
137
177
|
{
|
|
138
178
|
type: "plugin",
|
|
139
|
-
pluginId:
|
|
179
|
+
pluginId: options.pluginId,
|
|
140
180
|
extensionPoints,
|
|
141
181
|
init
|
|
142
182
|
}
|
|
@@ -148,7 +188,7 @@ function createBackendPlugin(config) {
|
|
|
148
188
|
factory.$$type = "@backstage/BackendFeatureFactory";
|
|
149
189
|
return factory;
|
|
150
190
|
}
|
|
151
|
-
function createBackendModule(
|
|
191
|
+
function createBackendModule(options) {
|
|
152
192
|
const factory = () => {
|
|
153
193
|
let registrations;
|
|
154
194
|
return {
|
|
@@ -160,7 +200,7 @@ function createBackendModule(config) {
|
|
|
160
200
|
}
|
|
161
201
|
const extensionPoints = [];
|
|
162
202
|
let init = void 0;
|
|
163
|
-
|
|
203
|
+
options.register({
|
|
164
204
|
registerExtensionPoint(ext, impl) {
|
|
165
205
|
if (init) {
|
|
166
206
|
throw new Error(
|
|
@@ -181,14 +221,14 @@ function createBackendModule(config) {
|
|
|
181
221
|
});
|
|
182
222
|
if (!init) {
|
|
183
223
|
throw new Error(
|
|
184
|
-
`registerInit was not called by register in ${
|
|
224
|
+
`registerInit was not called by register in ${options.moduleId} module for ${options.pluginId}`
|
|
185
225
|
);
|
|
186
226
|
}
|
|
187
227
|
registrations = [
|
|
188
228
|
{
|
|
189
229
|
type: "module",
|
|
190
|
-
pluginId:
|
|
191
|
-
moduleId:
|
|
230
|
+
pluginId: options.pluginId,
|
|
231
|
+
moduleId: options.moduleId,
|
|
192
232
|
extensionPoints,
|
|
193
233
|
init
|
|
194
234
|
}
|
|
@@ -213,4 +253,6 @@ exports.createBackendPlugin = createBackendPlugin;
|
|
|
213
253
|
exports.createExtensionPoint = createExtensionPoint;
|
|
214
254
|
exports.createServiceFactory = createServiceFactory;
|
|
215
255
|
exports.createServiceRef = createServiceRef;
|
|
256
|
+
exports.isDatabaseConflictError = isDatabaseConflictError;
|
|
257
|
+
exports.readSchedulerServiceTaskScheduleDefinitionFromConfig = readSchedulerServiceTaskScheduleDefinitionFromConfig;
|
|
216
258
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/services/system/types.ts","../src/services/definitions/coreServices.ts","../src/wiring/factories.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BackendFeature } from '../../types';\n\n/**\n * TODO\n *\n * @public\n */\nexport type ServiceRef<\n TService,\n TScope extends 'root' | 'plugin' = 'root' | 'plugin',\n> = {\n id: string;\n\n /**\n * This determines the scope at which this service is available.\n *\n * Root scoped services are available to all other services but\n * may only depend on other root scoped services.\n *\n * Plugin scoped services are only available to other plugin scoped\n * services but may depend on all other services.\n */\n scope: TScope;\n\n /**\n * Utility for getting the type of the service, using `typeof serviceRef.T`.\n * Attempting to actually read this value will result in an exception.\n */\n T: TService;\n\n $$type: '@backstage/ServiceRef';\n};\n\n/** @public */\nexport interface ServiceFactory<\n TService = unknown,\n TScope extends 'plugin' | 'root' = 'plugin' | 'root',\n> extends BackendFeature {\n service: ServiceRef<TService, TScope>;\n}\n\n/** @internal */\nexport interface InternalServiceFactory<\n TService = unknown,\n TScope extends 'plugin' | 'root' = 'plugin' | 'root',\n> extends ServiceFactory<TService, TScope> {\n version: 'v1';\n initialization?: 'always' | 'lazy';\n deps: { [key in string]: ServiceRef<unknown> };\n createRootContext?(deps: { [key in string]: unknown }): Promise<unknown>;\n factory(\n deps: { [key in string]: unknown },\n context: unknown,\n ): Promise<TService>;\n}\n\n/**\n * Represents either a {@link ServiceFactory} or a function that returns one.\n *\n * @public\n */\nexport type ServiceFactoryOrFunction = ServiceFactory | (() => ServiceFactory);\n\n/** @public */\nexport interface ServiceRefConfig<TService, TScope extends 'root' | 'plugin'> {\n id: string;\n scope?: TScope;\n defaultFactory?: (\n service: ServiceRef<TService, TScope>,\n ) => Promise<ServiceFactoryOrFunction>;\n}\n\n/**\n * Creates a new service definition. This overload is used to create plugin scoped services.\n *\n * @public\n */\nexport function createServiceRef<TService>(\n config: ServiceRefConfig<TService, 'plugin'>,\n): ServiceRef<TService, 'plugin'>;\n\n/**\n * Creates a new service definition. This overload is used to create root scoped services.\n *\n * @public\n */\nexport function createServiceRef<TService>(\n config: ServiceRefConfig<TService, 'root'>,\n): ServiceRef<TService, 'root'>;\nexport function createServiceRef<TService>(\n config: ServiceRefConfig<TService, any>,\n): ServiceRef<TService, any> {\n const { id, scope = 'plugin', defaultFactory } = config;\n return {\n id,\n scope,\n get T(): TService {\n throw new Error(`tried to read ServiceRef.T of ${this}`);\n },\n toString() {\n return `serviceRef{${config.id}}`;\n },\n $$type: '@backstage/ServiceRef',\n __defaultFactory: defaultFactory,\n } as ServiceRef<TService, typeof scope> & {\n __defaultFactory?: (\n service: ServiceRef<TService>,\n ) => Promise<ServiceFactory<TService> | (() => ServiceFactory<TService>)>;\n };\n}\n\n/** @ignore */\ntype ServiceRefsToInstances<\n T extends { [key in string]: ServiceRef<unknown> },\n TScope extends 'root' | 'plugin' = 'root' | 'plugin',\n> = {\n [key in keyof T as T[key]['scope'] extends TScope ? key : never]: T[key]['T'];\n};\n\n/** @public */\nexport interface RootServiceFactoryConfig<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n> {\n /**\n * The initialization strategy for the service factory. This service is root scoped and will use `always` by default.\n *\n * @remarks\n *\n * - `always` - The service will always be initialized regardless if it is used or not.\n * - `lazy` - The service will only be initialized if it is depended on by a different service or feature.\n *\n * Service factories for root scoped services use `always` as the default, while plugin scoped services use `lazy`.\n */\n initialization?: 'always' | 'lazy';\n service: ServiceRef<TService, 'root'>;\n deps: TDeps;\n factory(deps: ServiceRefsToInstances<TDeps, 'root'>): TImpl | Promise<TImpl>;\n}\n\n/** @public */\nexport interface PluginServiceFactoryConfig<\n TService,\n TContext,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n> {\n /**\n * The initialization strategy for the service factory. This service is plugin scoped and will use `lazy` by default.\n *\n * @remarks\n *\n * - `always` - The service will always be initialized regardless if it is used or not.\n * - `lazy` - The service will only be initialized if it is depended on by a different service or feature.\n *\n * Service factories for root scoped services use `always` as the default, while plugin scoped services use `lazy`.\n */\n initialization?: 'always' | 'lazy';\n service: ServiceRef<TService, 'plugin'>;\n deps: TDeps;\n createRootContext?(\n deps: ServiceRefsToInstances<TDeps, 'root'>,\n ): TContext | Promise<TContext>;\n factory(\n deps: ServiceRefsToInstances<TDeps>,\n context: TContext,\n ): TImpl | Promise<TImpl>;\n}\n\n/**\n * Creates a root scoped service factory without options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown, 'root'> },\n TOpts extends object | undefined = undefined,\n>(\n config: RootServiceFactoryConfig<TService, TImpl, TDeps>,\n): () => ServiceFactory<TService, 'root'>;\n/**\n * Creates a root scoped service factory with optional options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown, 'root'> },\n TOpts extends object | undefined = undefined,\n>(\n config: (options?: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>,\n): (options?: TOpts) => ServiceFactory<TService, 'root'>;\n/**\n * Creates a plugin scoped service factory without options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext = undefined,\n TOpts extends object | undefined = undefined,\n>(\n config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>,\n): () => ServiceFactory<TService, 'plugin'>;\n/**\n * Creates a plugin scoped service factory with optional options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext = undefined,\n TOpts extends object | undefined = undefined,\n>(\n config: (\n options?: TOpts,\n ) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>,\n): (options?: TOpts) => ServiceFactory<TService, 'plugin'>;\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext,\n TOpts extends object | undefined = undefined,\n>(\n config:\n | RootServiceFactoryConfig<TService, TImpl, TDeps>\n | PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>\n | ((options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>)\n | ((\n options: TOpts,\n ) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>)\n | (() => RootServiceFactoryConfig<TService, TImpl, TDeps>)\n | (() => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>),\n): (options: TOpts) => ServiceFactory {\n const configCallback = typeof config === 'function' ? config : () => config;\n const factory = (\n options: TOpts,\n ): InternalServiceFactory<TService, 'plugin' | 'root'> => {\n const anyConf = configCallback(options);\n if (anyConf.service.scope === 'root') {\n const c = anyConf as RootServiceFactoryConfig<TService, TImpl, TDeps>;\n return {\n $$type: '@backstage/BackendFeature',\n version: 'v1',\n service: c.service,\n initialization: c.initialization,\n deps: c.deps,\n factory: async (deps: TDeps) => c.factory(deps),\n };\n }\n const c = anyConf as PluginServiceFactoryConfig<\n TService,\n TContext,\n TImpl,\n TDeps\n >;\n return {\n $$type: '@backstage/BackendFeature',\n version: 'v1',\n service: c.service,\n initialization: c.initialization,\n ...('createRootContext' in c\n ? {\n createRootContext: async (deps: TDeps) =>\n c?.createRootContext?.(deps),\n }\n : {}),\n deps: c.deps,\n factory: async (deps: TDeps, ctx: TContext) => c.factory(deps, ctx),\n };\n };\n\n factory.$$type = '@backstage/BackendFeatureFactory';\n\n return factory;\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system';\n\n/**\n * All core services references\n *\n * @public\n */\nexport namespace coreServices {\n /**\n * The service reference for the plugin scoped {@link AuthService}.\n *\n * @public\n */\n export const auth = createServiceRef<import('./AuthService').AuthService>({\n id: 'core.auth',\n });\n\n /**\n * The service reference for the plugin scoped {@link UserInfoService}.\n *\n * @public\n */\n export const userInfo = createServiceRef<\n import('./UserInfoService').UserInfoService\n >({\n id: 'core.userInfo',\n });\n\n /**\n * The service reference for the plugin scoped {@link CacheService}.\n *\n * @public\n */\n export const cache = createServiceRef<import('./CacheService').CacheService>({\n id: 'core.cache',\n });\n\n /**\n * The service reference for the root scoped {@link RootConfigService}.\n *\n * @public\n */\n export const rootConfig = createServiceRef<\n import('./RootConfigService').RootConfigService\n >({ id: 'core.rootConfig', scope: 'root' });\n\n /**\n * The service reference for the plugin scoped {@link DatabaseService}.\n *\n * @public\n */\n export const database = createServiceRef<\n import('./DatabaseService').DatabaseService\n >({ id: 'core.database' });\n\n /**\n * The service reference for the plugin scoped {@link DiscoveryService}.\n *\n * @public\n */\n export const discovery = createServiceRef<\n import('./DiscoveryService').DiscoveryService\n >({ id: 'core.discovery' });\n\n /**\n * The service reference for the plugin scoped {@link HttpAuthService}.\n *\n * @public\n */\n export const httpAuth = createServiceRef<\n import('./HttpAuthService').HttpAuthService\n >({ id: 'core.httpAuth' });\n\n /**\n * The service reference for the plugin scoped {@link HttpRouterService}.\n *\n * @public\n */\n export const httpRouter = createServiceRef<\n import('./HttpRouterService').HttpRouterService\n >({ id: 'core.httpRouter' });\n\n /**\n * The service reference for the plugin scoped {@link LifecycleService}.\n *\n * @public\n */\n export const lifecycle = createServiceRef<\n import('./LifecycleService').LifecycleService\n >({ id: 'core.lifecycle' });\n\n /**\n * The service reference for the plugin scoped {@link LoggerService}.\n *\n * @public\n */\n export const logger = createServiceRef<\n import('./LoggerService').LoggerService\n >({ id: 'core.logger' });\n\n /**\n * The service reference for the plugin scoped {@link PermissionsService}.\n *\n * @public\n */\n export const permissions = createServiceRef<\n import('./PermissionsService').PermissionsService\n >({ id: 'core.permissions' });\n\n /**\n * The service reference for the plugin scoped {@link PluginMetadataService}.\n *\n * @public\n */\n export const pluginMetadata = createServiceRef<\n import('./PluginMetadataService').PluginMetadataService\n >({ id: 'core.pluginMetadata' });\n\n /**\n * The service reference for the root scoped {@link RootHttpRouterService}.\n *\n * @public\n */\n export const rootHttpRouter = createServiceRef<\n import('./RootHttpRouterService').RootHttpRouterService\n >({ id: 'core.rootHttpRouter', scope: 'root' });\n\n /**\n * The service reference for the root scoped {@link RootLifecycleService}.\n *\n * @public\n */\n export const rootLifecycle = createServiceRef<\n import('./RootLifecycleService').RootLifecycleService\n >({ id: 'core.rootLifecycle', scope: 'root' });\n\n /**\n * The service reference for the root scoped {@link RootLoggerService}.\n *\n * @public\n */\n export const rootLogger = createServiceRef<\n import('./RootLoggerService').RootLoggerService\n >({ id: 'core.rootLogger', scope: 'root' });\n\n /**\n * The service reference for the plugin scoped {@link SchedulerService}.\n *\n * @public\n */\n export const scheduler = createServiceRef<\n import('./SchedulerService').SchedulerService\n >({ id: 'core.scheduler' });\n\n /**\n * The service reference for the plugin scoped {@link TokenManagerService}.\n *\n * @public\n */\n export const tokenManager = createServiceRef<\n import('./TokenManagerService').TokenManagerService\n >({ id: 'core.tokenManager' });\n\n /**\n * The service reference for the plugin scoped {@link UrlReaderService}.\n *\n * @public\n */\n export const urlReader = createServiceRef<\n import('./UrlReaderService').UrlReaderService\n >({ id: 'core.urlReader' });\n\n /**\n * The service reference for the plugin scoped {@link IdentityService}.\n *\n * @public\n */\n export const identity = createServiceRef<\n import('./IdentityService').IdentityService\n >({ id: 'core.identity' });\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BackendFeature, BackendFeatureFactory } from '../types';\nimport {\n BackendModuleRegistrationPoints,\n BackendPluginRegistrationPoints,\n ExtensionPoint,\n InternalBackendModuleRegistration,\n InternalBackendPluginRegistration,\n} from './types';\n\n/**\n * The configuration options passed to {@link createExtensionPoint}.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/extension-points | The architecture of extension points}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport interface ExtensionPointConfig {\n /**\n * The ID of this extension point.\n *\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\n id: string;\n}\n\n/**\n * Creates a new backend extension point.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/extension-points | The architecture of extension points}\n */\nexport function createExtensionPoint<T>(\n config: ExtensionPointConfig,\n): ExtensionPoint<T> {\n return {\n id: config.id,\n get T(): T {\n throw new Error(`tried to read ExtensionPoint.T of ${this}`);\n },\n toString() {\n return `extensionPoint{${config.id}}`;\n },\n $$type: '@backstage/ExtensionPoint',\n };\n}\n\n/**\n * The configuration options passed to {@link createBackendPlugin}.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/plugins | The architecture of plugins}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport interface BackendPluginConfig {\n /**\n * The ID of this plugin.\n *\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\n pluginId: string;\n register(reg: BackendPluginRegistrationPoints): void;\n}\n\n/**\n * Creates a new backend plugin.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/plugins | The architecture of plugins}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport function createBackendPlugin(\n config: BackendPluginConfig,\n): () => BackendFeature {\n const factory: BackendFeatureFactory = () => {\n let registrations: InternalBackendPluginRegistration[];\n\n return {\n $$type: '@backstage/BackendFeature',\n version: 'v1',\n getRegistrations() {\n if (registrations) {\n return registrations;\n }\n const extensionPoints: InternalBackendPluginRegistration['extensionPoints'] =\n [];\n let init: InternalBackendPluginRegistration['init'] | undefined =\n undefined;\n\n config.register({\n registerExtensionPoint(ext, impl) {\n if (init) {\n throw new Error(\n 'registerExtensionPoint called after registerInit',\n );\n }\n extensionPoints.push([ext, impl]);\n },\n registerInit(regInit) {\n if (init) {\n throw new Error('registerInit must only be called once');\n }\n init = {\n deps: regInit.deps,\n func: regInit.init,\n };\n },\n });\n\n if (!init) {\n throw new Error(\n `registerInit was not called by register in ${config.pluginId}`,\n );\n }\n\n registrations = [\n {\n type: 'plugin',\n pluginId: config.pluginId,\n extensionPoints,\n init,\n },\n ];\n return registrations;\n },\n };\n };\n factory.$$type = '@backstage/BackendFeatureFactory';\n\n return factory;\n}\n\n/**\n * The configuration options passed to {@link createBackendModule}.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/modules | The architecture of modules}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport interface BackendModuleConfig {\n /**\n * Should exactly match the `id` of the plugin that the module extends.\n *\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\n pluginId: string;\n\n /**\n * The ID of this module, used to identify the module and ensure that it is not installed twice.\n */\n moduleId: string;\n register(reg: BackendModuleRegistrationPoints): void;\n}\n\n/**\n * Creates a new backend module for a given plugin.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/modules | The architecture of modules}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport function createBackendModule(\n config: BackendModuleConfig,\n): () => BackendFeature {\n const factory: BackendFeatureFactory = () => {\n let registrations: InternalBackendModuleRegistration[];\n\n return {\n $$type: '@backstage/BackendFeature',\n version: 'v1',\n getRegistrations() {\n if (registrations) {\n return registrations;\n }\n const extensionPoints: InternalBackendPluginRegistration['extensionPoints'] =\n [];\n let init: InternalBackendModuleRegistration['init'] | undefined =\n undefined;\n\n config.register({\n registerExtensionPoint(ext, impl) {\n if (init) {\n throw new Error(\n 'registerExtensionPoint called after registerInit',\n );\n }\n extensionPoints.push([ext, impl]);\n },\n registerInit(regInit) {\n if (init) {\n throw new Error('registerInit must only be called once');\n }\n init = {\n deps: regInit.deps,\n func: regInit.init,\n };\n },\n });\n\n if (!init) {\n throw new Error(\n `registerInit was not called by register in ${config.moduleId} module for ${config.pluginId}`,\n );\n }\n\n registrations = [\n {\n type: 'module',\n pluginId: config.pluginId,\n moduleId: config.moduleId,\n extensionPoints,\n init,\n },\n ];\n return registrations;\n },\n };\n };\n factory.$$type = '@backstage/BackendFeatureFactory';\n\n return factory;\n}\n"],"names":["c","coreServices"],"mappings":";;;;;;;;AAyGO,SAAS,iBACd,MAC2B,EAAA;AAC3B,EAAA,MAAM,EAAE,EAAA,EAAI,KAAQ,GAAA,QAAA,EAAU,gBAAmB,GAAA,MAAA,CAAA;AACjD,EAAO,OAAA;AAAA,IACL,EAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAI,CAAc,GAAA;AAChB,MAAA,MAAM,IAAI,KAAA,CAAM,CAAiC,8BAAA,EAAA,IAAI,CAAE,CAAA,CAAA,CAAA;AAAA,KACzD;AAAA,IACA,QAAW,GAAA;AACT,MAAO,OAAA,CAAA,WAAA,EAAc,OAAO,EAAE,CAAA,CAAA,CAAA,CAAA;AAAA,KAChC;AAAA,IACA,MAAQ,EAAA,uBAAA;AAAA,IACR,gBAAkB,EAAA,cAAA;AAAA,GACpB,CAAA;AAKF,CAAA;AAyHO,SAAS,qBAOd,MASoC,EAAA;AACpC,EAAA,MAAM,cAAiB,GAAA,OAAO,MAAW,KAAA,UAAA,GAAa,SAAS,MAAM,MAAA,CAAA;AACrE,EAAM,MAAA,OAAA,GAAU,CACd,OACwD,KAAA;AACxD,IAAM,MAAA,OAAA,GAAU,eAAe,OAAO,CAAA,CAAA;AACtC,IAAI,IAAA,OAAA,CAAQ,OAAQ,CAAA,KAAA,KAAU,MAAQ,EAAA;AACpC,MAAA,MAAMA,EAAI,GAAA,OAAA,CAAA;AACV,MAAO,OAAA;AAAA,QACL,MAAQ,EAAA,2BAAA;AAAA,QACR,OAAS,EAAA,IAAA;AAAA,QACT,SAASA,EAAE,CAAA,OAAA;AAAA,QACX,gBAAgBA,EAAE,CAAA,cAAA;AAAA,QAClB,MAAMA,EAAE,CAAA,IAAA;AAAA,QAC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AAA;AACR,cAAA,MAAM,IAAI,KAAA;AAAA,gBACR,kDAAA;AAAA,eACF,CAAA;AAAA,aACF;AACA,YAAA,eAAA,CAAgB,IAAK,CAAA,CAAC,GAAK,EAAA,IAAI,CAAC,CAAA,CAAA;AAAA,WAClC;AAAA,UACA,aAAa,OAAS,EAAA;AACpB,YAAA,IAAI,IAAM,EAAA;AACR,cAAM,MAAA,IAAI,MAAM,uCAAuC,CAAA,CAAA;AAAA,aACzD;AACA,YAAO,IAAA,GAAA;AAAA,cACL,MAAM,OAAQ,CAAA,IAAA;AAAA,cACd,MAAM,OAAQ,CAAA,IAAA;AAAA,aAChB,CAAA;AAAA,WACF;AAAA,SACD,CAAA,CAAA;AAED,QAAA,IAAI,CAAC,IAAM,EAAA;AACT,UAAA,MAAM,IAAI,KAAA;AAAA,YACR,CAA8C,2CAAA,EAAA,MAAA,CAAO,QAAQ,CAAA,YAAA,EAAe,OAAO,QAAQ,CAAA,CAAA;AAAA,WAC7F,CAAA;AAAA,SACF;AAEA,QAAgB,aAAA,GAAA;AAAA,UACd;AAAA,YACE,IAAM,EAAA,QAAA;AAAA,YACN,UAAU,MAAO,CAAA,QAAA;AAAA,YACjB,UAAU,MAAO,CAAA,QAAA;AAAA,YACjB,eAAA;AAAA,YACA,IAAA;AAAA,WACF;AAAA,SACF,CAAA;AACA,QAAO,OAAA,aAAA,CAAA;AAAA,OACT;AAAA,KACF,CAAA;AAAA,GACF,CAAA;AACA,EAAA,OAAA,CAAQ,MAAS,GAAA,kCAAA,CAAA;AAEjB,EAAO,OAAA,OAAA,CAAA;AACT;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/services/system/types.ts","../src/services/definitions/coreServices.ts","../src/services/definitions/SchedulerService.ts","../src/services/utilities/database.ts","../src/wiring/factories.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BackendFeature } from '../../types';\n\n/**\n * TODO\n *\n * @public\n */\nexport type ServiceRef<\n TService,\n TScope extends 'root' | 'plugin' = 'root' | 'plugin',\n> = {\n id: string;\n\n /**\n * This determines the scope at which this service is available.\n *\n * Root scoped services are available to all other services but\n * may only depend on other root scoped services.\n *\n * Plugin scoped services are only available to other plugin scoped\n * services but may depend on all other services.\n */\n scope: TScope;\n\n /**\n * Utility for getting the type of the service, using `typeof serviceRef.T`.\n * Attempting to actually read this value will result in an exception.\n */\n T: TService;\n\n $$type: '@backstage/ServiceRef';\n};\n\n/** @public */\nexport interface ServiceFactory<\n TService = unknown,\n TScope extends 'plugin' | 'root' = 'plugin' | 'root',\n> extends BackendFeature {\n service: ServiceRef<TService, TScope>;\n}\n\n/** @internal */\nexport interface InternalServiceFactory<\n TService = unknown,\n TScope extends 'plugin' | 'root' = 'plugin' | 'root',\n> extends ServiceFactory<TService, TScope> {\n version: 'v1';\n initialization?: 'always' | 'lazy';\n deps: { [key in string]: ServiceRef<unknown> };\n createRootContext?(deps: { [key in string]: unknown }): Promise<unknown>;\n factory(\n deps: { [key in string]: unknown },\n context: unknown,\n ): Promise<TService>;\n}\n\n/**\n * Represents either a {@link ServiceFactory} or a function that returns one.\n *\n * @public\n */\nexport type ServiceFactoryOrFunction = ServiceFactory | (() => ServiceFactory);\n\n/** @public */\nexport interface ServiceRefConfig<TService, TScope extends 'root' | 'plugin'> {\n id: string;\n scope?: TScope;\n defaultFactory?: (\n service: ServiceRef<TService, TScope>,\n ) => Promise<ServiceFactoryOrFunction>;\n}\n\n/**\n * Creates a new service definition. This overload is used to create plugin scoped services.\n *\n * @public\n */\nexport function createServiceRef<TService>(\n config: ServiceRefConfig<TService, 'plugin'>,\n): ServiceRef<TService, 'plugin'>;\n\n/**\n * Creates a new service definition. This overload is used to create root scoped services.\n *\n * @public\n */\nexport function createServiceRef<TService>(\n config: ServiceRefConfig<TService, 'root'>,\n): ServiceRef<TService, 'root'>;\nexport function createServiceRef<TService>(\n config: ServiceRefConfig<TService, any>,\n): ServiceRef<TService, any> {\n const { id, scope = 'plugin', defaultFactory } = config;\n return {\n id,\n scope,\n get T(): TService {\n throw new Error(`tried to read ServiceRef.T of ${this}`);\n },\n toString() {\n return `serviceRef{${config.id}}`;\n },\n $$type: '@backstage/ServiceRef',\n __defaultFactory: defaultFactory,\n } as ServiceRef<TService, typeof scope> & {\n __defaultFactory?: (\n service: ServiceRef<TService>,\n ) => Promise<ServiceFactory<TService> | (() => ServiceFactory<TService>)>;\n };\n}\n\n/** @ignore */\ntype ServiceRefsToInstances<\n T extends { [key in string]: ServiceRef<unknown> },\n TScope extends 'root' | 'plugin' = 'root' | 'plugin',\n> = {\n [key in keyof T as T[key]['scope'] extends TScope ? key : never]: T[key]['T'];\n};\n\n/** @public */\nexport interface RootServiceFactoryConfig<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n> {\n /**\n * The initialization strategy for the service factory. This service is root scoped and will use `always` by default.\n *\n * @remarks\n *\n * - `always` - The service will always be initialized regardless if it is used or not.\n * - `lazy` - The service will only be initialized if it is depended on by a different service or feature.\n *\n * Service factories for root scoped services use `always` as the default, while plugin scoped services use `lazy`.\n */\n initialization?: 'always' | 'lazy';\n service: ServiceRef<TService, 'root'>;\n deps: TDeps;\n factory(deps: ServiceRefsToInstances<TDeps, 'root'>): TImpl | Promise<TImpl>;\n}\n\n/** @public */\nexport interface PluginServiceFactoryConfig<\n TService,\n TContext,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n> {\n /**\n * The initialization strategy for the service factory. This service is plugin scoped and will use `lazy` by default.\n *\n * @remarks\n *\n * - `always` - The service will always be initialized regardless if it is used or not.\n * - `lazy` - The service will only be initialized if it is depended on by a different service or feature.\n *\n * Service factories for root scoped services use `always` as the default, while plugin scoped services use `lazy`.\n */\n initialization?: 'always' | 'lazy';\n service: ServiceRef<TService, 'plugin'>;\n deps: TDeps;\n createRootContext?(\n deps: ServiceRefsToInstances<TDeps, 'root'>,\n ): TContext | Promise<TContext>;\n factory(\n deps: ServiceRefsToInstances<TDeps>,\n context: TContext,\n ): TImpl | Promise<TImpl>;\n}\n\n/**\n * Creates a root scoped service factory without options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown, 'root'> },\n TOpts extends object | undefined = undefined,\n>(\n config: RootServiceFactoryConfig<TService, TImpl, TDeps>,\n): () => ServiceFactory<TService, 'root'>;\n/**\n * Creates a root scoped service factory with optional options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown, 'root'> },\n TOpts extends object | undefined = undefined,\n>(\n config: (options?: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>,\n): (options?: TOpts) => ServiceFactory<TService, 'root'>;\n/**\n * Creates a plugin scoped service factory without options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext = undefined,\n TOpts extends object | undefined = undefined,\n>(\n config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>,\n): () => ServiceFactory<TService, 'plugin'>;\n/**\n * Creates a plugin scoped service factory with optional options.\n *\n * @public\n * @param config - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext = undefined,\n TOpts extends object | undefined = undefined,\n>(\n config: (\n options?: TOpts,\n ) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>,\n): (options?: TOpts) => ServiceFactory<TService, 'plugin'>;\nexport function createServiceFactory<\n TService,\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext,\n TOpts extends object | undefined = undefined,\n>(\n config:\n | RootServiceFactoryConfig<TService, TImpl, TDeps>\n | PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>\n | ((options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>)\n | ((\n options: TOpts,\n ) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>)\n | (() => RootServiceFactoryConfig<TService, TImpl, TDeps>)\n | (() => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>),\n): (options: TOpts) => ServiceFactory {\n const configCallback = typeof config === 'function' ? config : () => config;\n const factory = (\n options: TOpts,\n ): InternalServiceFactory<TService, 'plugin' | 'root'> => {\n const anyConf = configCallback(options);\n if (anyConf.service.scope === 'root') {\n const c = anyConf as RootServiceFactoryConfig<TService, TImpl, TDeps>;\n return {\n $$type: '@backstage/BackendFeature',\n version: 'v1',\n service: c.service,\n initialization: c.initialization,\n deps: c.deps,\n factory: async (deps: TDeps) => c.factory(deps),\n };\n }\n const c = anyConf as PluginServiceFactoryConfig<\n TService,\n TContext,\n TImpl,\n TDeps\n >;\n return {\n $$type: '@backstage/BackendFeature',\n version: 'v1',\n service: c.service,\n initialization: c.initialization,\n ...('createRootContext' in c\n ? {\n createRootContext: async (deps: TDeps) =>\n c?.createRootContext?.(deps),\n }\n : {}),\n deps: c.deps,\n factory: async (deps: TDeps, ctx: TContext) => c.factory(deps, ctx),\n };\n };\n\n factory.$$type = '@backstage/BackendFeatureFactory';\n\n return factory;\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '../system';\n\n/**\n * All core services references\n *\n * @public\n */\nexport namespace coreServices {\n /**\n * The service reference for the plugin scoped {@link AuthService}.\n *\n * @public\n */\n export const auth = createServiceRef<import('./AuthService').AuthService>({\n id: 'core.auth',\n });\n\n /**\n * The service reference for the plugin scoped {@link UserInfoService}.\n *\n * @public\n */\n export const userInfo = createServiceRef<\n import('./UserInfoService').UserInfoService\n >({\n id: 'core.userInfo',\n });\n\n /**\n * The service reference for the plugin scoped {@link CacheService}.\n *\n * @public\n */\n export const cache = createServiceRef<import('./CacheService').CacheService>({\n id: 'core.cache',\n });\n\n /**\n * The service reference for the root scoped {@link RootConfigService}.\n *\n * @public\n */\n export const rootConfig = createServiceRef<\n import('./RootConfigService').RootConfigService\n >({ id: 'core.rootConfig', scope: 'root' });\n\n /**\n * The service reference for the plugin scoped {@link DatabaseService}.\n *\n * @public\n */\n export const database = createServiceRef<\n import('./DatabaseService').DatabaseService\n >({ id: 'core.database' });\n\n /**\n * The service reference for the plugin scoped {@link DiscoveryService}.\n *\n * @public\n */\n export const discovery = createServiceRef<\n import('./DiscoveryService').DiscoveryService\n >({ id: 'core.discovery' });\n\n /**\n * The service reference for the plugin scoped {@link HttpAuthService}.\n *\n * @public\n */\n export const httpAuth = createServiceRef<\n import('./HttpAuthService').HttpAuthService\n >({ id: 'core.httpAuth' });\n\n /**\n * The service reference for the plugin scoped {@link HttpRouterService}.\n *\n * @public\n */\n export const httpRouter = createServiceRef<\n import('./HttpRouterService').HttpRouterService\n >({ id: 'core.httpRouter' });\n\n /**\n * The service reference for the plugin scoped {@link LifecycleService}.\n *\n * @public\n */\n export const lifecycle = createServiceRef<\n import('./LifecycleService').LifecycleService\n >({ id: 'core.lifecycle' });\n\n /**\n * The service reference for the plugin scoped {@link LoggerService}.\n *\n * @public\n */\n export const logger = createServiceRef<\n import('./LoggerService').LoggerService\n >({ id: 'core.logger' });\n\n /**\n * The service reference for the plugin scoped {@link PermissionsService}.\n *\n * @public\n */\n export const permissions = createServiceRef<\n import('./PermissionsService').PermissionsService\n >({ id: 'core.permissions' });\n\n /**\n * The service reference for the plugin scoped {@link PluginMetadataService}.\n *\n * @public\n */\n export const pluginMetadata = createServiceRef<\n import('./PluginMetadataService').PluginMetadataService\n >({ id: 'core.pluginMetadata' });\n\n /**\n * The service reference for the root scoped {@link RootHttpRouterService}.\n *\n * @public\n */\n export const rootHttpRouter = createServiceRef<\n import('./RootHttpRouterService').RootHttpRouterService\n >({ id: 'core.rootHttpRouter', scope: 'root' });\n\n /**\n * The service reference for the root scoped {@link RootLifecycleService}.\n *\n * @public\n */\n export const rootLifecycle = createServiceRef<\n import('./RootLifecycleService').RootLifecycleService\n >({ id: 'core.rootLifecycle', scope: 'root' });\n\n /**\n * The service reference for the root scoped {@link RootLoggerService}.\n *\n * @public\n */\n export const rootLogger = createServiceRef<\n import('./RootLoggerService').RootLoggerService\n >({ id: 'core.rootLogger', scope: 'root' });\n\n /**\n * The service reference for the plugin scoped {@link SchedulerService}.\n *\n * @public\n */\n export const scheduler = createServiceRef<\n import('./SchedulerService').SchedulerService\n >({ id: 'core.scheduler' });\n\n /**\n * The service reference for the plugin scoped {@link TokenManagerService}.\n *\n * @public\n * @deprecated Please migrate to the new `coreServices.auth`, `coreServices.httpAuth`, and `coreServices.userInfo` services as needed instead\n */\n export const tokenManager = createServiceRef<\n import('./TokenManagerService').TokenManagerService\n >({ id: 'core.tokenManager' });\n\n /**\n * The service reference for the plugin scoped {@link UrlReaderService}.\n *\n * @public\n */\n export const urlReader = createServiceRef<\n import('./UrlReaderService').UrlReaderService\n >({ id: 'core.urlReader' });\n\n /**\n * The service reference for the plugin scoped {@link IdentityService}.\n *\n * @public\n * @deprecated Please migrate to the new `coreServices.auth`, `coreServices.httpAuth`, and `coreServices.userInfo` services as needed instead\n */\n export const identity = createServiceRef<\n import('./IdentityService').IdentityService\n >({ id: 'core.identity' });\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config, readDurationFromConfig } from '@backstage/config';\nimport { HumanDuration, JsonObject } from '@backstage/types';\nimport { Duration } from 'luxon';\n\n/**\n * A function that can be called as a scheduled task.\n *\n * It may optionally accept an abort signal argument. When the signal triggers,\n * processing should abort and return as quickly as possible.\n *\n * @public\n */\nexport type SchedulerServiceTaskFunction =\n | ((abortSignal: AbortSignal) => void | Promise<void>)\n | (() => void | Promise<void>);\n\n/**\n * A semi-opaque type to describe an actively scheduled task.\n *\n * @public\n */\nexport type SchedulerServiceTaskDescriptor = {\n /**\n * The unique identifier of the task.\n */\n id: string;\n /**\n * The scope of the task.\n */\n scope: 'global' | 'local';\n /**\n * The settings that control the task flow. This is a semi-opaque structure\n * that is mainly there for debugging purposes. Do not make any assumptions\n * about the contents of this field.\n */\n settings: { version: number } & JsonObject;\n};\n\n/**\n * Options that control the scheduling of a task.\n *\n * @public\n */\nexport interface SchedulerServiceTaskScheduleDefinition {\n /**\n * How often you want the task to run. The system does its best to avoid\n * overlapping invocations.\n *\n * @remarks\n *\n * This is the best effort value; under some circumstances there can be\n * deviations. For example, if the task runtime is longer than the frequency\n * and the timeout has not been given or not been exceeded yet, the next\n * invocation of this task will be delayed until after the previous one\n * finishes.\n *\n * This is a required field.\n */\n frequency:\n | {\n /**\n * A crontab style string.\n *\n * @remarks\n *\n * Overview:\n *\n * ```\n * ┌────────────── second (optional)\n * │ ┌──────────── minute\n * │ │ ┌────────── hour\n * │ │ │ ┌──────── day of month\n * │ │ │ │ ┌────── month\n * │ │ │ │ │ ┌──── day of week\n * │ │ │ │ │ │\n * │ │ │ │ │ │\n * * * * * * *\n * ```\n */\n cron: string;\n }\n | Duration\n | HumanDuration;\n\n /**\n * The maximum amount of time that a single task invocation can take, before\n * it's considered timed out and gets \"released\" such that a new invocation\n * is permitted to take place (possibly, then, on a different worker).\n */\n timeout: Duration | HumanDuration;\n\n /**\n * The amount of time that should pass before the first invocation happens.\n *\n * @remarks\n *\n * This can be useful in cold start scenarios to stagger or delay some heavy\n * compute jobs. If no value is given for this field then the first invocation\n * will happen as soon as possible according to the cadence.\n *\n * NOTE: This is a per-worker delay. If you have a cluster of workers all\n * collaborating on a task that has its `scope` field set to `'global'`, then\n * you may still see the task being processed by other long-lived workers,\n * while any given single worker is in its initial sleep delay time e.g. after\n * a deployment. Therefore, this parameter is not useful for \"globally\" pausing\n * work; its main intended use is for individual machines to get a chance to\n * reach some equilibrium at startup before triggering heavy batch workloads.\n */\n initialDelay?: Duration | HumanDuration;\n\n /**\n * Sets the scope of concurrency control / locking to apply for invocations of\n * this task.\n *\n * @remarks\n *\n * When the scope is set to the default value `'global'`, the scheduler will\n * attempt to ensure that only one worker machine runs the task at a time,\n * according to the given cadence. This means that as the number of worker\n * hosts increases, the invocation frequency of this task will not go up.\n * Instead, the load is spread randomly across hosts. This setting is useful\n * for tasks that access shared resources, for example catalog ingestion tasks\n * where you do not want many machines to repeatedly import the same data and\n * trample over each other.\n *\n * When the scope is set to `'local'`, there is no concurrency control across\n * hosts. Each host runs the task according to the given cadence similarly to\n * `setInterval`, but the runtime ensures that there are no overlapping runs.\n *\n * @defaultValue 'global'\n */\n scope?: 'global' | 'local';\n}\n\n/**\n * Config options for {@link SchedulerServiceTaskScheduleDefinition}\n * that control the scheduling of a task.\n *\n * @public\n */\nexport interface SchedulerServiceTaskScheduleDefinitionConfig {\n /**\n * How often you want the task to run. The system does its best to avoid\n * overlapping invocations.\n *\n * @remarks\n *\n * This is the best effort value; under some circumstances there can be\n * deviations. For example, if the task runtime is longer than the frequency\n * and the timeout has not been given or not been exceeded yet, the next\n * invocation of this task will be delayed until after the previous one\n * finishes.\n *\n * This is a required field.\n */\n frequency:\n | {\n /**\n * A crontab style string.\n *\n * @remarks\n *\n * Overview:\n *\n * ```\n * ┌────────────── second (optional)\n * │ ┌──────────── minute\n * │ │ ┌────────── hour\n * │ │ │ ┌──────── day of month\n * │ │ │ │ ┌────── month\n * │ │ │ │ │ ┌──── day of week\n * │ │ │ │ │ │\n * │ │ │ │ │ │\n * * * * * * *\n * ```\n */\n cron: string;\n }\n | string\n | HumanDuration;\n\n /**\n * The maximum amount of time that a single task invocation can take, before\n * it's considered timed out and gets \"released\" such that a new invocation\n * is permitted to take place (possibly, then, on a different worker).\n */\n timeout: string | HumanDuration;\n\n /**\n * The amount of time that should pass before the first invocation happens.\n *\n * @remarks\n *\n * This can be useful in cold start scenarios to stagger or delay some heavy\n * compute jobs. If no value is given for this field then the first invocation\n * will happen as soon as possible according to the cadence.\n *\n * NOTE: This is a per-worker delay. If you have a cluster of workers all\n * collaborating on a task that has its `scope` field set to `'global'`, then\n * you may still see the task being processed by other long-lived workers,\n * while any given single worker is in its initial sleep delay time e.g. after\n * a deployment. Therefore, this parameter is not useful for \"globally\" pausing\n * work; its main intended use is for individual machines to get a chance to\n * reach some equilibrium at startup before triggering heavy batch workloads.\n */\n initialDelay?: string | HumanDuration;\n\n /**\n * Sets the scope of concurrency control / locking to apply for invocations of\n * this task.\n *\n * @remarks\n *\n * When the scope is set to the default value `'global'`, the scheduler will\n * attempt to ensure that only one worker machine runs the task at a time,\n * according to the given cadence. This means that as the number of worker\n * hosts increases, the invocation frequency of this task will not go up.\n * Instead, the load is spread randomly across hosts. This setting is useful\n * for tasks that access shared resources, for example catalog ingestion tasks\n * where you do not want many machines to repeatedly import the same data and\n * trample over each other.\n *\n * When the scope is set to `'local'`, there is no concurrency control across\n * hosts. Each host runs the task according to the given cadence similarly to\n * `setInterval`, but the runtime ensures that there are no overlapping runs.\n *\n * @defaultValue 'global'\n */\n scope?: 'global' | 'local';\n}\n\n/**\n * Options that apply to the invocation of a given task.\n *\n * @public\n */\nexport interface SchedulerServiceTaskInvocationDefinition {\n /**\n * A unique ID (within the scope of the plugin) for the task.\n */\n id: string;\n\n /**\n * The actual task function to be invoked regularly.\n */\n fn: SchedulerServiceTaskFunction;\n\n /**\n * An abort signal that, when triggered, will stop the recurring execution of\n * the task.\n */\n signal?: AbortSignal;\n}\n\n/**\n * A previously prepared task schedule, ready to be invoked.\n *\n * @public\n */\nexport interface SchedulerServiceTaskRunner {\n /**\n * Takes the schedule and executes an actual task using it.\n *\n * @param task - The actual runtime properties of the task\n */\n run(task: SchedulerServiceTaskInvocationDefinition): Promise<void>;\n}\n\n/**\n * Deals with the scheduling of distributed tasks, for a given plugin.\n *\n * @public\n */\nexport interface SchedulerService {\n /**\n * Manually triggers a task by ID.\n *\n * If the task doesn't exist, a NotFoundError is thrown. If the task is\n * currently running, a ConflictError is thrown.\n *\n * @param id - The task ID\n */\n triggerTask(id: string): Promise<void>;\n\n /**\n * Schedules a task function for recurring runs.\n *\n * @remarks\n *\n * The `scope` task field controls whether to use coordinated exclusive\n * invocation across workers, or to just coordinate within the current worker.\n *\n * This convenience method performs both the scheduling and invocation in one\n * go.\n *\n * @param task - The task definition\n */\n scheduleTask(\n task: SchedulerServiceTaskScheduleDefinition &\n SchedulerServiceTaskInvocationDefinition,\n ): Promise<void>;\n\n /**\n * Creates a scheduled but dormant recurring task, ready to be launched at a\n * later time.\n *\n * @remarks\n *\n * This method is useful for pre-creating a schedule in outer code to be\n * passed into an inner implementation, such that the outer code controls\n * scheduling while inner code controls implementation.\n *\n * @param schedule - The task schedule\n */\n createScheduledTaskRunner(\n schedule: SchedulerServiceTaskScheduleDefinition,\n ): SchedulerServiceTaskRunner;\n\n /**\n * Returns all scheduled tasks registered to this scheduler.\n *\n * @remarks\n *\n * This method is useful for triggering tasks manually using the triggerTask\n * functionality. Note that the returned tasks contain only tasks that have\n * been initialized in this instance of the scheduler.\n *\n * @returns Scheduled tasks\n */\n getScheduledTasks(): Promise<SchedulerServiceTaskDescriptor[]>;\n}\n\nfunction readDuration(config: Config, key: string): Duration | HumanDuration {\n if (typeof config.get(key) === 'string') {\n const value = config.getString(key);\n const duration = Duration.fromISO(value);\n if (!duration.isValid) {\n throw new Error(`Invalid duration: ${value}`);\n }\n return duration;\n }\n\n return readDurationFromConfig(config, { key });\n}\n\nfunction readCronOrDuration(\n config: Config,\n key: string,\n): { cron: string } | Duration | HumanDuration {\n const value = config.get(key);\n if (typeof value === 'object' && (value as { cron?: string }).cron) {\n return value as { cron: string };\n }\n\n return readDuration(config, key);\n}\n\n/**\n * Reads a {@link SchedulerServiceTaskScheduleDefinition} from config. Expects\n * the config not to be the root config, but the config for the definition.\n *\n * @param config - config for a TaskScheduleDefinition.\n * @public\n */\nexport function readSchedulerServiceTaskScheduleDefinitionFromConfig(\n config: Config,\n): SchedulerServiceTaskScheduleDefinition {\n const frequency = readCronOrDuration(config, 'frequency');\n const timeout = readDuration(config, 'timeout');\n\n const initialDelay = config.has('initialDelay')\n ? readDuration(config, 'initialDelay')\n : undefined;\n\n const scope = config.getOptionalString('scope');\n if (scope && !['global', 'local'].includes(scope)) {\n throw new Error(\n `Only \"global\" or \"local\" are allowed for TaskScheduleDefinition.scope, but got: ${scope}`,\n );\n }\n\n return {\n frequency,\n timeout,\n initialDelay,\n scope: scope as 'global' | 'local' | undefined,\n };\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Tries to deduce whether a thrown error is a database conflict.\n *\n * @public\n * @param e - A thrown error\n * @returns True if the error looks like it was a conflict error thrown by a\n * known database engine\n */\nexport function isDatabaseConflictError(e: unknown) {\n const message = (e as any)?.message;\n\n return (\n typeof message === 'string' &&\n (/SQLITE_CONSTRAINT(?:_UNIQUE)?: UNIQUE/.test(message) ||\n /UNIQUE constraint failed:/.test(message) ||\n /unique constraint/.test(message) ||\n /Duplicate entry/.test(message)) // MySQL uniqueness error msg\n );\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BackendFeature, BackendFeatureFactory } from '../types';\nimport {\n BackendModuleRegistrationPoints,\n BackendPluginRegistrationPoints,\n ExtensionPoint,\n InternalBackendModuleRegistration,\n InternalBackendPluginRegistration,\n} from './types';\n\n/**\n * The configuration options passed to {@link createExtensionPoint}.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/extension-points | The architecture of extension points}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport interface CreateExtensionPointOptions {\n /**\n * The ID of this extension point.\n *\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\n id: string;\n}\n\n/**\n * Creates a new backend extension point.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/extension-points | The architecture of extension points}\n */\nexport function createExtensionPoint<T>(\n options: CreateExtensionPointOptions,\n): ExtensionPoint<T> {\n return {\n id: options.id,\n get T(): T {\n throw new Error(`tried to read ExtensionPoint.T of ${this}`);\n },\n toString() {\n return `extensionPoint{${options.id}}`;\n },\n $$type: '@backstage/ExtensionPoint',\n };\n}\n\n/**\n * The configuration options passed to {@link createBackendPlugin}.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/plugins | The architecture of plugins}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport interface CreateBackendPluginOptions {\n /**\n * The ID of this plugin.\n *\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\n pluginId: string;\n register(reg: BackendPluginRegistrationPoints): void;\n}\n\n/**\n * Creates a new backend plugin.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/plugins | The architecture of plugins}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport function createBackendPlugin(\n options: CreateBackendPluginOptions,\n): () => BackendFeature {\n const factory: BackendFeatureFactory = () => {\n let registrations: InternalBackendPluginRegistration[];\n\n return {\n $$type: '@backstage/BackendFeature',\n version: 'v1',\n getRegistrations() {\n if (registrations) {\n return registrations;\n }\n const extensionPoints: InternalBackendPluginRegistration['extensionPoints'] =\n [];\n let init: InternalBackendPluginRegistration['init'] | undefined =\n undefined;\n\n options.register({\n registerExtensionPoint(ext, impl) {\n if (init) {\n throw new Error(\n 'registerExtensionPoint called after registerInit',\n );\n }\n extensionPoints.push([ext, impl]);\n },\n registerInit(regInit) {\n if (init) {\n throw new Error('registerInit must only be called once');\n }\n init = {\n deps: regInit.deps,\n func: regInit.init,\n };\n },\n });\n\n if (!init) {\n throw new Error(\n `registerInit was not called by register in ${options.pluginId}`,\n );\n }\n\n registrations = [\n {\n type: 'plugin',\n pluginId: options.pluginId,\n extensionPoints,\n init,\n },\n ];\n return registrations;\n },\n };\n };\n factory.$$type = '@backstage/BackendFeatureFactory';\n\n return factory;\n}\n\n/**\n * The configuration options passed to {@link createBackendModule}.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/modules | The architecture of modules}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport interface CreateBackendModuleOptions {\n /**\n * Should exactly match the `id` of the plugin that the module extends.\n *\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\n pluginId: string;\n\n /**\n * The ID of this module, used to identify the module and ensure that it is not installed twice.\n */\n moduleId: string;\n register(reg: BackendModuleRegistrationPoints): void;\n}\n\n/**\n * Creates a new backend module for a given plugin.\n *\n * @public\n * @see {@link https://backstage.io/docs/backend-system/architecture/modules | The architecture of modules}\n * @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}\n */\nexport function createBackendModule(\n options: CreateBackendModuleOptions,\n): () => BackendFeature {\n const factory: BackendFeatureFactory = () => {\n let registrations: InternalBackendModuleRegistration[];\n\n return {\n $$type: '@backstage/BackendFeature',\n version: 'v1',\n getRegistrations() {\n if (registrations) {\n return registrations;\n }\n const extensionPoints: InternalBackendPluginRegistration['extensionPoints'] =\n [];\n let init: InternalBackendModuleRegistration['init'] | undefined =\n undefined;\n\n options.register({\n registerExtensionPoint(ext, impl) {\n if (init) {\n throw new Error(\n 'registerExtensionPoint called after registerInit',\n );\n }\n extensionPoints.push([ext, impl]);\n },\n registerInit(regInit) {\n if (init) {\n throw new Error('registerInit must only be called once');\n }\n init = {\n deps: regInit.deps,\n func: regInit.init,\n };\n },\n });\n\n if (!init) {\n throw new Error(\n `registerInit was not called by register in ${options.moduleId} module for ${options.pluginId}`,\n );\n }\n\n registrations = [\n {\n type: 'module',\n pluginId: options.pluginId,\n moduleId: options.moduleId,\n extensionPoints,\n init,\n },\n ];\n return registrations;\n },\n };\n };\n factory.$$type = '@backstage/BackendFeatureFactory';\n\n return factory;\n}\n"],"names":["c","coreServices","config","Duration","readDurationFromConfig"],"mappings":";;;;;;;;;;AAyGO,SAAS,iBACd,MAC2B,EAAA;AAC3B,EAAA,MAAM,EAAE,EAAA,EAAI,KAAQ,GAAA,QAAA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Api } from '@backstage/plugin-auth-node';
|
|
3
3
|
import { Readable } from 'stream';
|
|
4
|
-
import {
|
|
5
|
-
import { JsonObject, JsonValue } from '@backstage/types';
|
|
4
|
+
import { Config } from '@backstage/config';
|
|
5
|
+
import { JsonObject, HumanDuration, JsonValue } from '@backstage/types';
|
|
6
|
+
import { Duration } from 'luxon';
|
|
6
7
|
import { Handler, Request, Response } from 'express';
|
|
7
|
-
import { PermissionEvaluator, AuthorizePermissionRequest, AuthorizePermissionResponse, QueryPermissionRequest, QueryPermissionResponse } from '@backstage/plugin-permission-common';
|
|
8
|
+
import { PermissionAttributes, PermissionEvaluator, AuthorizePermissionRequest, AuthorizePermissionResponse, QueryPermissionRequest, QueryPermissionResponse } from '@backstage/plugin-permission-common';
|
|
8
9
|
import { Knex } from 'knex';
|
|
9
|
-
import { Config } from '@backstage/config';
|
|
10
10
|
export { isChildPath } from '@backstage/cli-common';
|
|
11
11
|
|
|
12
12
|
/** @public */
|
|
@@ -352,9 +352,313 @@ interface TokenManagerService {
|
|
|
352
352
|
authenticate(token: string): Promise<void>;
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
-
/**
|
|
356
|
-
|
|
355
|
+
/**
|
|
356
|
+
* A function that can be called as a scheduled task.
|
|
357
|
+
*
|
|
358
|
+
* It may optionally accept an abort signal argument. When the signal triggers,
|
|
359
|
+
* processing should abort and return as quickly as possible.
|
|
360
|
+
*
|
|
361
|
+
* @public
|
|
362
|
+
*/
|
|
363
|
+
type SchedulerServiceTaskFunction = ((abortSignal: AbortSignal) => void | Promise<void>) | (() => void | Promise<void>);
|
|
364
|
+
/**
|
|
365
|
+
* A semi-opaque type to describe an actively scheduled task.
|
|
366
|
+
*
|
|
367
|
+
* @public
|
|
368
|
+
*/
|
|
369
|
+
type SchedulerServiceTaskDescriptor = {
|
|
370
|
+
/**
|
|
371
|
+
* The unique identifier of the task.
|
|
372
|
+
*/
|
|
373
|
+
id: string;
|
|
374
|
+
/**
|
|
375
|
+
* The scope of the task.
|
|
376
|
+
*/
|
|
377
|
+
scope: 'global' | 'local';
|
|
378
|
+
/**
|
|
379
|
+
* The settings that control the task flow. This is a semi-opaque structure
|
|
380
|
+
* that is mainly there for debugging purposes. Do not make any assumptions
|
|
381
|
+
* about the contents of this field.
|
|
382
|
+
*/
|
|
383
|
+
settings: {
|
|
384
|
+
version: number;
|
|
385
|
+
} & JsonObject;
|
|
386
|
+
};
|
|
387
|
+
/**
|
|
388
|
+
* Options that control the scheduling of a task.
|
|
389
|
+
*
|
|
390
|
+
* @public
|
|
391
|
+
*/
|
|
392
|
+
interface SchedulerServiceTaskScheduleDefinition {
|
|
393
|
+
/**
|
|
394
|
+
* How often you want the task to run. The system does its best to avoid
|
|
395
|
+
* overlapping invocations.
|
|
396
|
+
*
|
|
397
|
+
* @remarks
|
|
398
|
+
*
|
|
399
|
+
* This is the best effort value; under some circumstances there can be
|
|
400
|
+
* deviations. For example, if the task runtime is longer than the frequency
|
|
401
|
+
* and the timeout has not been given or not been exceeded yet, the next
|
|
402
|
+
* invocation of this task will be delayed until after the previous one
|
|
403
|
+
* finishes.
|
|
404
|
+
*
|
|
405
|
+
* This is a required field.
|
|
406
|
+
*/
|
|
407
|
+
frequency: {
|
|
408
|
+
/**
|
|
409
|
+
* A crontab style string.
|
|
410
|
+
*
|
|
411
|
+
* @remarks
|
|
412
|
+
*
|
|
413
|
+
* Overview:
|
|
414
|
+
*
|
|
415
|
+
* ```
|
|
416
|
+
* ┌────────────── second (optional)
|
|
417
|
+
* │ ┌──────────── minute
|
|
418
|
+
* │ │ ┌────────── hour
|
|
419
|
+
* │ │ │ ┌──────── day of month
|
|
420
|
+
* │ │ │ │ ┌────── month
|
|
421
|
+
* │ │ │ │ │ ┌──── day of week
|
|
422
|
+
* │ │ │ │ │ │
|
|
423
|
+
* │ │ │ │ │ │
|
|
424
|
+
* * * * * * *
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
cron: string;
|
|
428
|
+
} | Duration | HumanDuration;
|
|
429
|
+
/**
|
|
430
|
+
* The maximum amount of time that a single task invocation can take, before
|
|
431
|
+
* it's considered timed out and gets "released" such that a new invocation
|
|
432
|
+
* is permitted to take place (possibly, then, on a different worker).
|
|
433
|
+
*/
|
|
434
|
+
timeout: Duration | HumanDuration;
|
|
435
|
+
/**
|
|
436
|
+
* The amount of time that should pass before the first invocation happens.
|
|
437
|
+
*
|
|
438
|
+
* @remarks
|
|
439
|
+
*
|
|
440
|
+
* This can be useful in cold start scenarios to stagger or delay some heavy
|
|
441
|
+
* compute jobs. If no value is given for this field then the first invocation
|
|
442
|
+
* will happen as soon as possible according to the cadence.
|
|
443
|
+
*
|
|
444
|
+
* NOTE: This is a per-worker delay. If you have a cluster of workers all
|
|
445
|
+
* collaborating on a task that has its `scope` field set to `'global'`, then
|
|
446
|
+
* you may still see the task being processed by other long-lived workers,
|
|
447
|
+
* while any given single worker is in its initial sleep delay time e.g. after
|
|
448
|
+
* a deployment. Therefore, this parameter is not useful for "globally" pausing
|
|
449
|
+
* work; its main intended use is for individual machines to get a chance to
|
|
450
|
+
* reach some equilibrium at startup before triggering heavy batch workloads.
|
|
451
|
+
*/
|
|
452
|
+
initialDelay?: Duration | HumanDuration;
|
|
453
|
+
/**
|
|
454
|
+
* Sets the scope of concurrency control / locking to apply for invocations of
|
|
455
|
+
* this task.
|
|
456
|
+
*
|
|
457
|
+
* @remarks
|
|
458
|
+
*
|
|
459
|
+
* When the scope is set to the default value `'global'`, the scheduler will
|
|
460
|
+
* attempt to ensure that only one worker machine runs the task at a time,
|
|
461
|
+
* according to the given cadence. This means that as the number of worker
|
|
462
|
+
* hosts increases, the invocation frequency of this task will not go up.
|
|
463
|
+
* Instead, the load is spread randomly across hosts. This setting is useful
|
|
464
|
+
* for tasks that access shared resources, for example catalog ingestion tasks
|
|
465
|
+
* where you do not want many machines to repeatedly import the same data and
|
|
466
|
+
* trample over each other.
|
|
467
|
+
*
|
|
468
|
+
* When the scope is set to `'local'`, there is no concurrency control across
|
|
469
|
+
* hosts. Each host runs the task according to the given cadence similarly to
|
|
470
|
+
* `setInterval`, but the runtime ensures that there are no overlapping runs.
|
|
471
|
+
*
|
|
472
|
+
* @defaultValue 'global'
|
|
473
|
+
*/
|
|
474
|
+
scope?: 'global' | 'local';
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Config options for {@link SchedulerServiceTaskScheduleDefinition}
|
|
478
|
+
* that control the scheduling of a task.
|
|
479
|
+
*
|
|
480
|
+
* @public
|
|
481
|
+
*/
|
|
482
|
+
interface SchedulerServiceTaskScheduleDefinitionConfig {
|
|
483
|
+
/**
|
|
484
|
+
* How often you want the task to run. The system does its best to avoid
|
|
485
|
+
* overlapping invocations.
|
|
486
|
+
*
|
|
487
|
+
* @remarks
|
|
488
|
+
*
|
|
489
|
+
* This is the best effort value; under some circumstances there can be
|
|
490
|
+
* deviations. For example, if the task runtime is longer than the frequency
|
|
491
|
+
* and the timeout has not been given or not been exceeded yet, the next
|
|
492
|
+
* invocation of this task will be delayed until after the previous one
|
|
493
|
+
* finishes.
|
|
494
|
+
*
|
|
495
|
+
* This is a required field.
|
|
496
|
+
*/
|
|
497
|
+
frequency: {
|
|
498
|
+
/**
|
|
499
|
+
* A crontab style string.
|
|
500
|
+
*
|
|
501
|
+
* @remarks
|
|
502
|
+
*
|
|
503
|
+
* Overview:
|
|
504
|
+
*
|
|
505
|
+
* ```
|
|
506
|
+
* ┌────────────── second (optional)
|
|
507
|
+
* │ ┌──────────── minute
|
|
508
|
+
* │ │ ┌────────── hour
|
|
509
|
+
* │ │ │ ┌──────── day of month
|
|
510
|
+
* │ │ │ │ ┌────── month
|
|
511
|
+
* │ │ │ │ │ ┌──── day of week
|
|
512
|
+
* │ │ │ │ │ │
|
|
513
|
+
* │ │ │ │ │ │
|
|
514
|
+
* * * * * * *
|
|
515
|
+
* ```
|
|
516
|
+
*/
|
|
517
|
+
cron: string;
|
|
518
|
+
} | string | HumanDuration;
|
|
519
|
+
/**
|
|
520
|
+
* The maximum amount of time that a single task invocation can take, before
|
|
521
|
+
* it's considered timed out and gets "released" such that a new invocation
|
|
522
|
+
* is permitted to take place (possibly, then, on a different worker).
|
|
523
|
+
*/
|
|
524
|
+
timeout: string | HumanDuration;
|
|
525
|
+
/**
|
|
526
|
+
* The amount of time that should pass before the first invocation happens.
|
|
527
|
+
*
|
|
528
|
+
* @remarks
|
|
529
|
+
*
|
|
530
|
+
* This can be useful in cold start scenarios to stagger or delay some heavy
|
|
531
|
+
* compute jobs. If no value is given for this field then the first invocation
|
|
532
|
+
* will happen as soon as possible according to the cadence.
|
|
533
|
+
*
|
|
534
|
+
* NOTE: This is a per-worker delay. If you have a cluster of workers all
|
|
535
|
+
* collaborating on a task that has its `scope` field set to `'global'`, then
|
|
536
|
+
* you may still see the task being processed by other long-lived workers,
|
|
537
|
+
* while any given single worker is in its initial sleep delay time e.g. after
|
|
538
|
+
* a deployment. Therefore, this parameter is not useful for "globally" pausing
|
|
539
|
+
* work; its main intended use is for individual machines to get a chance to
|
|
540
|
+
* reach some equilibrium at startup before triggering heavy batch workloads.
|
|
541
|
+
*/
|
|
542
|
+
initialDelay?: string | HumanDuration;
|
|
543
|
+
/**
|
|
544
|
+
* Sets the scope of concurrency control / locking to apply for invocations of
|
|
545
|
+
* this task.
|
|
546
|
+
*
|
|
547
|
+
* @remarks
|
|
548
|
+
*
|
|
549
|
+
* When the scope is set to the default value `'global'`, the scheduler will
|
|
550
|
+
* attempt to ensure that only one worker machine runs the task at a time,
|
|
551
|
+
* according to the given cadence. This means that as the number of worker
|
|
552
|
+
* hosts increases, the invocation frequency of this task will not go up.
|
|
553
|
+
* Instead, the load is spread randomly across hosts. This setting is useful
|
|
554
|
+
* for tasks that access shared resources, for example catalog ingestion tasks
|
|
555
|
+
* where you do not want many machines to repeatedly import the same data and
|
|
556
|
+
* trample over each other.
|
|
557
|
+
*
|
|
558
|
+
* When the scope is set to `'local'`, there is no concurrency control across
|
|
559
|
+
* hosts. Each host runs the task according to the given cadence similarly to
|
|
560
|
+
* `setInterval`, but the runtime ensures that there are no overlapping runs.
|
|
561
|
+
*
|
|
562
|
+
* @defaultValue 'global'
|
|
563
|
+
*/
|
|
564
|
+
scope?: 'global' | 'local';
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Options that apply to the invocation of a given task.
|
|
568
|
+
*
|
|
569
|
+
* @public
|
|
570
|
+
*/
|
|
571
|
+
interface SchedulerServiceTaskInvocationDefinition {
|
|
572
|
+
/**
|
|
573
|
+
* A unique ID (within the scope of the plugin) for the task.
|
|
574
|
+
*/
|
|
575
|
+
id: string;
|
|
576
|
+
/**
|
|
577
|
+
* The actual task function to be invoked regularly.
|
|
578
|
+
*/
|
|
579
|
+
fn: SchedulerServiceTaskFunction;
|
|
580
|
+
/**
|
|
581
|
+
* An abort signal that, when triggered, will stop the recurring execution of
|
|
582
|
+
* the task.
|
|
583
|
+
*/
|
|
584
|
+
signal?: AbortSignal;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* A previously prepared task schedule, ready to be invoked.
|
|
588
|
+
*
|
|
589
|
+
* @public
|
|
590
|
+
*/
|
|
591
|
+
interface SchedulerServiceTaskRunner {
|
|
592
|
+
/**
|
|
593
|
+
* Takes the schedule and executes an actual task using it.
|
|
594
|
+
*
|
|
595
|
+
* @param task - The actual runtime properties of the task
|
|
596
|
+
*/
|
|
597
|
+
run(task: SchedulerServiceTaskInvocationDefinition): Promise<void>;
|
|
357
598
|
}
|
|
599
|
+
/**
|
|
600
|
+
* Deals with the scheduling of distributed tasks, for a given plugin.
|
|
601
|
+
*
|
|
602
|
+
* @public
|
|
603
|
+
*/
|
|
604
|
+
interface SchedulerService {
|
|
605
|
+
/**
|
|
606
|
+
* Manually triggers a task by ID.
|
|
607
|
+
*
|
|
608
|
+
* If the task doesn't exist, a NotFoundError is thrown. If the task is
|
|
609
|
+
* currently running, a ConflictError is thrown.
|
|
610
|
+
*
|
|
611
|
+
* @param id - The task ID
|
|
612
|
+
*/
|
|
613
|
+
triggerTask(id: string): Promise<void>;
|
|
614
|
+
/**
|
|
615
|
+
* Schedules a task function for recurring runs.
|
|
616
|
+
*
|
|
617
|
+
* @remarks
|
|
618
|
+
*
|
|
619
|
+
* The `scope` task field controls whether to use coordinated exclusive
|
|
620
|
+
* invocation across workers, or to just coordinate within the current worker.
|
|
621
|
+
*
|
|
622
|
+
* This convenience method performs both the scheduling and invocation in one
|
|
623
|
+
* go.
|
|
624
|
+
*
|
|
625
|
+
* @param task - The task definition
|
|
626
|
+
*/
|
|
627
|
+
scheduleTask(task: SchedulerServiceTaskScheduleDefinition & SchedulerServiceTaskInvocationDefinition): Promise<void>;
|
|
628
|
+
/**
|
|
629
|
+
* Creates a scheduled but dormant recurring task, ready to be launched at a
|
|
630
|
+
* later time.
|
|
631
|
+
*
|
|
632
|
+
* @remarks
|
|
633
|
+
*
|
|
634
|
+
* This method is useful for pre-creating a schedule in outer code to be
|
|
635
|
+
* passed into an inner implementation, such that the outer code controls
|
|
636
|
+
* scheduling while inner code controls implementation.
|
|
637
|
+
*
|
|
638
|
+
* @param schedule - The task schedule
|
|
639
|
+
*/
|
|
640
|
+
createScheduledTaskRunner(schedule: SchedulerServiceTaskScheduleDefinition): SchedulerServiceTaskRunner;
|
|
641
|
+
/**
|
|
642
|
+
* Returns all scheduled tasks registered to this scheduler.
|
|
643
|
+
*
|
|
644
|
+
* @remarks
|
|
645
|
+
*
|
|
646
|
+
* This method is useful for triggering tasks manually using the triggerTask
|
|
647
|
+
* functionality. Note that the returned tasks contain only tasks that have
|
|
648
|
+
* been initialized in this instance of the scheduler.
|
|
649
|
+
*
|
|
650
|
+
* @returns Scheduled tasks
|
|
651
|
+
*/
|
|
652
|
+
getScheduledTasks(): Promise<SchedulerServiceTaskDescriptor[]>;
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Reads a {@link SchedulerServiceTaskScheduleDefinition} from config. Expects
|
|
656
|
+
* the config not to be the root config, but the config for the definition.
|
|
657
|
+
*
|
|
658
|
+
* @param config - config for a TaskScheduleDefinition.
|
|
659
|
+
* @public
|
|
660
|
+
*/
|
|
661
|
+
declare function readSchedulerServiceTaskScheduleDefinitionFromConfig(config: Config): SchedulerServiceTaskScheduleDefinition;
|
|
358
662
|
|
|
359
663
|
/**
|
|
360
664
|
* A service that provides a logging facility.
|
|
@@ -460,6 +764,52 @@ type BackstageNonePrincipal = {
|
|
|
460
764
|
type BackstageServicePrincipal = {
|
|
461
765
|
type: 'service';
|
|
462
766
|
subject: string;
|
|
767
|
+
/**
|
|
768
|
+
* The access restrictions that apply to this principal.
|
|
769
|
+
*
|
|
770
|
+
* @remarks
|
|
771
|
+
*
|
|
772
|
+
* If no access restrictions are provided the principal is assumed to have
|
|
773
|
+
* unlimited access, at a framework level. The permissions system and
|
|
774
|
+
* individual plugins may or may not still apply additional access controls on
|
|
775
|
+
* top of this.
|
|
776
|
+
*/
|
|
777
|
+
accessRestrictions?: BackstagePrincipalAccessRestrictions;
|
|
778
|
+
};
|
|
779
|
+
/**
|
|
780
|
+
* The access restrictions that apply to a given principal.
|
|
781
|
+
*
|
|
782
|
+
* @public
|
|
783
|
+
*/
|
|
784
|
+
type BackstagePrincipalAccessRestrictions = {
|
|
785
|
+
/**
|
|
786
|
+
* If given, the principal is limited to only performing actions with these
|
|
787
|
+
* named permissions.
|
|
788
|
+
*
|
|
789
|
+
* Note that this only applies where permissions checks are enabled in the
|
|
790
|
+
* first place. Endpoints that are not protected by the permissions system at
|
|
791
|
+
* all, are not affected by this setting.
|
|
792
|
+
*
|
|
793
|
+
* This array always has at least one element, or is missing entirely.
|
|
794
|
+
*/
|
|
795
|
+
permissionNames?: string[];
|
|
796
|
+
/**
|
|
797
|
+
* If given, the principal is limited to only performing actions whose
|
|
798
|
+
* permissions have these attributes.
|
|
799
|
+
*
|
|
800
|
+
* Note that this only applies where permissions checks are enabled in the
|
|
801
|
+
* first place. Endpoints that are not protected by the permissions system at
|
|
802
|
+
* all, are not affected by this setting.
|
|
803
|
+
*
|
|
804
|
+
* This object always has at least one key, or is missing entirely.
|
|
805
|
+
*/
|
|
806
|
+
permissionAttributes?: {
|
|
807
|
+
/**
|
|
808
|
+
* Match any of these action values. This array always has at least one
|
|
809
|
+
* element, or is missing entirely.
|
|
810
|
+
*/
|
|
811
|
+
action?: Array<Required<PermissionAttributes>['action']>;
|
|
812
|
+
};
|
|
463
813
|
};
|
|
464
814
|
/**
|
|
465
815
|
* @public
|
|
@@ -933,6 +1283,7 @@ declare namespace coreServices {
|
|
|
933
1283
|
* The service reference for the plugin scoped {@link TokenManagerService}.
|
|
934
1284
|
*
|
|
935
1285
|
* @public
|
|
1286
|
+
* @deprecated Please migrate to the new `coreServices.auth`, `coreServices.httpAuth`, and `coreServices.userInfo` services as needed instead
|
|
936
1287
|
*/
|
|
937
1288
|
const tokenManager: ServiceRef<TokenManagerService, "plugin">;
|
|
938
1289
|
/**
|
|
@@ -945,10 +1296,21 @@ declare namespace coreServices {
|
|
|
945
1296
|
* The service reference for the plugin scoped {@link IdentityService}.
|
|
946
1297
|
*
|
|
947
1298
|
* @public
|
|
1299
|
+
* @deprecated Please migrate to the new `coreServices.auth`, `coreServices.httpAuth`, and `coreServices.userInfo` services as needed instead
|
|
948
1300
|
*/
|
|
949
1301
|
const identity: ServiceRef<IdentityService, "plugin">;
|
|
950
1302
|
}
|
|
951
1303
|
|
|
1304
|
+
/**
|
|
1305
|
+
* Tries to deduce whether a thrown error is a database conflict.
|
|
1306
|
+
*
|
|
1307
|
+
* @public
|
|
1308
|
+
* @param e - A thrown error
|
|
1309
|
+
* @returns True if the error looks like it was a conflict error thrown by a
|
|
1310
|
+
* known database engine
|
|
1311
|
+
*/
|
|
1312
|
+
declare function isDatabaseConflictError(e: unknown): boolean;
|
|
1313
|
+
|
|
952
1314
|
/**
|
|
953
1315
|
* Resolve a path relative to the root of a package directory.
|
|
954
1316
|
* Additional path arguments are resolved relative to the package dir.
|
|
@@ -1027,7 +1389,7 @@ interface BackendModuleRegistrationPoints {
|
|
|
1027
1389
|
* @see {@link https://backstage.io/docs/backend-system/architecture/extension-points | The architecture of extension points}
|
|
1028
1390
|
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
1029
1391
|
*/
|
|
1030
|
-
interface
|
|
1392
|
+
interface CreateExtensionPointOptions {
|
|
1031
1393
|
/**
|
|
1032
1394
|
* The ID of this extension point.
|
|
1033
1395
|
*
|
|
@@ -1041,7 +1403,7 @@ interface ExtensionPointConfig {
|
|
|
1041
1403
|
* @public
|
|
1042
1404
|
* @see {@link https://backstage.io/docs/backend-system/architecture/extension-points | The architecture of extension points}
|
|
1043
1405
|
*/
|
|
1044
|
-
declare function createExtensionPoint<T>(
|
|
1406
|
+
declare function createExtensionPoint<T>(options: CreateExtensionPointOptions): ExtensionPoint<T>;
|
|
1045
1407
|
/**
|
|
1046
1408
|
* The configuration options passed to {@link createBackendPlugin}.
|
|
1047
1409
|
*
|
|
@@ -1049,7 +1411,7 @@ declare function createExtensionPoint<T>(config: ExtensionPointConfig): Extensio
|
|
|
1049
1411
|
* @see {@link https://backstage.io/docs/backend-system/architecture/plugins | The architecture of plugins}
|
|
1050
1412
|
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
1051
1413
|
*/
|
|
1052
|
-
interface
|
|
1414
|
+
interface CreateBackendPluginOptions {
|
|
1053
1415
|
/**
|
|
1054
1416
|
* The ID of this plugin.
|
|
1055
1417
|
*
|
|
@@ -1065,7 +1427,7 @@ interface BackendPluginConfig {
|
|
|
1065
1427
|
* @see {@link https://backstage.io/docs/backend-system/architecture/plugins | The architecture of plugins}
|
|
1066
1428
|
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
1067
1429
|
*/
|
|
1068
|
-
declare function createBackendPlugin(
|
|
1430
|
+
declare function createBackendPlugin(options: CreateBackendPluginOptions): () => BackendFeature;
|
|
1069
1431
|
/**
|
|
1070
1432
|
* The configuration options passed to {@link createBackendModule}.
|
|
1071
1433
|
*
|
|
@@ -1073,7 +1435,7 @@ declare function createBackendPlugin(config: BackendPluginConfig): () => Backend
|
|
|
1073
1435
|
* @see {@link https://backstage.io/docs/backend-system/architecture/modules | The architecture of modules}
|
|
1074
1436
|
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
1075
1437
|
*/
|
|
1076
|
-
interface
|
|
1438
|
+
interface CreateBackendModuleOptions {
|
|
1077
1439
|
/**
|
|
1078
1440
|
* Should exactly match the `id` of the plugin that the module extends.
|
|
1079
1441
|
*
|
|
@@ -1093,6 +1455,22 @@ interface BackendModuleConfig {
|
|
|
1093
1455
|
* @see {@link https://backstage.io/docs/backend-system/architecture/modules | The architecture of modules}
|
|
1094
1456
|
* @see {@link https://backstage.io/docs/backend-system/architecture/naming-patterns | Recommended naming patterns}
|
|
1095
1457
|
*/
|
|
1096
|
-
declare function createBackendModule(
|
|
1458
|
+
declare function createBackendModule(options: CreateBackendModuleOptions): () => BackendFeature;
|
|
1459
|
+
|
|
1460
|
+
/**
|
|
1461
|
+
* @public
|
|
1462
|
+
* @deprecated Use {@link CreateBackendPluginOptions} instead.
|
|
1463
|
+
*/
|
|
1464
|
+
type BackendPluginConfig = CreateBackendPluginOptions;
|
|
1465
|
+
/**
|
|
1466
|
+
* @public
|
|
1467
|
+
* @deprecated Use {@link CreateBackendModuleOptions} instead.
|
|
1468
|
+
*/
|
|
1469
|
+
type BackendModuleConfig = CreateBackendModuleOptions;
|
|
1470
|
+
/**
|
|
1471
|
+
* @public
|
|
1472
|
+
* @deprecated Use {@link CreateExtensionPointOptions} instead.
|
|
1473
|
+
*/
|
|
1474
|
+
type ExtensionPointConfig = CreateExtensionPointOptions;
|
|
1097
1475
|
|
|
1098
|
-
export { type AuthService, type BackendFeature, type BackendModuleConfig, type BackendModuleRegistrationPoints, type BackendPluginConfig, type BackendPluginRegistrationPoints, type BackstageCredentials, type BackstageNonePrincipal, type BackstagePrincipalTypes, type BackstageServicePrincipal, type BackstageUserInfo, type BackstageUserPrincipal, type CacheService, type CacheServiceOptions, type CacheServiceSetOptions, type DatabaseService, type DiscoveryService, type ExtensionPoint, type ExtensionPointConfig, type HttpAuthService, type HttpRouterService, type HttpRouterServiceAuthPolicy, type IdentityService, type LifecycleService, type LifecycleServiceShutdownHook, type LifecycleServiceShutdownOptions, type LifecycleServiceStartupHook, type LifecycleServiceStartupOptions, type LoggerService, type PermissionsService, type PermissionsServiceRequestOptions, type PluginMetadataService, type PluginServiceFactoryConfig, type ReadTreeOptions, type ReadTreeResponse, type ReadTreeResponseDirOptions, type ReadTreeResponseFile, type ReadUrlOptions, type ReadUrlResponse, type RootConfigService, type RootHttpRouterService, type RootLifecycleService, type RootLoggerService, type RootServiceFactoryConfig, type SchedulerService, type SearchOptions, type SearchResponse, type SearchResponseFile, type ServiceFactory, type ServiceFactoryOrFunction, type ServiceRef, type ServiceRefConfig, type TokenManagerService, type UrlReaderService, type UserInfoService, coreServices, createBackendModule, createBackendPlugin, createExtensionPoint, createServiceFactory, createServiceRef, resolvePackagePath, resolveSafeChildPath };
|
|
1476
|
+
export { type AuthService, type BackendFeature, type BackendModuleConfig, type BackendModuleRegistrationPoints, type BackendPluginConfig, type BackendPluginRegistrationPoints, type BackstageCredentials, type BackstageNonePrincipal, type BackstagePrincipalAccessRestrictions, type BackstagePrincipalTypes, type BackstageServicePrincipal, type BackstageUserInfo, type BackstageUserPrincipal, type CacheService, type CacheServiceOptions, type CacheServiceSetOptions, type CreateBackendModuleOptions, type CreateBackendPluginOptions, type CreateExtensionPointOptions, type DatabaseService, type DiscoveryService, type ExtensionPoint, type ExtensionPointConfig, type HttpAuthService, type HttpRouterService, type HttpRouterServiceAuthPolicy, type IdentityService, type LifecycleService, type LifecycleServiceShutdownHook, type LifecycleServiceShutdownOptions, type LifecycleServiceStartupHook, type LifecycleServiceStartupOptions, type LoggerService, type PermissionsService, type PermissionsServiceRequestOptions, type PluginMetadataService, type PluginServiceFactoryConfig, type ReadTreeOptions, type ReadTreeResponse, type ReadTreeResponseDirOptions, type ReadTreeResponseFile, type ReadUrlOptions, type ReadUrlResponse, type RootConfigService, type RootHttpRouterService, type RootLifecycleService, type RootLoggerService, type RootServiceFactoryConfig, type SchedulerService, type SchedulerServiceTaskDescriptor, type SchedulerServiceTaskFunction, type SchedulerServiceTaskInvocationDefinition, type SchedulerServiceTaskRunner, type SchedulerServiceTaskScheduleDefinition, type SchedulerServiceTaskScheduleDefinitionConfig, type SearchOptions, type SearchResponse, type SearchResponseFile, type ServiceFactory, type ServiceFactoryOrFunction, type ServiceRef, type ServiceRefConfig, type TokenManagerService, type UrlReaderService, type UserInfoService, coreServices, createBackendModule, createBackendPlugin, createExtensionPoint, createServiceFactory, createServiceRef, isDatabaseConflictError, readSchedulerServiceTaskScheduleDefinitionFromConfig, resolvePackagePath, resolveSafeChildPath };
|
package/dist/testUtils.cjs.js
CHANGED
|
@@ -14,9 +14,8 @@ function overridePackagePathResolution(options) {
|
|
|
14
14
|
);
|
|
15
15
|
}
|
|
16
16
|
paths.packagePathMocks.set(name, (paths) => {
|
|
17
|
-
var _a;
|
|
18
17
|
const joinedPath = path.posix.join(...paths);
|
|
19
|
-
const localResolver =
|
|
18
|
+
const localResolver = options.paths?.[joinedPath];
|
|
20
19
|
if (localResolver) {
|
|
21
20
|
return typeof localResolver === "function" ? localResolver() : localResolver;
|
|
22
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testUtils.cjs.js","sources":["../src/testUtils.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { packagePathMocks } from './paths';\nimport { posix as posixPath, resolve as resolvePath } from 'path';\n\n/** @public */\nexport interface PackagePathResolutionOverride {\n /** Restores the normal behavior of resolvePackagePath */\n restore(): void;\n}\n\n/** @public */\nexport interface OverridePackagePathResolutionOptions {\n /** The name of the package to mock the resolved path of */\n packageName: string;\n\n /** A replacement for the root package path */\n path?: string;\n\n /**\n * Replacements for package sub-paths, each key must be an exact match of the posix-style path\n * that is being resolved within the package.\n *\n * For example, code calling `resolvePackagePath('x', 'foo', 'bar')` would match only the following\n * configuration: `overridePackagePathResolution({ packageName: 'x', paths: { 'foo/bar': baz } })`\n */\n paths?: { [path in string]: string | (() => string) };\n}\n\n/**\n * This utility helps you override the paths returned by `resolvePackagePath` for a given package.\n *\n * @public\n */\nexport function overridePackagePathResolution(\n options: OverridePackagePathResolutionOptions,\n): PackagePathResolutionOverride {\n const name = options.packageName;\n\n if (packagePathMocks.has(name)) {\n throw new Error(\n `Tried to override resolution for '${name}' more than once for package '${name}'`,\n );\n }\n\n packagePathMocks.set(name, paths => {\n const joinedPath = posixPath.join(...paths);\n const localResolver = options.paths?.[joinedPath];\n if (localResolver) {\n return typeof localResolver === 'function'\n ? localResolver()\n : localResolver;\n }\n if (options.path) {\n return resolvePath(options.path, ...paths);\n }\n return undefined;\n });\n\n return {\n restore() {\n packagePathMocks.delete(name);\n },\n };\n}\n"],"names":["packagePathMocks","posixPath","resolvePath"],"mappings":";;;;;;;;AAgDO,SAAS,8BACd,OAC+B,EAAA;AAC/B,EAAA,MAAM,OAAO,OAAQ,CAAA,WAAA,CAAA;AAErB,EAAI,IAAAA,sBAAA,CAAiB,GAAI,CAAA,IAAI,CAAG,EAAA;AAC9B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,kCAAA,EAAqC,IAAI,CAAA,8BAAA,EAAiC,IAAI,CAAA,CAAA,CAAA;AAAA,KAChF,CAAA;AAAA,GACF;AAEA,EAAiBA,sBAAA,CAAA,GAAA,CAAI,MAAM,CAAS,KAAA,KAAA;
|
|
1
|
+
{"version":3,"file":"testUtils.cjs.js","sources":["../src/testUtils.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { packagePathMocks } from './paths';\nimport { posix as posixPath, resolve as resolvePath } from 'path';\n\n/** @public */\nexport interface PackagePathResolutionOverride {\n /** Restores the normal behavior of resolvePackagePath */\n restore(): void;\n}\n\n/** @public */\nexport interface OverridePackagePathResolutionOptions {\n /** The name of the package to mock the resolved path of */\n packageName: string;\n\n /** A replacement for the root package path */\n path?: string;\n\n /**\n * Replacements for package sub-paths, each key must be an exact match of the posix-style path\n * that is being resolved within the package.\n *\n * For example, code calling `resolvePackagePath('x', 'foo', 'bar')` would match only the following\n * configuration: `overridePackagePathResolution({ packageName: 'x', paths: { 'foo/bar': baz } })`\n */\n paths?: { [path in string]: string | (() => string) };\n}\n\n/**\n * This utility helps you override the paths returned by `resolvePackagePath` for a given package.\n *\n * @public\n */\nexport function overridePackagePathResolution(\n options: OverridePackagePathResolutionOptions,\n): PackagePathResolutionOverride {\n const name = options.packageName;\n\n if (packagePathMocks.has(name)) {\n throw new Error(\n `Tried to override resolution for '${name}' more than once for package '${name}'`,\n );\n }\n\n packagePathMocks.set(name, paths => {\n const joinedPath = posixPath.join(...paths);\n const localResolver = options.paths?.[joinedPath];\n if (localResolver) {\n return typeof localResolver === 'function'\n ? localResolver()\n : localResolver;\n }\n if (options.path) {\n return resolvePath(options.path, ...paths);\n }\n return undefined;\n });\n\n return {\n restore() {\n packagePathMocks.delete(name);\n },\n };\n}\n"],"names":["packagePathMocks","posixPath","resolvePath"],"mappings":";;;;;;;;AAgDO,SAAS,8BACd,OAC+B,EAAA;AAC/B,EAAA,MAAM,OAAO,OAAQ,CAAA,WAAA,CAAA;AAErB,EAAI,IAAAA,sBAAA,CAAiB,GAAI,CAAA,IAAI,CAAG,EAAA;AAC9B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,kCAAA,EAAqC,IAAI,CAAA,8BAAA,EAAiC,IAAI,CAAA,CAAA,CAAA;AAAA,KAChF,CAAA;AAAA,GACF;AAEA,EAAiBA,sBAAA,CAAA,GAAA,CAAI,MAAM,CAAS,KAAA,KAAA;AAClC,IAAA,MAAM,UAAa,GAAAC,UAAA,CAAU,IAAK,CAAA,GAAG,KAAK,CAAA,CAAA;AAC1C,IAAM,MAAA,aAAA,GAAgB,OAAQ,CAAA,KAAA,GAAQ,UAAU,CAAA,CAAA;AAChD,IAAA,IAAI,aAAe,EAAA;AACjB,MAAA,OAAO,OAAO,aAAA,KAAkB,UAC5B,GAAA,aAAA,EACA,GAAA,aAAA,CAAA;AAAA,KACN;AACA,IAAA,IAAI,QAAQ,IAAM,EAAA;AAChB,MAAA,OAAOC,YAAY,CAAA,OAAA,CAAQ,IAAM,EAAA,GAAG,KAAK,CAAA,CAAA;AAAA,KAC3C;AACA,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACR,CAAA,CAAA;AAED,EAAO,OAAA;AAAA,IACL,OAAU,GAAA;AACR,MAAAF,sBAAA,CAAiB,OAAO,IAAI,CAAA,CAAA;AAAA,KAC9B;AAAA,GACF,CAAA;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/backend-plugin-api",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.19-next.1",
|
|
4
4
|
"description": "Core API used by Backstage backend plugins",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library"
|
|
@@ -53,19 +53,20 @@
|
|
|
53
53
|
"test": "backstage-cli package test"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@backstage/backend-tasks": "^0.5.23",
|
|
57
56
|
"@backstage/cli-common": "^0.1.13",
|
|
58
57
|
"@backstage/config": "^1.2.0",
|
|
59
58
|
"@backstage/errors": "^1.2.4",
|
|
60
|
-
"@backstage/plugin-auth-node": "^0.4.
|
|
59
|
+
"@backstage/plugin-auth-node": "^0.4.14-next.1",
|
|
61
60
|
"@backstage/plugin-permission-common": "^0.7.13",
|
|
62
61
|
"@backstage/types": "^1.1.1",
|
|
63
62
|
"@types/express": "^4.17.6",
|
|
63
|
+
"@types/luxon": "^3.0.0",
|
|
64
64
|
"express": "^4.17.1",
|
|
65
|
-
"knex": "^3.0.0"
|
|
65
|
+
"knex": "^3.0.0",
|
|
66
|
+
"luxon": "^3.0.0"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
|
-
"@backstage/backend-test-utils": "^0.
|
|
69
|
-
"@backstage/cli": "^0.26.
|
|
69
|
+
"@backstage/backend-test-utils": "^0.4.0-next.1",
|
|
70
|
+
"@backstage/cli": "^0.26.7-next.1"
|
|
70
71
|
}
|
|
71
72
|
}
|