@backstage/backend-plugin-api 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @backstage/backend-plugin-api
2
2
 
3
+ ## 1.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/plugin-auth-node@0.6.6
9
+ - @backstage/plugin-permission-node@0.10.3
10
+
11
+ ## 1.4.2-next.0
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+ - @backstage/plugin-auth-node@0.6.6-next.0
17
+ - @backstage/plugin-permission-node@0.10.3-next.0
18
+ - @backstage/cli-common@0.1.15
19
+ - @backstage/config@1.3.3
20
+ - @backstage/errors@1.2.7
21
+ - @backstage/types@1.2.1
22
+ - @backstage/plugin-permission-common@0.9.1
23
+
3
24
  ## 1.4.1
4
25
 
5
26
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"refs.cjs.js","sources":["../../src/alpha/refs.ts"],"sourcesContent":["/*\n * Copyright 2025 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 '@backstage/backend-plugin-api';\n\n/**\n * @alpha\n */\nexport const instanceMetadataServiceRef = createServiceRef<\n import('./InstanceMetadataService').InstanceMetadataService\n>({\n id: 'core.instanceMetadata',\n});\n\n/**\n * Service for calling distributed actions\n *\n * See {@link ActionsService}\n * and {@link https://backstage.io/docs/backend-system/core-services/actions | the service docs}\n * for more information.\n *\n * @alpha\n */\nexport const actionsServiceRef = createServiceRef<\n import('./ActionsService').ActionsService\n>({\n id: 'alpha.core.actions',\n});\n\n/**\n * Service for registering and managing distributed actions.\n *\n * See {@link ActionsRegistryService}\n * and {@link https://backstage.io/docs/backend-system/core-services/actions-registry | the service docs}\n * for more information.\n *\n * @alpha\n */\nexport const actionsRegistryServiceRef = createServiceRef<\n import('./ActionsRegistryService').ActionsRegistryService\n>({\n id: 'alpha.core.actionsRegistry',\n});\n"],"names":["createServiceRef"],"mappings":";;;;AAqBO,MAAM,6BAA6BA,iCAExC,CAAA;AAAA,EACA,EAAI,EAAA;AACN,CAAC;AAWM,MAAM,oBAAoBA,iCAE/B,CAAA;AAAA,EACA,EAAI,EAAA;AACN,CAAC;AAWM,MAAM,4BAA4BA,iCAEvC,CAAA;AAAA,EACA,EAAI,EAAA;AACN,CAAC;;;;;;"}
1
+ {"version":3,"file":"refs.cjs.js","sources":["../../src/alpha/refs.ts"],"sourcesContent":["/*\n * Copyright 2025 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 '@backstage/backend-plugin-api';\n\n/**\n * @alpha\n */\nexport const instanceMetadataServiceRef = createServiceRef<\n import('./InstanceMetadataService').InstanceMetadataService\n>({\n id: 'core.instanceMetadata',\n});\n\n/**\n * Service for calling distributed actions\n *\n * See {@link ActionsService}\n * and {@link https://backstage.io/docs/backend-system/core-services/actions | the service docs}\n * for more information.\n *\n * @alpha\n */\nexport const actionsServiceRef = createServiceRef<\n import('./ActionsService').ActionsService\n>({\n id: 'alpha.core.actions',\n});\n\n/**\n * Service for registering and managing distributed actions.\n *\n * See {@link ActionsRegistryService}\n * and {@link https://backstage.io/docs/backend-system/core-services/actions-registry | the service docs}\n * for more information.\n *\n * @alpha\n */\nexport const actionsRegistryServiceRef = createServiceRef<\n import('./ActionsRegistryService').ActionsRegistryService\n>({\n id: 'alpha.core.actionsRegistry',\n});\n"],"names":["createServiceRef"],"mappings":";;;;AAqBO,MAAM,6BAA6BA,iCAAA,CAExC;AAAA,EACA,EAAA,EAAI;AACN,CAAC;AAWM,MAAM,oBAAoBA,iCAAA,CAE/B;AAAA,EACA,EAAA,EAAI;AACN,CAAC;AAWM,MAAM,4BAA4BA,iCAAA,CAEvC;AAAA,EACA,EAAA,EAAI;AACN,CAAC;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"describeParentCallSite.cjs.js","sources":["../../../../../frontend-plugin-api/src/routing/describeParentCallSite.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\nconst MESSAGE_MARKER = 'eHgtF5hmbrXyiEvo';\n\n// NOTE: This function is also imported and used in backend code\n\n/**\n * Internal helper that describes the location of the parent caller.\n * @internal\n */\nexport function describeParentCallSite(\n ErrorConstructor: { new (message: string): Error } = Error,\n): string {\n const { stack } = new ErrorConstructor(MESSAGE_MARKER);\n if (!stack) {\n return '<unknown>';\n }\n\n // Safari and Firefox don't include the error itself in the stack\n const startIndex = stack.includes(MESSAGE_MARKER)\n ? stack.indexOf('\\n') + 1\n : 0;\n const secondEntryStart =\n stack.indexOf('\\n', stack.indexOf('\\n', startIndex) + 1) + 1;\n const secondEntryEnd = stack.indexOf('\\n', secondEntryStart);\n\n const line = stack.substring(secondEntryStart, secondEntryEnd).trim();\n if (!line) {\n return 'unknown';\n }\n\n // Below we try to extract the location for different browsers.\n // Since RouteRefs are declared at the top-level of modules the caller name isn't interesting.\n\n // Chrome\n if (line.includes('(')) {\n return line.substring(line.indexOf('(') + 1, line.indexOf(')'));\n }\n\n // Safari & Firefox\n if (line.includes('@')) {\n return line.substring(line.indexOf('@') + 1);\n }\n\n // Give up\n return line;\n}\n"],"names":[],"mappings":";;AAgBA,MAAM,cAAiB,GAAA,kBAAA;AAQP,SAAA,sBAAA,CACd,mBAAqD,KAC7C,EAAA;AACR,EAAA,MAAM,EAAE,KAAA,EAAU,GAAA,IAAI,iBAAiB,cAAc,CAAA;AACrD,EAAA,IAAI,CAAC,KAAO,EAAA;AACV,IAAO,OAAA,WAAA;AAAA;AAIT,EAAM,MAAA,UAAA,GAAa,MAAM,QAAS,CAAA,cAAc,IAC5C,KAAM,CAAA,OAAA,CAAQ,IAAI,CAAA,GAAI,CACtB,GAAA,CAAA;AACJ,EAAM,MAAA,gBAAA,GACJ,KAAM,CAAA,OAAA,CAAQ,IAAM,EAAA,KAAA,CAAM,QAAQ,IAAM,EAAA,UAAU,CAAI,GAAA,CAAC,CAAI,GAAA,CAAA;AAC7D,EAAA,MAAM,cAAiB,GAAA,KAAA,CAAM,OAAQ,CAAA,IAAA,EAAM,gBAAgB,CAAA;AAE3D,EAAA,MAAM,OAAO,KAAM,CAAA,SAAA,CAAU,gBAAkB,EAAA,cAAc,EAAE,IAAK,EAAA;AACpE,EAAA,IAAI,CAAC,IAAM,EAAA;AACT,IAAO,OAAA,SAAA;AAAA;AAOT,EAAI,IAAA,IAAA,CAAK,QAAS,CAAA,GAAG,CAAG,EAAA;AACtB,IAAO,OAAA,IAAA,CAAK,SAAU,CAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,IAAI,CAAG,EAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,CAAC,CAAA;AAAA;AAIhE,EAAI,IAAA,IAAA,CAAK,QAAS,CAAA,GAAG,CAAG,EAAA;AACtB,IAAA,OAAO,KAAK,SAAU,CAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,IAAI,CAAC,CAAA;AAAA;AAI7C,EAAO,OAAA,IAAA;AACT;;;;"}
1
+ {"version":3,"file":"describeParentCallSite.cjs.js","sources":["../../../../../frontend-plugin-api/src/routing/describeParentCallSite.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\nconst MESSAGE_MARKER = 'eHgtF5hmbrXyiEvo';\n\n// NOTE: This function is also imported and used in backend code\n\n/**\n * Internal helper that describes the location of the parent caller.\n * @internal\n */\nexport function describeParentCallSite(\n ErrorConstructor: { new (message: string): Error } = Error,\n): string {\n const { stack } = new ErrorConstructor(MESSAGE_MARKER);\n if (!stack) {\n return '<unknown>';\n }\n\n // Safari and Firefox don't include the error itself in the stack\n const startIndex = stack.includes(MESSAGE_MARKER)\n ? stack.indexOf('\\n') + 1\n : 0;\n const secondEntryStart =\n stack.indexOf('\\n', stack.indexOf('\\n', startIndex) + 1) + 1;\n const secondEntryEnd = stack.indexOf('\\n', secondEntryStart);\n\n const line = stack.substring(secondEntryStart, secondEntryEnd).trim();\n if (!line) {\n return 'unknown';\n }\n\n // Below we try to extract the location for different browsers.\n // Since RouteRefs are declared at the top-level of modules the caller name isn't interesting.\n\n // Chrome\n if (line.includes('(')) {\n return line.substring(line.indexOf('(') + 1, line.indexOf(')'));\n }\n\n // Safari & Firefox\n if (line.includes('@')) {\n return line.substring(line.indexOf('@') + 1);\n }\n\n // Give up\n return line;\n}\n"],"names":[],"mappings":";;AAgBA,MAAM,cAAA,GAAiB,kBAAA;AAQhB,SAAS,sBAAA,CACd,mBAAqD,KAAA,EAC7C;AACR,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,IAAI,iBAAiB,cAAc,CAAA;AACrD,EAAA,IAAI,CAAC,KAAA,EAAO;AACV,IAAA,OAAO,WAAA;AAAA,EACT;AAGA,EAAA,MAAM,UAAA,GAAa,MAAM,QAAA,CAAS,cAAc,IAC5C,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,GAAI,CAAA,GACtB,CAAA;AACJ,EAAA,MAAM,gBAAA,GACJ,KAAA,CAAM,OAAA,CAAQ,IAAA,EAAM,KAAA,CAAM,QAAQ,IAAA,EAAM,UAAU,CAAA,GAAI,CAAC,CAAA,GAAI,CAAA;AAC7D,EAAA,MAAM,cAAA,GAAiB,KAAA,CAAM,OAAA,CAAQ,IAAA,EAAM,gBAAgB,CAAA;AAE3D,EAAA,MAAM,OAAO,KAAA,CAAM,SAAA,CAAU,gBAAA,EAAkB,cAAc,EAAE,IAAA,EAAK;AACpE,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,OAAO,SAAA;AAAA,EACT;AAMA,EAAA,IAAI,IAAA,CAAK,QAAA,CAAS,GAAG,CAAA,EAAG;AACtB,IAAA,OAAO,IAAA,CAAK,SAAA,CAAU,IAAA,CAAK,OAAA,CAAQ,GAAG,IAAI,CAAA,EAAG,IAAA,CAAK,OAAA,CAAQ,GAAG,CAAC,CAAA;AAAA,EAChE;AAGA,EAAA,IAAI,IAAA,CAAK,QAAA,CAAS,GAAG,CAAA,EAAG;AACtB,IAAA,OAAO,KAAK,SAAA,CAAU,IAAA,CAAK,OAAA,CAAQ,GAAG,IAAI,CAAC,CAAA;AAAA,EAC7C;AAGA,EAAA,OAAO,IAAA;AACT;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { JsonObject, HumanDuration, JsonValue } from '@backstage/types';
1
+ import { JsonObject, JsonValue, HumanDuration } from '@backstage/types';
2
2
  import { Request, Response, Handler } from 'express';
3
- import { PermissionAttributes, EvaluatorRequestOptions, PermissionEvaluator, AuthorizePermissionRequest, AuthorizePermissionResponse, QueryPermissionRequest, QueryPermissionResponse, Permission } from '@backstage/plugin-permission-common';
3
+ import { PermissionAttributes, PermissionEvaluator, AuthorizePermissionRequest, EvaluatorRequestOptions, AuthorizePermissionResponse, QueryPermissionRequest, QueryPermissionResponse, Permission } from '@backstage/plugin-permission-common';
4
4
  import { Knex } from 'knex';
5
- import { PermissionResourceRef, PermissionRule, PermissionRuleset } from '@backstage/plugin-permission-node';
5
+ import { PermissionRule, PermissionResourceRef, PermissionRuleset } from '@backstage/plugin-permission-node';
6
6
  import { Config } from '@backstage/config';
7
7
  import { Duration } from 'luxon';
8
8
  import { Readable } from 'stream';
@@ -1 +1 @@
1
- {"version":3,"file":"paths.cjs.js","sources":["../src/paths.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { isChildPath } from '@backstage/cli-common';\nimport { NotAllowedError } from '@backstage/errors';\nimport { resolve as resolvePath } from 'path';\nimport { realpathSync as realPath } from 'fs';\n\n/** @internal */\nexport const packagePathMocks = new Map<\n string,\n (paths: string[]) => string | undefined\n>();\n\n/**\n * Resolve a path relative to the root of a package directory.\n * Additional path arguments are resolved relative to the package dir.\n *\n * This is particularly useful when you want to access assets shipped with\n * your backend plugin package. When doing so, do not forget to include the assets\n * in your published package by adding them to `files` in your `package.json`.\n *\n * @public\n */\nexport function resolvePackagePath(name: string, ...paths: string[]) {\n const mockedResolve = packagePathMocks.get(name);\n if (mockedResolve) {\n const resolved = mockedResolve(paths);\n if (resolved) {\n return resolved;\n }\n }\n\n const req =\n typeof __non_webpack_require__ === 'undefined'\n ? require\n : __non_webpack_require__;\n\n return resolvePath(req.resolve(`${name}/package.json`), '..', ...paths);\n}\n\n/**\n * Resolves a target path from a base path while guaranteeing that the result is\n * a path that point to or within the base path. This is useful for resolving\n * paths from user input, as it otherwise opens up for vulnerabilities.\n *\n * @public\n * @param base - The base directory to resolve the path from.\n * @param path - The target path, relative or absolute\n * @returns A path that is guaranteed to point to or within the base path.\n */\nexport function resolveSafeChildPath(base: string, path: string): string {\n const resolvedBasePath = resolveRealPath(base);\n const targetPath = resolvePath(resolvedBasePath, path);\n\n if (!isChildPath(resolvedBasePath, resolveRealPath(targetPath))) {\n throw new NotAllowedError(\n 'Relative path is not allowed to refer to a directory outside its parent',\n );\n }\n\n // Don't return the resolved path as the original could be a symlink\n return resolvePath(base, path);\n}\n\nfunction resolveRealPath(path: string): string {\n try {\n return realPath(path);\n } catch (ex) {\n if (ex.code !== 'ENOENT') {\n throw ex;\n }\n }\n\n return path;\n}\n// Re-export isChildPath so that backend packages don't need to depend on cli-common\nexport { isChildPath };\n"],"names":["resolvePath","path","isChildPath","NotAllowedError","realPath"],"mappings":";;;;;;;AAsBa,MAAA,gBAAA,uBAAuB,GAGlC;AAYc,SAAA,kBAAA,CAAmB,SAAiB,KAAiB,EAAA;AACnE,EAAM,MAAA,aAAA,GAAgB,gBAAiB,CAAA,GAAA,CAAI,IAAI,CAAA;AAC/C,EAAA,IAAI,aAAe,EAAA;AACjB,IAAM,MAAA,QAAA,GAAW,cAAc,KAAK,CAAA;AACpC,IAAA,IAAI,QAAU,EAAA;AACZ,MAAO,OAAA,QAAA;AAAA;AACT;AAGF,EAAA,MAAM,GACJ,GAAA,OAAO,uBAA4B,KAAA,WAAA,GAC/B,OACA,GAAA,uBAAA;AAEN,EAAO,OAAAA,YAAA,CAAY,IAAI,OAAQ,CAAA,CAAA,EAAG,IAAI,CAAe,aAAA,CAAA,CAAA,EAAG,IAAM,EAAA,GAAG,KAAK,CAAA;AACxE;AAYgB,SAAA,oBAAA,CAAqB,MAAcC,MAAsB,EAAA;AACvE,EAAM,MAAA,gBAAA,GAAmB,gBAAgB,IAAI,CAAA;AAC7C,EAAM,MAAA,UAAA,GAAaD,YAAY,CAAA,gBAAA,EAAkBC,MAAI,CAAA;AAErD,EAAA,IAAI,CAACC,qBAAY,CAAA,gBAAA,EAAkB,eAAgB,CAAA,UAAU,CAAC,CAAG,EAAA;AAC/D,IAAA,MAAM,IAAIC,sBAAA;AAAA,MACR;AAAA,KACF;AAAA;AAIF,EAAO,OAAAH,YAAA,CAAY,MAAMC,MAAI,CAAA;AAC/B;AAEA,SAAS,gBAAgB,IAAsB,EAAA;AAC7C,EAAI,IAAA;AACF,IAAA,OAAOG,gBAAS,IAAI,CAAA;AAAA,WACb,EAAI,EAAA;AACX,IAAI,IAAA,EAAA,CAAG,SAAS,QAAU,EAAA;AACxB,MAAM,MAAA,EAAA;AAAA;AACR;AAGF,EAAO,OAAA,IAAA;AACT;;;;;;;;;;"}
1
+ {"version":3,"file":"paths.cjs.js","sources":["../src/paths.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { isChildPath } from '@backstage/cli-common';\nimport { NotAllowedError } from '@backstage/errors';\nimport { resolve as resolvePath } from 'path';\nimport { realpathSync as realPath } from 'fs';\n\n/** @internal */\nexport const packagePathMocks = new Map<\n string,\n (paths: string[]) => string | undefined\n>();\n\n/**\n * Resolve a path relative to the root of a package directory.\n * Additional path arguments are resolved relative to the package dir.\n *\n * This is particularly useful when you want to access assets shipped with\n * your backend plugin package. When doing so, do not forget to include the assets\n * in your published package by adding them to `files` in your `package.json`.\n *\n * @public\n */\nexport function resolvePackagePath(name: string, ...paths: string[]) {\n const mockedResolve = packagePathMocks.get(name);\n if (mockedResolve) {\n const resolved = mockedResolve(paths);\n if (resolved) {\n return resolved;\n }\n }\n\n const req =\n typeof __non_webpack_require__ === 'undefined'\n ? require\n : __non_webpack_require__;\n\n return resolvePath(req.resolve(`${name}/package.json`), '..', ...paths);\n}\n\n/**\n * Resolves a target path from a base path while guaranteeing that the result is\n * a path that point to or within the base path. This is useful for resolving\n * paths from user input, as it otherwise opens up for vulnerabilities.\n *\n * @public\n * @param base - The base directory to resolve the path from.\n * @param path - The target path, relative or absolute\n * @returns A path that is guaranteed to point to or within the base path.\n */\nexport function resolveSafeChildPath(base: string, path: string): string {\n const resolvedBasePath = resolveRealPath(base);\n const targetPath = resolvePath(resolvedBasePath, path);\n\n if (!isChildPath(resolvedBasePath, resolveRealPath(targetPath))) {\n throw new NotAllowedError(\n 'Relative path is not allowed to refer to a directory outside its parent',\n );\n }\n\n // Don't return the resolved path as the original could be a symlink\n return resolvePath(base, path);\n}\n\nfunction resolveRealPath(path: string): string {\n try {\n return realPath(path);\n } catch (ex) {\n if (ex.code !== 'ENOENT') {\n throw ex;\n }\n }\n\n return path;\n}\n// Re-export isChildPath so that backend packages don't need to depend on cli-common\nexport { isChildPath };\n"],"names":["resolvePath","path","isChildPath","NotAllowedError","realPath"],"mappings":";;;;;;;AAsBO,MAAM,gBAAA,uBAAuB,GAAA;AAe7B,SAAS,kBAAA,CAAmB,SAAiB,KAAA,EAAiB;AACnE,EAAA,MAAM,aAAA,GAAgB,gBAAA,CAAiB,GAAA,CAAI,IAAI,CAAA;AAC/C,EAAA,IAAI,aAAA,EAAe;AACjB,IAAA,MAAM,QAAA,GAAW,cAAc,KAAK,CAAA;AACpC,IAAA,IAAI,QAAA,EAAU;AACZ,MAAA,OAAO,QAAA;AAAA,IACT;AAAA,EACF;AAEA,EAAA,MAAM,GAAA,GACJ,OAAO,uBAAA,KAA4B,WAAA,GAC/B,OAAA,GACA,uBAAA;AAEN,EAAA,OAAOA,YAAA,CAAY,IAAI,OAAA,CAAQ,CAAA,EAAG,IAAI,CAAA,aAAA,CAAe,CAAA,EAAG,IAAA,EAAM,GAAG,KAAK,CAAA;AACxE;AAYO,SAAS,oBAAA,CAAqB,MAAcC,MAAA,EAAsB;AACvE,EAAA,MAAM,gBAAA,GAAmB,gBAAgB,IAAI,CAAA;AAC7C,EAAA,MAAM,UAAA,GAAaD,YAAA,CAAY,gBAAA,EAAkBC,MAAI,CAAA;AAErD,EAAA,IAAI,CAACC,qBAAA,CAAY,gBAAA,EAAkB,eAAA,CAAgB,UAAU,CAAC,CAAA,EAAG;AAC/D,IAAA,MAAM,IAAIC,sBAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AAGA,EAAA,OAAOH,YAAA,CAAY,MAAMC,MAAI,CAAA;AAC/B;AAEA,SAAS,gBAAgB,IAAA,EAAsB;AAC7C,EAAA,IAAI;AACF,IAAA,OAAOG,gBAAS,IAAI,CAAA;AAAA,EACtB,SAAS,EAAA,EAAI;AACX,IAAA,IAAI,EAAA,CAAG,SAAS,QAAA,EAAU;AACxB,MAAA,MAAM,EAAA;AAAA,IACR;AAAA,EACF;AAEA,EAAA,OAAO,IAAA;AACT;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SchedulerService.cjs.js","sources":["../../../src/services/definitions/SchedulerService.ts"],"sourcesContent":["/*\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 (0-60, optional)\n * │ ┌──────────── minute (0-59)\n * │ │ ┌────────── hour (0-23)\n * │ │ │ ┌──────── day of month (1-31)\n * │ │ │ │ ┌────── month (1-12)\n * │ │ │ │ │ ┌──── day of week (0-6, 0 is Sunday)\n * │ │ │ │ │ │\n * * * * * * *\n * ```\n */\n cron: string;\n }\n | Duration\n | HumanDuration\n | { trigger: 'manual' };\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 (0-60, optional)\n * │ ┌──────────── minute (0-59)\n * │ │ ┌────────── hour (0-23)\n * │ │ │ ┌──────── day of month (1-31)\n * │ │ │ │ ┌────── month (1-12)\n * │ │ │ │ │ ┌──── day of week (0-6, 0 is Sunday)\n * │ │ │ │ │ │\n * * * * * * *\n * ```\n */\n cron: string;\n }\n | string\n | HumanDuration\n /**\n * This task will only run when manually triggered with the `triggerTask` method; no automatic\n * scheduling. This is useful for locking of global tasks that should not be run concurrently.\n */\n | { trigger: 'manual' };\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 * See the {@link https://backstage.io/docs/backend-system/core-services/scheduler | service documentation} for more details.\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 readFrequency(\n config: Config,\n key: string,\n): { cron: string } | HumanDuration | { trigger: 'manual' } {\n const value = config.get(key);\n if (typeof value === 'object' && (value as { cron?: string }).cron) {\n return value as { cron: string };\n }\n if (\n typeof value === 'object' &&\n (value as { trigger?: string }).trigger === 'manual'\n ) {\n return { trigger: 'manual' };\n }\n\n return readDurationFromConfig(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 = readFrequency(config, 'frequency');\n const timeout = readDurationFromConfig(config, { key: 'timeout' });\n\n const initialDelay = config.has('initialDelay')\n ? readDurationFromConfig(config, { key: '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"],"names":["config","readDurationFromConfig"],"mappings":";;;;AAkWA,SAAS,aAAA,CACPA,UACA,GAC0D,EAAA;AAC1D,EAAM,MAAA,KAAA,GAAQA,QAAO,CAAA,GAAA,CAAI,GAAG,CAAA;AAC5B,EAAA,IAAI,OAAO,KAAA,KAAU,QAAa,IAAA,KAAA,CAA4B,IAAM,EAAA;AAClE,IAAO,OAAA,KAAA;AAAA;AAET,EAAA,IACE,OAAO,KAAA,KAAU,QAChB,IAAA,KAAA,CAA+B,YAAY,QAC5C,EAAA;AACA,IAAO,OAAA,EAAE,SAAS,QAAS,EAAA;AAAA;AAG7B,EAAA,OAAOC,6BAAuB,CAAAD,QAAA,EAAQ,EAAE,GAAA,EAAK,CAAA;AAC/C;AASO,SAAS,qDACdA,QACwC,EAAA;AACxC,EAAM,MAAA,SAAA,GAAY,aAAc,CAAAA,QAAA,EAAQ,WAAW,CAAA;AACnD,EAAA,MAAM,UAAUC,6BAAuB,CAAAD,QAAA,EAAQ,EAAE,GAAA,EAAK,WAAW,CAAA;AAEjE,EAAM,MAAA,YAAA,GAAeA,QAAO,CAAA,GAAA,CAAI,cAAc,CAAA,GAC1CC,6BAAuB,CAAAD,QAAA,EAAQ,EAAE,GAAA,EAAK,cAAe,EAAC,CACtD,GAAA,KAAA,CAAA;AAEJ,EAAM,MAAA,KAAA,GAAQA,QAAO,CAAA,iBAAA,CAAkB,OAAO,CAAA;AAC9C,EAAI,IAAA,KAAA,IAAS,CAAC,CAAC,QAAA,EAAU,OAAO,CAAE,CAAA,QAAA,CAAS,KAAK,CAAG,EAAA;AACjD,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,mFAAmF,KAAK,CAAA;AAAA,KAC1F;AAAA;AAGF,EAAO,OAAA;AAAA,IACL,SAAA;AAAA,IACA,OAAA;AAAA,IACA,YAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"SchedulerService.cjs.js","sources":["../../../src/services/definitions/SchedulerService.ts"],"sourcesContent":["/*\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 (0-60, optional)\n * │ ┌──────────── minute (0-59)\n * │ │ ┌────────── hour (0-23)\n * │ │ │ ┌──────── day of month (1-31)\n * │ │ │ │ ┌────── month (1-12)\n * │ │ │ │ │ ┌──── day of week (0-6, 0 is Sunday)\n * │ │ │ │ │ │\n * * * * * * *\n * ```\n */\n cron: string;\n }\n | Duration\n | HumanDuration\n | { trigger: 'manual' };\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 (0-60, optional)\n * │ ┌──────────── minute (0-59)\n * │ │ ┌────────── hour (0-23)\n * │ │ │ ┌──────── day of month (1-31)\n * │ │ │ │ ┌────── month (1-12)\n * │ │ │ │ │ ┌──── day of week (0-6, 0 is Sunday)\n * │ │ │ │ │ │\n * * * * * * *\n * ```\n */\n cron: string;\n }\n | string\n | HumanDuration\n /**\n * This task will only run when manually triggered with the `triggerTask` method; no automatic\n * scheduling. This is useful for locking of global tasks that should not be run concurrently.\n */\n | { trigger: 'manual' };\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 * See the {@link https://backstage.io/docs/backend-system/core-services/scheduler | service documentation} for more details.\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 readFrequency(\n config: Config,\n key: string,\n): { cron: string } | HumanDuration | { trigger: 'manual' } {\n const value = config.get(key);\n if (typeof value === 'object' && (value as { cron?: string }).cron) {\n return value as { cron: string };\n }\n if (\n typeof value === 'object' &&\n (value as { trigger?: string }).trigger === 'manual'\n ) {\n return { trigger: 'manual' };\n }\n\n return readDurationFromConfig(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 = readFrequency(config, 'frequency');\n const timeout = readDurationFromConfig(config, { key: 'timeout' });\n\n const initialDelay = config.has('initialDelay')\n ? readDurationFromConfig(config, { key: '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"],"names":["config","readDurationFromConfig"],"mappings":";;;;AAkWA,SAAS,aAAA,CACPA,UACA,GAAA,EAC0D;AAC1D,EAAA,MAAM,KAAA,GAAQA,QAAA,CAAO,GAAA,CAAI,GAAG,CAAA;AAC5B,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAa,KAAA,CAA4B,IAAA,EAAM;AAClE,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IACE,OAAO,KAAA,KAAU,QAAA,IAChB,KAAA,CAA+B,YAAY,QAAA,EAC5C;AACA,IAAA,OAAO,EAAE,SAAS,QAAA,EAAS;AAAA,EAC7B;AAEA,EAAA,OAAOC,6BAAA,CAAuBD,QAAA,EAAQ,EAAE,GAAA,EAAK,CAAA;AAC/C;AASO,SAAS,qDACdA,QAAA,EACwC;AACxC,EAAA,MAAM,SAAA,GAAY,aAAA,CAAcA,QAAA,EAAQ,WAAW,CAAA;AACnD,EAAA,MAAM,UAAUC,6BAAA,CAAuBD,QAAA,EAAQ,EAAE,GAAA,EAAK,WAAW,CAAA;AAEjE,EAAA,MAAM,YAAA,GAAeA,QAAA,CAAO,GAAA,CAAI,cAAc,CAAA,GAC1CC,6BAAA,CAAuBD,QAAA,EAAQ,EAAE,GAAA,EAAK,cAAA,EAAgB,CAAA,GACtD,MAAA;AAEJ,EAAA,MAAM,KAAA,GAAQA,QAAA,CAAO,iBAAA,CAAkB,OAAO,CAAA;AAC9C,EAAA,IAAI,KAAA,IAAS,CAAC,CAAC,QAAA,EAAU,OAAO,CAAA,CAAE,QAAA,CAAS,KAAK,CAAA,EAAG;AACjD,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,mFAAmF,KAAK,CAAA;AAAA,KAC1F;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,SAAA;AAAA,IACA,OAAA;AAAA,IACA,YAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"coreServices.cjs.js","sources":["../../../src/services/definitions/coreServices.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 { createServiceRef } from '../system';\n\n/**\n * All core services references\n *\n * @public\n */\nexport namespace coreServices {\n /**\n * Handles token authentication and credentials management.\n *\n * See {@link AuthService}\n * and {@link https://backstage.io/docs/backend-system/core-services/auth | the service docs}\n * for more information.\n *\n * @public\n */\n export const auth = createServiceRef<import('./AuthService').AuthService>({\n id: 'core.auth',\n });\n\n /**\n * Authenticated user information retrieval.\n *\n * See {@link UserInfoService}\n * and {@link https://backstage.io/docs/backend-system/core-services/user-info | the service docs}\n * for more information.\n *\n * @public\n */\n export const userInfo = createServiceRef<\n import('./UserInfoService').UserInfoService\n >({\n id: 'core.userInfo',\n });\n\n /**\n * Key-value store for caching data.\n *\n * See {@link CacheService}\n * and {@link https://backstage.io/docs/backend-system/core-services/cache | the service docs}\n * for more information.\n *\n * @public\n */\n export const cache = createServiceRef<import('./CacheService').CacheService>({\n id: 'core.cache',\n });\n\n /**\n * Access to static configuration.\n *\n * See {@link RootConfigService}\n * and {@link https://backstage.io/docs/backend-system/core-services/root-config | the service docs}\n * for more information.\n *\n * @public\n */\n export const rootConfig = createServiceRef<\n import('./RootConfigService').RootConfigService\n >({ id: 'core.rootConfig', scope: 'root' });\n\n /**\n * Database access and management via `knex`.\n *\n * See {@link DatabaseService}\n * and {@link https://backstage.io/docs/backend-system/core-services/database | the service docs}\n * for more information.\n *\n * @public\n */\n export const database = createServiceRef<\n import('./DatabaseService').DatabaseService\n >({ id: 'core.database' });\n\n /**\n * Service discovery for inter-plugin communication.\n *\n * See {@link DiscoveryService}\n * and {@link https://backstage.io/docs/backend-system/core-services/discovery | the service docs}\n * for more information.\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 RootHealthService}.\n */\n export const rootHealth = createServiceRef<\n import('./RootHealthService').RootHealthService\n >({ id: 'core.rootHealth', scope: 'root' });\n\n /**\n * Authentication of HTTP requests.\n *\n * See {@link HttpAuthService}\n * and {@link https://backstage.io/docs/backend-system/core-services/http-auth | the service docs}\n * for more information.\n *\n * @public\n */\n export const httpAuth = createServiceRef<\n import('./HttpAuthService').HttpAuthService\n >({ id: 'core.httpAuth' });\n\n /**\n * HTTP route registration for plugins.\n *\n * See {@link HttpRouterService}\n * and {@link https://backstage.io/docs/backend-system/core-services/http-router | the service docs}\n * for more information.\n *\n * @public\n */\n export const httpRouter = createServiceRef<\n import('./HttpRouterService').HttpRouterService\n >({ id: 'core.httpRouter' });\n\n /**\n * Registration of plugin startup and shutdown lifecycle hooks.\n *\n * See {@link LifecycleService}\n * and {@link https://backstage.io/docs/backend-system/core-services/lifecycle | the service docs}\n * for more information.\n *\n * @public\n */\n export const lifecycle = createServiceRef<\n import('./LifecycleService').LifecycleService\n >({ id: 'core.lifecycle' });\n\n /**\n * Plugin-level logging.\n *\n * See {@link LoggerService}\n * and {@link https://backstage.io/docs/backend-system/core-services/logger | the service docs}\n * for more information.\n *\n * @public\n */\n export const logger = createServiceRef<\n import('./LoggerService').LoggerService\n >({ id: 'core.logger' });\n\n /**\n * Plugin-level auditing.\n *\n * See {@link AuditorService}\n * and {@link https://backstage.io/docs/backend-system/core-services/auditor | the service docs}\n * for more information.\n *\n * @public\n */\n export const auditor = createServiceRef<\n import('./AuditorService').AuditorService\n >({ id: 'core.auditor' });\n\n /**\n * Permission system integration for authorization of user actions.\n *\n * See {@link PermissionsService}\n * and {@link https://backstage.io/docs/backend-system/core-services/permissions | the service docs}\n * for more information.\n *\n * @public\n */\n export const permissions = createServiceRef<\n import('./PermissionsService').PermissionsService\n >({ id: 'core.permissions' });\n\n /**\n * Permission system integration for registering resources and permissions.\n *\n * See {@link PermissionsRegistryService}\n * and {@link https://backstage.io/docs/backend-system/core-services/permission-integrations | the service docs}\n * for more information.\n *\n * @public\n */\n export const permissionsRegistry = createServiceRef<\n import('./PermissionsRegistryService').PermissionsRegistryService\n >({ id: 'core.permissionsRegistry' });\n\n /**\n * Built-in service for accessing metadata about the current plugin.\n *\n * See {@link PluginMetadataService}\n * and {@link https://backstage.io/docs/backend-system/core-services/plugin-metadata | the service docs}\n * for more information.\n *\n * @public\n */\n export const pluginMetadata = createServiceRef<\n import('./PluginMetadataService').PluginMetadataService\n >({ id: 'core.pluginMetadata' });\n\n /**\n * HTTP route registration for root services.\n *\n * See {@link RootHttpRouterService}\n * and {@link https://backstage.io/docs/backend-system/core-services/root-http-router | the service docs}\n * for more information.\n *\n * @public\n */\n export const rootHttpRouter = createServiceRef<\n import('./RootHttpRouterService').RootHttpRouterService\n >({ id: 'core.rootHttpRouter', scope: 'root' });\n\n /**\n * Registration of backend startup and shutdown lifecycle hooks.\n *\n * See {@link RootLifecycleService}\n * and {@link https://backstage.io/docs/backend-system/core-services/root-lifecycle | the service docs}\n * for more information.\n *\n * @public\n */\n export const rootLifecycle = createServiceRef<\n import('./RootLifecycleService').RootLifecycleService\n >({ id: 'core.rootLifecycle', scope: 'root' });\n\n /**\n * Root-level logging.\n *\n * See {@link RootLoggerService}\n * and {@link https://backstage.io/docs/backend-system/core-services/root-logger | the service docs}\n * for more information.\n *\n * @public\n */\n export const rootLogger = createServiceRef<\n import('./RootLoggerService').RootLoggerService\n >({ id: 'core.rootLogger', scope: 'root' });\n\n /**\n * Scheduling of distributed background tasks.\n *\n * See {@link SchedulerService}\n * and {@link https://backstage.io/docs/backend-system/core-services/scheduler | the service docs}\n * for more information.\n *\n * @public\n */\n export const scheduler = createServiceRef<\n import('./SchedulerService').SchedulerService\n >({ id: 'core.scheduler' });\n\n /**\n * Reading content from external systems.\n *\n * See {@link UrlReaderService}\n * and {@link https://backstage.io/docs/backend-system/core-services/url-reader | the service docs}\n * for more information.\n *\n * @public\n */\n export const urlReader = createServiceRef<\n import('./UrlReaderService').UrlReaderService\n >({ id: 'core.urlReader' });\n}\n"],"names":["coreServices","createServiceRef"],"mappings":";;;;AAuBiBA;AAAA,CAAV,CAAUA,aAAV,KAAA;AAUE,EAAMA,aAAAA,CAAA,OAAOC,sBAAsD,CAAA;AAAA,IACxE,EAAI,EAAA;AAAA,GACL,CAAA;AAWM,EAAMD,aAAAA,CAAA,WAAWC,sBAEtB,CAAA;AAAA,IACA,EAAI,EAAA;AAAA,GACL,CAAA;AAWM,EAAMD,aAAAA,CAAA,QAAQC,sBAAwD,CAAA;AAAA,IAC3E,EAAI,EAAA;AAAA,GACL,CAAA;AAWM,EAAMD,aAAAA,CAAA,aAAaC,sBAExB,CAAA,EAAE,IAAI,iBAAmB,EAAA,KAAA,EAAO,QAAQ,CAAA;AAWnC,EAAMD,cAAA,QAAW,GAAAC,sBAAA,CAEtB,EAAE,EAAA,EAAI,iBAAiB,CAAA;AAWlB,EAAMD,cAAA,SAAY,GAAAC,sBAAA,CAEvB,EAAE,EAAA,EAAI,kBAAkB,CAAA;AAKnB,EAAMD,aAAAA,CAAA,aAAaC,sBAExB,CAAA,EAAE,IAAI,iBAAmB,EAAA,KAAA,EAAO,QAAQ,CAAA;AAWnC,EAAMD,cAAA,QAAW,GAAAC,sBAAA,CAEtB,EAAE,EAAA,EAAI,iBAAiB,CAAA;AAWlB,EAAMD,cAAA,UAAa,GAAAC,sBAAA,CAExB,EAAE,EAAA,EAAI,mBAAmB,CAAA;AAWpB,EAAMD,cAAA,SAAY,GAAAC,sBAAA,CAEvB,EAAE,EAAA,EAAI,kBAAkB,CAAA;AAWnB,EAAMD,cAAA,MAAS,GAAAC,sBAAA,CAEpB,EAAE,EAAA,EAAI,eAAe,CAAA;AAWhB,EAAMD,cAAA,OAAU,GAAAC,sBAAA,CAErB,EAAE,EAAA,EAAI,gBAAgB,CAAA;AAWjB,EAAMD,cAAA,WAAc,GAAAC,sBAAA,CAEzB,EAAE,EAAA,EAAI,oBAAoB,CAAA;AAWrB,EAAMD,cAAA,mBAAsB,GAAAC,sBAAA,CAEjC,EAAE,EAAA,EAAI,4BAA4B,CAAA;AAW7B,EAAMD,cAAA,cAAiB,GAAAC,sBAAA,CAE5B,EAAE,EAAA,EAAI,uBAAuB,CAAA;AAWxB,EAAMD,aAAAA,CAAA,iBAAiBC,sBAE5B,CAAA,EAAE,IAAI,qBAAuB,EAAA,KAAA,EAAO,QAAQ,CAAA;AAWvC,EAAMD,aAAAA,CAAA,gBAAgBC,sBAE3B,CAAA,EAAE,IAAI,oBAAsB,EAAA,KAAA,EAAO,QAAQ,CAAA;AAWtC,EAAMD,aAAAA,CAAA,aAAaC,sBAExB,CAAA,EAAE,IAAI,iBAAmB,EAAA,KAAA,EAAO,QAAQ,CAAA;AAWnC,EAAMD,cAAA,SAAY,GAAAC,sBAAA,CAEvB,EAAE,EAAA,EAAI,kBAAkB,CAAA;AAWnB,EAAMD,cAAA,SAAY,GAAAC,sBAAA,CAEvB,EAAE,EAAA,EAAI,kBAAkB,CAAA;AAAA,CA/PX,EAAAD,oBAAA,KAAAA,oBAAA,GAAA,EAAA,CAAA,CAAA;;"}
1
+ {"version":3,"file":"coreServices.cjs.js","sources":["../../../src/services/definitions/coreServices.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 { createServiceRef } from '../system';\n\n/**\n * All core services references\n *\n * @public\n */\nexport namespace coreServices {\n /**\n * Handles token authentication and credentials management.\n *\n * See {@link AuthService}\n * and {@link https://backstage.io/docs/backend-system/core-services/auth | the service docs}\n * for more information.\n *\n * @public\n */\n export const auth = createServiceRef<import('./AuthService').AuthService>({\n id: 'core.auth',\n });\n\n /**\n * Authenticated user information retrieval.\n *\n * See {@link UserInfoService}\n * and {@link https://backstage.io/docs/backend-system/core-services/user-info | the service docs}\n * for more information.\n *\n * @public\n */\n export const userInfo = createServiceRef<\n import('./UserInfoService').UserInfoService\n >({\n id: 'core.userInfo',\n });\n\n /**\n * Key-value store for caching data.\n *\n * See {@link CacheService}\n * and {@link https://backstage.io/docs/backend-system/core-services/cache | the service docs}\n * for more information.\n *\n * @public\n */\n export const cache = createServiceRef<import('./CacheService').CacheService>({\n id: 'core.cache',\n });\n\n /**\n * Access to static configuration.\n *\n * See {@link RootConfigService}\n * and {@link https://backstage.io/docs/backend-system/core-services/root-config | the service docs}\n * for more information.\n *\n * @public\n */\n export const rootConfig = createServiceRef<\n import('./RootConfigService').RootConfigService\n >({ id: 'core.rootConfig', scope: 'root' });\n\n /**\n * Database access and management via `knex`.\n *\n * See {@link DatabaseService}\n * and {@link https://backstage.io/docs/backend-system/core-services/database | the service docs}\n * for more information.\n *\n * @public\n */\n export const database = createServiceRef<\n import('./DatabaseService').DatabaseService\n >({ id: 'core.database' });\n\n /**\n * Service discovery for inter-plugin communication.\n *\n * See {@link DiscoveryService}\n * and {@link https://backstage.io/docs/backend-system/core-services/discovery | the service docs}\n * for more information.\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 RootHealthService}.\n */\n export const rootHealth = createServiceRef<\n import('./RootHealthService').RootHealthService\n >({ id: 'core.rootHealth', scope: 'root' });\n\n /**\n * Authentication of HTTP requests.\n *\n * See {@link HttpAuthService}\n * and {@link https://backstage.io/docs/backend-system/core-services/http-auth | the service docs}\n * for more information.\n *\n * @public\n */\n export const httpAuth = createServiceRef<\n import('./HttpAuthService').HttpAuthService\n >({ id: 'core.httpAuth' });\n\n /**\n * HTTP route registration for plugins.\n *\n * See {@link HttpRouterService}\n * and {@link https://backstage.io/docs/backend-system/core-services/http-router | the service docs}\n * for more information.\n *\n * @public\n */\n export const httpRouter = createServiceRef<\n import('./HttpRouterService').HttpRouterService\n >({ id: 'core.httpRouter' });\n\n /**\n * Registration of plugin startup and shutdown lifecycle hooks.\n *\n * See {@link LifecycleService}\n * and {@link https://backstage.io/docs/backend-system/core-services/lifecycle | the service docs}\n * for more information.\n *\n * @public\n */\n export const lifecycle = createServiceRef<\n import('./LifecycleService').LifecycleService\n >({ id: 'core.lifecycle' });\n\n /**\n * Plugin-level logging.\n *\n * See {@link LoggerService}\n * and {@link https://backstage.io/docs/backend-system/core-services/logger | the service docs}\n * for more information.\n *\n * @public\n */\n export const logger = createServiceRef<\n import('./LoggerService').LoggerService\n >({ id: 'core.logger' });\n\n /**\n * Plugin-level auditing.\n *\n * See {@link AuditorService}\n * and {@link https://backstage.io/docs/backend-system/core-services/auditor | the service docs}\n * for more information.\n *\n * @public\n */\n export const auditor = createServiceRef<\n import('./AuditorService').AuditorService\n >({ id: 'core.auditor' });\n\n /**\n * Permission system integration for authorization of user actions.\n *\n * See {@link PermissionsService}\n * and {@link https://backstage.io/docs/backend-system/core-services/permissions | the service docs}\n * for more information.\n *\n * @public\n */\n export const permissions = createServiceRef<\n import('./PermissionsService').PermissionsService\n >({ id: 'core.permissions' });\n\n /**\n * Permission system integration for registering resources and permissions.\n *\n * See {@link PermissionsRegistryService}\n * and {@link https://backstage.io/docs/backend-system/core-services/permission-integrations | the service docs}\n * for more information.\n *\n * @public\n */\n export const permissionsRegistry = createServiceRef<\n import('./PermissionsRegistryService').PermissionsRegistryService\n >({ id: 'core.permissionsRegistry' });\n\n /**\n * Built-in service for accessing metadata about the current plugin.\n *\n * See {@link PluginMetadataService}\n * and {@link https://backstage.io/docs/backend-system/core-services/plugin-metadata | the service docs}\n * for more information.\n *\n * @public\n */\n export const pluginMetadata = createServiceRef<\n import('./PluginMetadataService').PluginMetadataService\n >({ id: 'core.pluginMetadata' });\n\n /**\n * HTTP route registration for root services.\n *\n * See {@link RootHttpRouterService}\n * and {@link https://backstage.io/docs/backend-system/core-services/root-http-router | the service docs}\n * for more information.\n *\n * @public\n */\n export const rootHttpRouter = createServiceRef<\n import('./RootHttpRouterService').RootHttpRouterService\n >({ id: 'core.rootHttpRouter', scope: 'root' });\n\n /**\n * Registration of backend startup and shutdown lifecycle hooks.\n *\n * See {@link RootLifecycleService}\n * and {@link https://backstage.io/docs/backend-system/core-services/root-lifecycle | the service docs}\n * for more information.\n *\n * @public\n */\n export const rootLifecycle = createServiceRef<\n import('./RootLifecycleService').RootLifecycleService\n >({ id: 'core.rootLifecycle', scope: 'root' });\n\n /**\n * Root-level logging.\n *\n * See {@link RootLoggerService}\n * and {@link https://backstage.io/docs/backend-system/core-services/root-logger | the service docs}\n * for more information.\n *\n * @public\n */\n export const rootLogger = createServiceRef<\n import('./RootLoggerService').RootLoggerService\n >({ id: 'core.rootLogger', scope: 'root' });\n\n /**\n * Scheduling of distributed background tasks.\n *\n * See {@link SchedulerService}\n * and {@link https://backstage.io/docs/backend-system/core-services/scheduler | the service docs}\n * for more information.\n *\n * @public\n */\n export const scheduler = createServiceRef<\n import('./SchedulerService').SchedulerService\n >({ id: 'core.scheduler' });\n\n /**\n * Reading content from external systems.\n *\n * See {@link UrlReaderService}\n * and {@link https://backstage.io/docs/backend-system/core-services/url-reader | the service docs}\n * for more information.\n *\n * @public\n */\n export const urlReader = createServiceRef<\n import('./UrlReaderService').UrlReaderService\n >({ id: 'core.urlReader' });\n}\n"],"names":["coreServices","createServiceRef"],"mappings":";;;;AAuBiBA;AAAA,CAAV,CAAUA,aAAAA,KAAV;AAUE,EAAMA,aAAAA,CAAA,OAAOC,sBAAA,CAAsD;AAAA,IACxE,EAAA,EAAI;AAAA,GACL,CAAA;AAWM,EAAMD,aAAAA,CAAA,WAAWC,sBAAA,CAEtB;AAAA,IACA,EAAA,EAAI;AAAA,GACL,CAAA;AAWM,EAAMD,aAAAA,CAAA,QAAQC,sBAAA,CAAwD;AAAA,IAC3E,EAAA,EAAI;AAAA,GACL,CAAA;AAWM,EAAMD,aAAAA,CAAA,aAAaC,sBAAA,CAExB,EAAE,IAAI,iBAAA,EAAmB,KAAA,EAAO,QAAQ,CAAA;AAWnC,EAAMD,cAAA,QAAA,GAAWC,sBAAA,CAEtB,EAAE,EAAA,EAAI,iBAAiB,CAAA;AAWlB,EAAMD,cAAA,SAAA,GAAYC,sBAAA,CAEvB,EAAE,EAAA,EAAI,kBAAkB,CAAA;AAKnB,EAAMD,aAAAA,CAAA,aAAaC,sBAAA,CAExB,EAAE,IAAI,iBAAA,EAAmB,KAAA,EAAO,QAAQ,CAAA;AAWnC,EAAMD,cAAA,QAAA,GAAWC,sBAAA,CAEtB,EAAE,EAAA,EAAI,iBAAiB,CAAA;AAWlB,EAAMD,cAAA,UAAA,GAAaC,sBAAA,CAExB,EAAE,EAAA,EAAI,mBAAmB,CAAA;AAWpB,EAAMD,cAAA,SAAA,GAAYC,sBAAA,CAEvB,EAAE,EAAA,EAAI,kBAAkB,CAAA;AAWnB,EAAMD,cAAA,MAAA,GAASC,sBAAA,CAEpB,EAAE,EAAA,EAAI,eAAe,CAAA;AAWhB,EAAMD,cAAA,OAAA,GAAUC,sBAAA,CAErB,EAAE,EAAA,EAAI,gBAAgB,CAAA;AAWjB,EAAMD,cAAA,WAAA,GAAcC,sBAAA,CAEzB,EAAE,EAAA,EAAI,oBAAoB,CAAA;AAWrB,EAAMD,cAAA,mBAAA,GAAsBC,sBAAA,CAEjC,EAAE,EAAA,EAAI,4BAA4B,CAAA;AAW7B,EAAMD,cAAA,cAAA,GAAiBC,sBAAA,CAE5B,EAAE,EAAA,EAAI,uBAAuB,CAAA;AAWxB,EAAMD,aAAAA,CAAA,iBAAiBC,sBAAA,CAE5B,EAAE,IAAI,qBAAA,EAAuB,KAAA,EAAO,QAAQ,CAAA;AAWvC,EAAMD,aAAAA,CAAA,gBAAgBC,sBAAA,CAE3B,EAAE,IAAI,oBAAA,EAAsB,KAAA,EAAO,QAAQ,CAAA;AAWtC,EAAMD,aAAAA,CAAA,aAAaC,sBAAA,CAExB,EAAE,IAAI,iBAAA,EAAmB,KAAA,EAAO,QAAQ,CAAA;AAWnC,EAAMD,cAAA,SAAA,GAAYC,sBAAA,CAEvB,EAAE,EAAA,EAAI,kBAAkB,CAAA;AAWnB,EAAMD,cAAA,SAAA,GAAYC,sBAAA,CAEvB,EAAE,EAAA,EAAI,kBAAkB,CAAA;AAAA,CAAA,EA/PXD,oBAAA,KAAAA,oBAAA,GAAA,EAAA,CAAA,CAAA;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs.js","sources":["../../../src/services/system/types.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 * A reference to a backend service. You can use these references to mark\n * dependencies on services and having their implementations injected\n * automatically.\n *\n * @public\n */\nexport type ServiceRef<\n TService,\n TScope extends 'root' | 'plugin' = 'root' | 'plugin',\n TInstances extends 'singleton' | 'multiton' = 'singleton' | 'multiton',\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 * Marks whether the service is a multiton or not. Multiton services the\n * opposite of singletons - they can be provided many times, and when depended\n * on, you receive an array of all provided instances.\n */\n multiton?: TInstances extends 'multiton' ? true : false;\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 TInstances extends 'singleton' | 'multiton' = 'singleton' | 'multiton',\n> extends BackendFeature {\n service: ServiceRef<TService, TScope, TInstances>;\n}\n\n/** @internal */\nexport interface InternalServiceFactory<\n TService = unknown,\n TScope extends 'plugin' | 'root' = 'plugin' | 'root',\n TInstances extends 'singleton' | 'multiton' = 'singleton' | 'multiton',\n> extends ServiceFactory<TService, TScope, TInstances> {\n version: 'v1';\n featureType: 'service';\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/** @public */\nexport interface ServiceRefOptions<\n TService,\n TScope extends 'root' | 'plugin',\n TInstances extends 'singleton' | 'multiton',\n> {\n id: string;\n scope?: TScope;\n multiton?: TInstances extends 'multiton' ? true : false;\n defaultFactory?(\n service: ServiceRef<TService, TScope>,\n ): Promise<ServiceFactory>;\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 options: ServiceRefOptions<TService, 'plugin', 'singleton'>,\n): ServiceRef<TService, 'plugin', 'singleton'>;\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 options: ServiceRefOptions<TService, 'root', 'singleton'>,\n): ServiceRef<TService, 'root', 'singleton'>;\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 options: ServiceRefOptions<TService, 'plugin', 'multiton'>,\n): ServiceRef<TService, 'plugin', 'multiton'>;\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 options: ServiceRefOptions<TService, 'root', 'multiton'>,\n): ServiceRef<TService, 'root', 'multiton'>;\nexport function createServiceRef<\n TService,\n TInstances extends 'singleton' | 'multiton',\n>(\n options: ServiceRefOptions<TService, any, TInstances>,\n): ServiceRef<TService, any, TInstances> {\n const { id, scope = 'plugin', multiton = false, defaultFactory } = options;\n return {\n id,\n scope,\n multiton,\n get T(): TService {\n throw new Error(`tried to read ServiceRef.T of ${this}`);\n },\n toString() {\n return `serviceRef{${options.id}}`;\n },\n toJSON() {\n // This avoids accidental calls to T happening e.g. in tests\n return {\n $$type: '@backstage/ServiceRef',\n id,\n scope,\n multiton,\n };\n },\n $$type: '@backstage/ServiceRef',\n __defaultFactory: defaultFactory,\n } as ServiceRef<TService, typeof scope, TInstances> & {\n __defaultFactory?: (\n service: ServiceRef<TService>,\n ) => Promise<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\n ? key\n : never]: T[key]['multiton'] extends true | undefined\n ? Array<T[key]['T']>\n : T[key]['T'];\n};\n\n/** @public */\nexport interface RootServiceFactoryOptions<\n TService,\n TInstances extends 'singleton' | 'multiton',\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', TInstances>;\n deps: TDeps;\n factory(deps: ServiceRefsToInstances<TDeps, 'root'>): TImpl | Promise<TImpl>;\n}\n\n/** @public */\nexport interface PluginServiceFactoryOptions<\n TService,\n TInstances extends 'singleton' | 'multiton',\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', TInstances>;\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 options - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TInstances extends 'singleton' | 'multiton',\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown, 'root'> },\n>(\n options: RootServiceFactoryOptions<TService, TInstances, TImpl, TDeps>,\n): ServiceFactory<TService, 'root', TInstances>;\n/**\n * Creates a plugin scoped service factory without options.\n *\n * @public\n * @param options - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TInstances extends 'singleton' | 'multiton',\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext = undefined,\n>(\n options: PluginServiceFactoryOptions<\n TService,\n TInstances,\n TContext,\n TImpl,\n TDeps\n >,\n): ServiceFactory<TService, 'plugin', TInstances>;\nexport function createServiceFactory<\n TService,\n TInstances extends 'singleton' | 'multiton',\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext,\n>(\n options:\n | RootServiceFactoryOptions<TService, TInstances, TImpl, TDeps>\n | PluginServiceFactoryOptions<TService, TInstances, TContext, TImpl, TDeps>,\n): ServiceFactory<TService, 'root' | 'plugin', 'singleton' | 'multiton'> {\n if (options.service.scope === 'root') {\n const c = options as RootServiceFactoryOptions<\n TService,\n TInstances,\n TImpl,\n TDeps\n >;\n return {\n $$type: '@backstage/BackendFeature',\n version: 'v1',\n featureType: 'service',\n service: c.service,\n initialization: c.initialization,\n deps: options.deps,\n factory: async (deps: ServiceRefsToInstances<TDeps, 'root'>) =>\n c.factory(deps),\n } as InternalServiceFactory<TService, 'root', TInstances>;\n }\n const c = options as PluginServiceFactoryOptions<\n TService,\n TInstances,\n TContext,\n TImpl,\n TDeps\n >;\n return {\n $$type: '@backstage/BackendFeature',\n version: 'v1',\n featureType: 'service',\n service: c.service,\n initialization: c.initialization,\n ...('createRootContext' in options\n ? {\n createRootContext: async (\n deps: ServiceRefsToInstances<TDeps, 'root'>,\n ) => c?.createRootContext?.(deps),\n }\n : {}),\n deps: options.deps,\n factory: async (deps: ServiceRefsToInstances<TDeps>, ctx: TContext) =>\n c.factory(deps, ctx),\n } as InternalServiceFactory<TService, 'plugin', TInstances>;\n}\n"],"names":["c"],"mappings":";;AAsIO,SAAS,iBAId,OACuC,EAAA;AACvC,EAAA,MAAM,EAAE,EAAI,EAAA,KAAA,GAAQ,UAAU,QAAW,GAAA,KAAA,EAAO,gBAAmB,GAAA,OAAA;AACnE,EAAO,OAAA;AAAA,IACL,EAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAI,CAAc,GAAA;AAChB,MAAA,MAAM,IAAI,KAAA,CAAM,CAAiC,8BAAA,EAAA,IAAI,CAAE,CAAA,CAAA;AAAA,KACzD;AAAA,IACA,QAAW,GAAA;AACT,MAAO,OAAA,CAAA,WAAA,EAAc,QAAQ,EAAE,CAAA,CAAA,CAAA;AAAA,KACjC;AAAA,IACA,MAAS,GAAA;AAEP,MAAO,OAAA;AAAA,QACL,MAAQ,EAAA,uBAAA;AAAA,QACR,EAAA;AAAA,QACA,KAAA;AAAA,QACA;AAAA,OACF;AAAA,KACF;AAAA,IACA,MAAQ,EAAA,uBAAA;AAAA,IACR,gBAAkB,EAAA;AAAA,GACpB;AAKF;AAsGO,SAAS,qBAOd,OAGuE,EAAA;AACvE,EAAI,IAAA,OAAA,CAAQ,OAAQ,CAAA,KAAA,KAAU,MAAQ,EAAA;AACpC,IAAA,MAAMA,EAAI,GAAA,OAAA;AAMV,IAAO,OAAA;AAAA,MACL,MAAQ,EAAA,2BAAA;AAAA,MACR,OAAS,EAAA,IAAA;AAAA,MACT,WAAa,EAAA,SAAA;AAAA,MACb,SAASA,EAAE,CAAA,OAAA;AAAA,MACX,gBAAgBA,EAAE,CAAA,cAAA;AAAA,MAClB,MAAM,OAAQ,CAAA,IAAA;AAAA,MACd,OAAS,EAAA,OAAO,IACdA,KAAAA,EAAAA,CAAE,QAAQ,IAAI;AAAA,KAClB;AAAA;AAEF,EAAA,MAAM,CAAI,GAAA,OAAA;AAOV,EAAO,OAAA;AAAA,IACL,MAAQ,EAAA,2BAAA;AAAA,IACR,OAAS,EAAA,IAAA;AAAA,IACT,WAAa,EAAA,SAAA;AAAA,IACb,SAAS,CAAE,CAAA,OAAA;AAAA,IACX,gBAAgB,CAAE,CAAA,cAAA;AAAA,IAClB,GAAI,uBAAuB,OACvB,GAAA;AAAA,MACE,iBAAmB,EAAA,OACjB,IACG,KAAA,CAAA,EAAG,oBAAoB,IAAI;AAAA,QAElC,EAAC;AAAA,IACL,MAAM,OAAQ,CAAA,IAAA;AAAA,IACd,SAAS,OAAO,IAAA,EAAqC,QACnD,CAAE,CAAA,OAAA,CAAQ,MAAM,GAAG;AAAA,GACvB;AACF;;;;;"}
1
+ {"version":3,"file":"types.cjs.js","sources":["../../../src/services/system/types.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 * A reference to a backend service. You can use these references to mark\n * dependencies on services and having their implementations injected\n * automatically.\n *\n * @public\n */\nexport type ServiceRef<\n TService,\n TScope extends 'root' | 'plugin' = 'root' | 'plugin',\n TInstances extends 'singleton' | 'multiton' = 'singleton' | 'multiton',\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 * Marks whether the service is a multiton or not. Multiton services the\n * opposite of singletons - they can be provided many times, and when depended\n * on, you receive an array of all provided instances.\n */\n multiton?: TInstances extends 'multiton' ? true : false;\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 TInstances extends 'singleton' | 'multiton' = 'singleton' | 'multiton',\n> extends BackendFeature {\n service: ServiceRef<TService, TScope, TInstances>;\n}\n\n/** @internal */\nexport interface InternalServiceFactory<\n TService = unknown,\n TScope extends 'plugin' | 'root' = 'plugin' | 'root',\n TInstances extends 'singleton' | 'multiton' = 'singleton' | 'multiton',\n> extends ServiceFactory<TService, TScope, TInstances> {\n version: 'v1';\n featureType: 'service';\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/** @public */\nexport interface ServiceRefOptions<\n TService,\n TScope extends 'root' | 'plugin',\n TInstances extends 'singleton' | 'multiton',\n> {\n id: string;\n scope?: TScope;\n multiton?: TInstances extends 'multiton' ? true : false;\n defaultFactory?(\n service: ServiceRef<TService, TScope>,\n ): Promise<ServiceFactory>;\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 options: ServiceRefOptions<TService, 'plugin', 'singleton'>,\n): ServiceRef<TService, 'plugin', 'singleton'>;\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 options: ServiceRefOptions<TService, 'root', 'singleton'>,\n): ServiceRef<TService, 'root', 'singleton'>;\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 options: ServiceRefOptions<TService, 'plugin', 'multiton'>,\n): ServiceRef<TService, 'plugin', 'multiton'>;\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 options: ServiceRefOptions<TService, 'root', 'multiton'>,\n): ServiceRef<TService, 'root', 'multiton'>;\nexport function createServiceRef<\n TService,\n TInstances extends 'singleton' | 'multiton',\n>(\n options: ServiceRefOptions<TService, any, TInstances>,\n): ServiceRef<TService, any, TInstances> {\n const { id, scope = 'plugin', multiton = false, defaultFactory } = options;\n return {\n id,\n scope,\n multiton,\n get T(): TService {\n throw new Error(`tried to read ServiceRef.T of ${this}`);\n },\n toString() {\n return `serviceRef{${options.id}}`;\n },\n toJSON() {\n // This avoids accidental calls to T happening e.g. in tests\n return {\n $$type: '@backstage/ServiceRef',\n id,\n scope,\n multiton,\n };\n },\n $$type: '@backstage/ServiceRef',\n __defaultFactory: defaultFactory,\n } as ServiceRef<TService, typeof scope, TInstances> & {\n __defaultFactory?: (\n service: ServiceRef<TService>,\n ) => Promise<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\n ? key\n : never]: T[key]['multiton'] extends true | undefined\n ? Array<T[key]['T']>\n : T[key]['T'];\n};\n\n/** @public */\nexport interface RootServiceFactoryOptions<\n TService,\n TInstances extends 'singleton' | 'multiton',\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', TInstances>;\n deps: TDeps;\n factory(deps: ServiceRefsToInstances<TDeps, 'root'>): TImpl | Promise<TImpl>;\n}\n\n/** @public */\nexport interface PluginServiceFactoryOptions<\n TService,\n TInstances extends 'singleton' | 'multiton',\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', TInstances>;\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 options - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TInstances extends 'singleton' | 'multiton',\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown, 'root'> },\n>(\n options: RootServiceFactoryOptions<TService, TInstances, TImpl, TDeps>,\n): ServiceFactory<TService, 'root', TInstances>;\n/**\n * Creates a plugin scoped service factory without options.\n *\n * @public\n * @param options - The service factory configuration.\n */\nexport function createServiceFactory<\n TService,\n TInstances extends 'singleton' | 'multiton',\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext = undefined,\n>(\n options: PluginServiceFactoryOptions<\n TService,\n TInstances,\n TContext,\n TImpl,\n TDeps\n >,\n): ServiceFactory<TService, 'plugin', TInstances>;\nexport function createServiceFactory<\n TService,\n TInstances extends 'singleton' | 'multiton',\n TImpl extends TService,\n TDeps extends { [name in string]: ServiceRef<unknown> },\n TContext,\n>(\n options:\n | RootServiceFactoryOptions<TService, TInstances, TImpl, TDeps>\n | PluginServiceFactoryOptions<TService, TInstances, TContext, TImpl, TDeps>,\n): ServiceFactory<TService, 'root' | 'plugin', 'singleton' | 'multiton'> {\n if (options.service.scope === 'root') {\n const c = options as RootServiceFactoryOptions<\n TService,\n TInstances,\n TImpl,\n TDeps\n >;\n return {\n $$type: '@backstage/BackendFeature',\n version: 'v1',\n featureType: 'service',\n service: c.service,\n initialization: c.initialization,\n deps: options.deps,\n factory: async (deps: ServiceRefsToInstances<TDeps, 'root'>) =>\n c.factory(deps),\n } as InternalServiceFactory<TService, 'root', TInstances>;\n }\n const c = options as PluginServiceFactoryOptions<\n TService,\n TInstances,\n TContext,\n TImpl,\n TDeps\n >;\n return {\n $$type: '@backstage/BackendFeature',\n version: 'v1',\n featureType: 'service',\n service: c.service,\n initialization: c.initialization,\n ...('createRootContext' in options\n ? {\n createRootContext: async (\n deps: ServiceRefsToInstances<TDeps, 'root'>,\n ) => c?.createRootContext?.(deps),\n }\n : {}),\n deps: options.deps,\n factory: async (deps: ServiceRefsToInstances<TDeps>, ctx: TContext) =>\n c.factory(deps, ctx),\n } as InternalServiceFactory<TService, 'plugin', TInstances>;\n}\n"],"names":["c"],"mappings":";;AAsIO,SAAS,iBAId,OAAA,EACuC;AACvC,EAAA,MAAM,EAAE,EAAA,EAAI,KAAA,GAAQ,UAAU,QAAA,GAAW,KAAA,EAAO,gBAAe,GAAI,OAAA;AACnE,EAAA,OAAO;AAAA,IACL,EAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAI,CAAA,GAAc;AAChB,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,8BAAA,EAAiC,IAAI,CAAA,CAAE,CAAA;AAAA,IACzD,CAAA;AAAA,IACA,QAAA,GAAW;AACT,MAAA,OAAO,CAAA,WAAA,EAAc,QAAQ,EAAE,CAAA,CAAA,CAAA;AAAA,IACjC,CAAA;AAAA,IACA,MAAA,GAAS;AAEP,MAAA,OAAO;AAAA,QACL,MAAA,EAAQ,uBAAA;AAAA,QACR,EAAA;AAAA,QACA,KAAA;AAAA,QACA;AAAA,OACF;AAAA,IACF,CAAA;AAAA,IACA,MAAA,EAAQ,uBAAA;AAAA,IACR,gBAAA,EAAkB;AAAA,GACpB;AAKF;AAsGO,SAAS,qBAOd,OAAA,EAGuE;AACvE,EAAA,IAAI,OAAA,CAAQ,OAAA,CAAQ,KAAA,KAAU,MAAA,EAAQ;AACpC,IAAA,MAAMA,EAAAA,GAAI,OAAA;AAMV,IAAA,OAAO;AAAA,MACL,MAAA,EAAQ,2BAAA;AAAA,MACR,OAAA,EAAS,IAAA;AAAA,MACT,WAAA,EAAa,SAAA;AAAA,MACb,SAASA,EAAAA,CAAE,OAAA;AAAA,MACX,gBAAgBA,EAAAA,CAAE,cAAA;AAAA,MAClB,MAAM,OAAA,CAAQ,IAAA;AAAA,MACd,OAAA,EAAS,OAAO,IAAA,KACdA,EAAAA,CAAE,QAAQ,IAAI;AAAA,KAClB;AAAA,EACF;AACA,EAAA,MAAM,CAAA,GAAI,OAAA;AAOV,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,2BAAA;AAAA,IACR,OAAA,EAAS,IAAA;AAAA,IACT,WAAA,EAAa,SAAA;AAAA,IACb,SAAS,CAAA,CAAE,OAAA;AAAA,IACX,gBAAgB,CAAA,CAAE,cAAA;AAAA,IAClB,GAAI,uBAAuB,OAAA,GACvB;AAAA,MACE,iBAAA,EAAmB,OACjB,IAAA,KACG,CAAA,EAAG,oBAAoB,IAAI;AAAA,QAElC,EAAC;AAAA,IACL,MAAM,OAAA,CAAQ,IAAA;AAAA,IACd,SAAS,OAAO,IAAA,EAAqC,QACnD,CAAA,CAAE,OAAA,CAAQ,MAAM,GAAG;AAAA,GACvB;AACF;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"database.cjs.js","sources":["../../../src/services/utilities/database.ts"],"sourcesContent":["/*\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"],"names":[],"mappings":";;AAwBO,SAAS,wBAAwB,CAAY,EAAA;AAClD,EAAA,MAAM,UAAW,CAAW,EAAA,OAAA;AAE5B,EAAA,OACE,OAAO,OAAY,KAAA,QAAA,KAClB,uCAAwC,CAAA,IAAA,CAAK,OAAO,CACnD,IAAA,2BAAA,CAA4B,IAAK,CAAA,OAAO,KACxC,mBAAoB,CAAA,IAAA,CAAK,OAAO,CAChC,IAAA,iBAAA,CAAkB,KAAK,OAAO,CAAA,CAAA;AAEpC;;;;"}
1
+ {"version":3,"file":"database.cjs.js","sources":["../../../src/services/utilities/database.ts"],"sourcesContent":["/*\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"],"names":[],"mappings":";;AAwBO,SAAS,wBAAwB,CAAA,EAAY;AAClD,EAAA,MAAM,UAAW,CAAA,EAAW,OAAA;AAE5B,EAAA,OACE,OAAO,OAAA,KAAY,QAAA,KAClB,uCAAA,CAAwC,IAAA,CAAK,OAAO,CAAA,IACnD,2BAAA,CAA4B,IAAA,CAAK,OAAO,KACxC,mBAAA,CAAoB,IAAA,CAAK,OAAO,CAAA,IAChC,iBAAA,CAAkB,KAAK,OAAO,CAAA,CAAA;AAEpC;;;;"}
@@ -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;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;AAAA,KAChF;AAAA;AAGF,EAAiBA,sBAAA,CAAA,GAAA,CAAI,MAAM,CAAS,KAAA,KAAA;AAClC,IAAA,MAAM,UAAa,GAAAC,UAAA,CAAU,IAAK,CAAA,GAAG,KAAK,CAAA;AAC1C,IAAM,MAAA,aAAA,GAAgB,OAAQ,CAAA,KAAA,GAAQ,UAAU,CAAA;AAChD,IAAA,IAAI,aAAe,EAAA;AACjB,MAAA,OAAO,OAAO,aAAA,KAAkB,UAC5B,GAAA,aAAA,EACA,GAAA,aAAA;AAAA;AAEN,IAAA,IAAI,QAAQ,IAAM,EAAA;AAChB,MAAA,OAAOC,YAAY,CAAA,OAAA,CAAQ,IAAM,EAAA,GAAG,KAAK,CAAA;AAAA;AAE3C,IAAO,OAAA,KAAA,CAAA;AAAA,GACR,CAAA;AAED,EAAO,OAAA;AAAA,IACL,OAAU,GAAA;AACR,MAAAF,sBAAA,CAAiB,OAAO,IAAI,CAAA;AAAA;AAC9B,GACF;AACF;;;;"}
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,OAAA,EAC+B;AAC/B,EAAA,MAAM,OAAO,OAAA,CAAQ,WAAA;AAErB,EAAA,IAAIA,sBAAA,CAAiB,GAAA,CAAI,IAAI,CAAA,EAAG;AAC9B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,kCAAA,EAAqC,IAAI,CAAA,8BAAA,EAAiC,IAAI,CAAA,CAAA;AAAA,KAChF;AAAA,EACF;AAEA,EAAAA,sBAAA,CAAiB,GAAA,CAAI,MAAM,CAAA,KAAA,KAAS;AAClC,IAAA,MAAM,UAAA,GAAaC,UAAA,CAAU,IAAA,CAAK,GAAG,KAAK,CAAA;AAC1C,IAAA,MAAM,aAAA,GAAgB,OAAA,CAAQ,KAAA,GAAQ,UAAU,CAAA;AAChD,IAAA,IAAI,aAAA,EAAe;AACjB,MAAA,OAAO,OAAO,aAAA,KAAkB,UAAA,GAC5B,aAAA,EAAc,GACd,aAAA;AAAA,IACN;AACA,IAAA,IAAI,QAAQ,IAAA,EAAM;AAChB,MAAA,OAAOC,YAAA,CAAY,OAAA,CAAQ,IAAA,EAAM,GAAG,KAAK,CAAA;AAAA,IAC3C;AACA,IAAA,OAAO,MAAA;AAAA,EACT,CAAC,CAAA;AAED,EAAA,OAAO;AAAA,IACL,OAAA,GAAU;AACR,MAAAF,sBAAA,CAAiB,OAAO,IAAI,CAAA;AAAA,IAC9B;AAAA,GACF;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createBackendFeatureLoader.cjs.js","sources":["../../src/wiring/createBackendFeatureLoader.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { ServiceRef } from '../services';\nimport { BackendFeature } from '../types';\nimport { describeParentCallSite } from './describeParentCallSite';\nimport { InternalBackendFeatureLoader } from './types';\n\n/**\n * @public\n * Options for creating a new backend feature loader.\n */\nexport interface CreateBackendFeatureLoaderOptions<\n TDeps extends { [name in string]: unknown },\n> {\n deps?: {\n [name in keyof TDeps]: ServiceRef<TDeps[name], 'root'>;\n };\n loader(\n deps: TDeps,\n ):\n | Iterable<BackendFeature | Promise<{ default: BackendFeature }>>\n | Promise<Iterable<BackendFeature | Promise<{ default: BackendFeature }>>>\n | AsyncIterable<BackendFeature | { default: BackendFeature }>;\n}\n\n/**\n * @public\n * Creates a new backend feature loader.\n */\nexport function createBackendFeatureLoader<\n TDeps extends { [name in string]: unknown },\n>(options: CreateBackendFeatureLoaderOptions<TDeps>): BackendFeature {\n return {\n $$type: '@backstage/BackendFeature',\n version: 'v1',\n featureType: 'loader',\n description: `created at '${describeParentCallSite()}'`,\n deps: options.deps,\n async loader(deps: TDeps) {\n const it = await options.loader(deps);\n const result = new Array<BackendFeature>();\n for await (const item of it) {\n if ('$$type' in item && item.$$type === '@backstage/BackendFeature') {\n result.push(item);\n } else if ('default' in item) {\n result.push(item.default);\n } else {\n throw new Error(`Invalid item \"${item}\"`);\n }\n }\n return result;\n },\n } as InternalBackendFeatureLoader;\n}\n"],"names":["describeParentCallSite"],"mappings":";;;;AA2CO,SAAS,2BAEd,OAAmE,EAAA;AACnE,EAAO,OAAA;AAAA,IACL,MAAQ,EAAA,2BAAA;AAAA,IACR,OAAS,EAAA,IAAA;AAAA,IACT,WAAa,EAAA,QAAA;AAAA,IACb,WAAA,EAAa,CAAe,YAAA,EAAAA,6CAAA,EAAwB,CAAA,CAAA,CAAA;AAAA,IACpD,MAAM,OAAQ,CAAA,IAAA;AAAA,IACd,MAAM,OAAO,IAAa,EAAA;AACxB,MAAA,MAAM,EAAK,GAAA,MAAM,OAAQ,CAAA,MAAA,CAAO,IAAI,CAAA;AACpC,MAAM,MAAA,MAAA,GAAS,IAAI,KAAsB,EAAA;AACzC,MAAA,WAAA,MAAiB,QAAQ,EAAI,EAAA;AAC3B,QAAA,IAAI,QAAY,IAAA,IAAA,IAAQ,IAAK,CAAA,MAAA,KAAW,2BAA6B,EAAA;AACnE,UAAA,MAAA,CAAO,KAAK,IAAI,CAAA;AAAA,SAClB,MAAA,IAAW,aAAa,IAAM,EAAA;AAC5B,UAAO,MAAA,CAAA,IAAA,CAAK,KAAK,OAAO,CAAA;AAAA,SACnB,MAAA;AACL,UAAA,MAAM,IAAI,KAAA,CAAM,CAAiB,cAAA,EAAA,IAAI,CAAG,CAAA,CAAA,CAAA;AAAA;AAC1C;AAEF,MAAO,OAAA,MAAA;AAAA;AACT,GACF;AACF;;;;"}
1
+ {"version":3,"file":"createBackendFeatureLoader.cjs.js","sources":["../../src/wiring/createBackendFeatureLoader.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { ServiceRef } from '../services';\nimport { BackendFeature } from '../types';\nimport { describeParentCallSite } from './describeParentCallSite';\nimport { InternalBackendFeatureLoader } from './types';\n\n/**\n * @public\n * Options for creating a new backend feature loader.\n */\nexport interface CreateBackendFeatureLoaderOptions<\n TDeps extends { [name in string]: unknown },\n> {\n deps?: {\n [name in keyof TDeps]: ServiceRef<TDeps[name], 'root'>;\n };\n loader(\n deps: TDeps,\n ):\n | Iterable<BackendFeature | Promise<{ default: BackendFeature }>>\n | Promise<Iterable<BackendFeature | Promise<{ default: BackendFeature }>>>\n | AsyncIterable<BackendFeature | { default: BackendFeature }>;\n}\n\n/**\n * @public\n * Creates a new backend feature loader.\n */\nexport function createBackendFeatureLoader<\n TDeps extends { [name in string]: unknown },\n>(options: CreateBackendFeatureLoaderOptions<TDeps>): BackendFeature {\n return {\n $$type: '@backstage/BackendFeature',\n version: 'v1',\n featureType: 'loader',\n description: `created at '${describeParentCallSite()}'`,\n deps: options.deps,\n async loader(deps: TDeps) {\n const it = await options.loader(deps);\n const result = new Array<BackendFeature>();\n for await (const item of it) {\n if ('$$type' in item && item.$$type === '@backstage/BackendFeature') {\n result.push(item);\n } else if ('default' in item) {\n result.push(item.default);\n } else {\n throw new Error(`Invalid item \"${item}\"`);\n }\n }\n return result;\n },\n } as InternalBackendFeatureLoader;\n}\n"],"names":["describeParentCallSite"],"mappings":";;;;AA2CO,SAAS,2BAEd,OAAA,EAAmE;AACnE,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,2BAAA;AAAA,IACR,OAAA,EAAS,IAAA;AAAA,IACT,WAAA,EAAa,QAAA;AAAA,IACb,WAAA,EAAa,CAAA,YAAA,EAAeA,6CAAA,EAAwB,CAAA,CAAA,CAAA;AAAA,IACpD,MAAM,OAAA,CAAQ,IAAA;AAAA,IACd,MAAM,OAAO,IAAA,EAAa;AACxB,MAAA,MAAM,EAAA,GAAK,MAAM,OAAA,CAAQ,MAAA,CAAO,IAAI,CAAA;AACpC,MAAA,MAAM,MAAA,GAAS,IAAI,KAAA,EAAsB;AACzC,MAAA,WAAA,MAAiB,QAAQ,EAAA,EAAI;AAC3B,QAAA,IAAI,QAAA,IAAY,IAAA,IAAQ,IAAA,CAAK,MAAA,KAAW,2BAAA,EAA6B;AACnE,UAAA,MAAA,CAAO,KAAK,IAAI,CAAA;AAAA,QAClB,CAAA,MAAA,IAAW,aAAa,IAAA,EAAM;AAC5B,UAAA,MAAA,CAAO,IAAA,CAAK,KAAK,OAAO,CAAA;AAAA,QAC1B,CAAA,MAAO;AACL,UAAA,MAAM,IAAI,KAAA,CAAM,CAAA,cAAA,EAAiB,IAAI,CAAA,CAAA,CAAG,CAAA;AAAA,QAC1C;AAAA,MACF;AACA,MAAA,OAAO,MAAA;AAAA,IACT;AAAA,GACF;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createBackendModule.cjs.js","sources":["../../src/wiring/createBackendModule.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';\nimport {\n BackendModuleRegistrationPoints,\n InternalBackendModuleRegistration,\n InternalBackendPluginRegistration,\n InternalBackendRegistrations,\n} from './types';\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 function getRegistrations() {\n const extensionPoints: InternalBackendPluginRegistration['extensionPoints'] =\n [];\n let init: InternalBackendModuleRegistration['init'] | undefined = undefined;\n\n options.register({\n registerExtensionPoint(ext, impl) {\n if (init) {\n throw new Error('registerExtensionPoint called after registerInit');\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 return [\n {\n type: 'module',\n pluginId: options.pluginId,\n moduleId: options.moduleId,\n extensionPoints,\n init,\n },\n ];\n }\n\n return {\n $$type: '@backstage/BackendFeature' as const,\n featureType: 'registrations',\n version: 'v1',\n getRegistrations,\n } as InternalBackendRegistrations;\n}\n"],"names":[],"mappings":";;AAqDO,SAAS,oBACd,OACgB,EAAA;AAChB,EAAA,SAAS,gBAAmB,GAAA;AAC1B,IAAA,MAAM,kBACJ,EAAC;AACH,IAAA,IAAI,IAA8D,GAAA,KAAA,CAAA;AAElE,IAAA,OAAA,CAAQ,QAAS,CAAA;AAAA,MACf,sBAAA,CAAuB,KAAK,IAAM,EAAA;AAChC,QAAA,IAAI,IAAM,EAAA;AACR,UAAM,MAAA,IAAI,MAAM,kDAAkD,CAAA;AAAA;AAEpE,QAAA,eAAA,CAAgB,IAAK,CAAA,CAAC,GAAK,EAAA,IAAI,CAAC,CAAA;AAAA,OAClC;AAAA,MACA,aAAa,OAAS,EAAA;AACpB,QAAA,IAAI,IAAM,EAAA;AACR,UAAM,MAAA,IAAI,MAAM,uCAAuC,CAAA;AAAA;AAEzD,QAAO,IAAA,GAAA;AAAA,UACL,MAAM,OAAQ,CAAA,IAAA;AAAA,UACd,MAAM,OAAQ,CAAA;AAAA,SAChB;AAAA;AACF,KACD,CAAA;AAED,IAAA,IAAI,CAAC,IAAM,EAAA;AACT,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAA8C,2CAAA,EAAA,OAAA,CAAQ,QAAQ,CAAA,YAAA,EAAe,QAAQ,QAAQ,CAAA;AAAA,OAC/F;AAAA;AAGF,IAAO,OAAA;AAAA,MACL;AAAA,QACE,IAAM,EAAA,QAAA;AAAA,QACN,UAAU,OAAQ,CAAA,QAAA;AAAA,QAClB,UAAU,OAAQ,CAAA,QAAA;AAAA,QAClB,eAAA;AAAA,QACA;AAAA;AACF,KACF;AAAA;AAGF,EAAO,OAAA;AAAA,IACL,MAAQ,EAAA,2BAAA;AAAA,IACR,WAAa,EAAA,eAAA;AAAA,IACb,OAAS,EAAA,IAAA;AAAA,IACT;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"createBackendModule.cjs.js","sources":["../../src/wiring/createBackendModule.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';\nimport {\n BackendModuleRegistrationPoints,\n InternalBackendModuleRegistration,\n InternalBackendPluginRegistration,\n InternalBackendRegistrations,\n} from './types';\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 function getRegistrations() {\n const extensionPoints: InternalBackendPluginRegistration['extensionPoints'] =\n [];\n let init: InternalBackendModuleRegistration['init'] | undefined = undefined;\n\n options.register({\n registerExtensionPoint(ext, impl) {\n if (init) {\n throw new Error('registerExtensionPoint called after registerInit');\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 return [\n {\n type: 'module',\n pluginId: options.pluginId,\n moduleId: options.moduleId,\n extensionPoints,\n init,\n },\n ];\n }\n\n return {\n $$type: '@backstage/BackendFeature' as const,\n featureType: 'registrations',\n version: 'v1',\n getRegistrations,\n } as InternalBackendRegistrations;\n}\n"],"names":[],"mappings":";;AAqDO,SAAS,oBACd,OAAA,EACgB;AAChB,EAAA,SAAS,gBAAA,GAAmB;AAC1B,IAAA,MAAM,kBACJ,EAAC;AACH,IAAA,IAAI,IAAA,GAA8D,MAAA;AAElE,IAAA,OAAA,CAAQ,QAAA,CAAS;AAAA,MACf,sBAAA,CAAuB,KAAK,IAAA,EAAM;AAChC,QAAA,IAAI,IAAA,EAAM;AACR,UAAA,MAAM,IAAI,MAAM,kDAAkD,CAAA;AAAA,QACpE;AACA,QAAA,eAAA,CAAgB,IAAA,CAAK,CAAC,GAAA,EAAK,IAAI,CAAC,CAAA;AAAA,MAClC,CAAA;AAAA,MACA,aAAa,OAAA,EAAS;AACpB,QAAA,IAAI,IAAA,EAAM;AACR,UAAA,MAAM,IAAI,MAAM,uCAAuC,CAAA;AAAA,QACzD;AACA,QAAA,IAAA,GAAO;AAAA,UACL,MAAM,OAAA,CAAQ,IAAA;AAAA,UACd,MAAM,OAAA,CAAQ;AAAA,SAChB;AAAA,MACF;AAAA,KACD,CAAA;AAED,IAAA,IAAI,CAAC,IAAA,EAAM;AACT,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,2CAAA,EAA8C,OAAA,CAAQ,QAAQ,CAAA,YAAA,EAAe,QAAQ,QAAQ,CAAA;AAAA,OAC/F;AAAA,IACF;AAEA,IAAA,OAAO;AAAA,MACL;AAAA,QACE,IAAA,EAAM,QAAA;AAAA,QACN,UAAU,OAAA,CAAQ,QAAA;AAAA,QAClB,UAAU,OAAA,CAAQ,QAAA;AAAA,QAClB,eAAA;AAAA,QACA;AAAA;AACF,KACF;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,2BAAA;AAAA,IACR,WAAA,EAAa,eAAA;AAAA,IACb,OAAA,EAAS,IAAA;AAAA,IACT;AAAA,GACF;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createBackendPlugin.cjs.js","sources":["../../src/wiring/createBackendPlugin.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';\nimport {\n BackendPluginRegistrationPoints,\n InternalBackendPluginRegistration,\n InternalBackendRegistrations,\n} from './types';\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 function getRegistrations() {\n const extensionPoints: InternalBackendPluginRegistration['extensionPoints'] =\n [];\n let init: InternalBackendPluginRegistration['init'] | undefined = undefined;\n\n options.register({\n registerExtensionPoint(ext, impl) {\n if (init) {\n throw new Error('registerExtensionPoint called after registerInit');\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 return [\n {\n type: 'plugin',\n pluginId: options.pluginId,\n extensionPoints,\n init,\n },\n ];\n }\n\n return {\n $$type: '@backstage/BackendFeature' as const,\n version: 'v1',\n featureType: 'registrations',\n getRegistrations,\n } as InternalBackendRegistrations;\n}\n"],"names":[],"mappings":";;AA+CO,SAAS,oBACd,OACgB,EAAA;AAChB,EAAA,SAAS,gBAAmB,GAAA;AAC1B,IAAA,MAAM,kBACJ,EAAC;AACH,IAAA,IAAI,IAA8D,GAAA,KAAA,CAAA;AAElE,IAAA,OAAA,CAAQ,QAAS,CAAA;AAAA,MACf,sBAAA,CAAuB,KAAK,IAAM,EAAA;AAChC,QAAA,IAAI,IAAM,EAAA;AACR,UAAM,MAAA,IAAI,MAAM,kDAAkD,CAAA;AAAA;AAEpE,QAAA,eAAA,CAAgB,IAAK,CAAA,CAAC,GAAK,EAAA,IAAI,CAAC,CAAA;AAAA,OAClC;AAAA,MACA,aAAa,OAAS,EAAA;AACpB,QAAA,IAAI,IAAM,EAAA;AACR,UAAM,MAAA,IAAI,MAAM,uCAAuC,CAAA;AAAA;AAEzD,QAAO,IAAA,GAAA;AAAA,UACL,MAAM,OAAQ,CAAA,IAAA;AAAA,UACd,MAAM,OAAQ,CAAA;AAAA,SAChB;AAAA;AACF,KACD,CAAA;AAED,IAAA,IAAI,CAAC,IAAM,EAAA;AACT,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,2CAAA,EAA8C,QAAQ,QAAQ,CAAA;AAAA,OAChE;AAAA;AAGF,IAAO,OAAA;AAAA,MACL;AAAA,QACE,IAAM,EAAA,QAAA;AAAA,QACN,UAAU,OAAQ,CAAA,QAAA;AAAA,QAClB,eAAA;AAAA,QACA;AAAA;AACF,KACF;AAAA;AAGF,EAAO,OAAA;AAAA,IACL,MAAQ,EAAA,2BAAA;AAAA,IACR,OAAS,EAAA,IAAA;AAAA,IACT,WAAa,EAAA,eAAA;AAAA,IACb;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"createBackendPlugin.cjs.js","sources":["../../src/wiring/createBackendPlugin.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';\nimport {\n BackendPluginRegistrationPoints,\n InternalBackendPluginRegistration,\n InternalBackendRegistrations,\n} from './types';\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 function getRegistrations() {\n const extensionPoints: InternalBackendPluginRegistration['extensionPoints'] =\n [];\n let init: InternalBackendPluginRegistration['init'] | undefined = undefined;\n\n options.register({\n registerExtensionPoint(ext, impl) {\n if (init) {\n throw new Error('registerExtensionPoint called after registerInit');\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 return [\n {\n type: 'plugin',\n pluginId: options.pluginId,\n extensionPoints,\n init,\n },\n ];\n }\n\n return {\n $$type: '@backstage/BackendFeature' as const,\n version: 'v1',\n featureType: 'registrations',\n getRegistrations,\n } as InternalBackendRegistrations;\n}\n"],"names":[],"mappings":";;AA+CO,SAAS,oBACd,OAAA,EACgB;AAChB,EAAA,SAAS,gBAAA,GAAmB;AAC1B,IAAA,MAAM,kBACJ,EAAC;AACH,IAAA,IAAI,IAAA,GAA8D,MAAA;AAElE,IAAA,OAAA,CAAQ,QAAA,CAAS;AAAA,MACf,sBAAA,CAAuB,KAAK,IAAA,EAAM;AAChC,QAAA,IAAI,IAAA,EAAM;AACR,UAAA,MAAM,IAAI,MAAM,kDAAkD,CAAA;AAAA,QACpE;AACA,QAAA,eAAA,CAAgB,IAAA,CAAK,CAAC,GAAA,EAAK,IAAI,CAAC,CAAA;AAAA,MAClC,CAAA;AAAA,MACA,aAAa,OAAA,EAAS;AACpB,QAAA,IAAI,IAAA,EAAM;AACR,UAAA,MAAM,IAAI,MAAM,uCAAuC,CAAA;AAAA,QACzD;AACA,QAAA,IAAA,GAAO;AAAA,UACL,MAAM,OAAA,CAAQ,IAAA;AAAA,UACd,MAAM,OAAA,CAAQ;AAAA,SAChB;AAAA,MACF;AAAA,KACD,CAAA;AAED,IAAA,IAAI,CAAC,IAAA,EAAM;AACT,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,2CAAA,EAA8C,QAAQ,QAAQ,CAAA;AAAA,OAChE;AAAA,IACF;AAEA,IAAA,OAAO;AAAA,MACL;AAAA,QACE,IAAA,EAAM,QAAA;AAAA,QACN,UAAU,OAAA,CAAQ,QAAA;AAAA,QAClB,eAAA;AAAA,QACA;AAAA;AACF,KACF;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,2BAAA;AAAA,IACR,OAAA,EAAS,IAAA;AAAA,IACT,WAAA,EAAa,eAAA;AAAA,IACb;AAAA,GACF;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createExtensionPoint.cjs.js","sources":["../../src/wiring/createExtensionPoint.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 { ExtensionPoint } 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 if (process.env.NODE_ENV === 'test') {\n // Avoid throwing errors so tests asserting extensions' properties cannot be easily broken\n return null as T;\n }\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"],"names":[],"mappings":";;AAwCO,SAAS,qBACd,OACmB,EAAA;AACnB,EAAO,OAAA;AAAA,IACL,IAAI,OAAQ,CAAA,EAAA;AAAA,IACZ,IAAI,CAAO,GAAA;AACT,MAAI,IAAA,OAAA,CAAQ,GAAI,CAAA,QAAA,KAAa,MAAQ,EAAA;AAEnC,QAAO,OAAA,IAAA;AAAA;AAET,MAAA,MAAM,IAAI,KAAA,CAAM,CAAqC,kCAAA,EAAA,IAAI,CAAE,CAAA,CAAA;AAAA,KAC7D;AAAA,IACA,QAAW,GAAA;AACT,MAAO,OAAA,CAAA,eAAA,EAAkB,QAAQ,EAAE,CAAA,CAAA,CAAA;AAAA,KACrC;AAAA,IACA,MAAQ,EAAA;AAAA,GACV;AACF;;;;"}
1
+ {"version":3,"file":"createExtensionPoint.cjs.js","sources":["../../src/wiring/createExtensionPoint.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 { ExtensionPoint } 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 if (process.env.NODE_ENV === 'test') {\n // Avoid throwing errors so tests asserting extensions' properties cannot be easily broken\n return null as T;\n }\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"],"names":[],"mappings":";;AAwCO,SAAS,qBACd,OAAA,EACmB;AACnB,EAAA,OAAO;AAAA,IACL,IAAI,OAAA,CAAQ,EAAA;AAAA,IACZ,IAAI,CAAA,GAAO;AACT,MAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,MAAA,EAAQ;AAEnC,QAAA,OAAO,IAAA;AAAA,MACT;AACA,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kCAAA,EAAqC,IAAI,CAAA,CAAE,CAAA;AAAA,IAC7D,CAAA;AAAA,IACA,QAAA,GAAW;AACT,MAAA,OAAO,CAAA,eAAA,EAAkB,QAAQ,EAAE,CAAA,CAAA,CAAA;AAAA,IACrC,CAAA;AAAA,IACA,MAAA,EAAQ;AAAA,GACV;AACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/backend-plugin-api",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "Core API used by Backstage backend plugins",
5
5
  "backstage": {
6
6
  "role": "node-library"
@@ -68,9 +68,9 @@
68
68
  "@backstage/cli-common": "^0.1.15",
69
69
  "@backstage/config": "^1.3.3",
70
70
  "@backstage/errors": "^1.2.7",
71
- "@backstage/plugin-auth-node": "^0.6.5",
71
+ "@backstage/plugin-auth-node": "^0.6.6",
72
72
  "@backstage/plugin-permission-common": "^0.9.1",
73
- "@backstage/plugin-permission-node": "^0.10.2",
73
+ "@backstage/plugin-permission-node": "^0.10.3",
74
74
  "@backstage/types": "^1.2.1",
75
75
  "@types/express": "^4.17.6",
76
76
  "@types/json-schema": "^7.0.6",
@@ -81,8 +81,8 @@
81
81
  "zod": "^3.22.4"
82
82
  },
83
83
  "devDependencies": {
84
- "@backstage/backend-test-utils": "^1.7.0",
85
- "@backstage/cli": "^0.33.1"
84
+ "@backstage/backend-test-utils": "^1.8.0",
85
+ "@backstage/cli": "^0.34.0"
86
86
  },
87
87
  "configSchema": "config.d.ts"
88
88
  }