@backstage/plugin-catalog-backend-module-puppetdb 0.1.24-next.2 → 0.1.25-next.0

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,30 @@
1
1
  # @backstage/plugin-catalog-backend-module-puppetdb
2
2
 
3
+ ## 0.1.25-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/backend-tasks@0.5.24-next.0
9
+ - @backstage/backend-common@0.22.1-next.0
10
+ - @backstage/backend-plugin-api@0.6.19-next.0
11
+ - @backstage/plugin-catalog-node@1.12.1-next.0
12
+ - @backstage/catalog-model@1.5.0
13
+ - @backstage/config@1.2.0
14
+ - @backstage/errors@1.2.4
15
+ - @backstage/types@1.1.1
16
+
17
+ ## 0.1.24
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies
22
+ - @backstage/plugin-catalog-node@1.12.0
23
+ - @backstage/catalog-model@1.5.0
24
+ - @backstage/backend-common@0.22.0
25
+ - @backstage/backend-plugin-api@0.6.18
26
+ - @backstage/backend-tasks@0.5.23
27
+
3
28
  ## 0.1.24-next.2
4
29
 
5
30
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend-module-puppetdb",
3
- "version": "0.1.24-next.2",
3
+ "version": "0.1.25-next.0",
4
4
  "main": "../dist/alpha.cjs.js",
5
5
  "types": "../dist/alpha.d.ts"
6
6
  }
package/dist/alpha.cjs.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var backendPluginApi = require('@backstage/backend-plugin-api');
6
6
  var alpha = require('@backstage/plugin-catalog-node/alpha');
7
- var PuppetDbEntityProvider = require('./cjs/PuppetDbEntityProvider-0YlNSUWD.cjs.js');
7
+ var PuppetDbEntityProvider = require('./cjs/PuppetDbEntityProvider-CJxPJSiY.cjs.js');
8
8
  require('@backstage/backend-tasks');
9
9
  require('uuid');
10
10
  require('@backstage/catalog-model');
@@ -64,10 +64,9 @@ const ENDPOINT_NODES = "pdb/query/v4/nodes";
64
64
  const DEFAULT_ENTITY_OWNER = "unknown";
65
65
 
66
66
  const defaultResourceTransformer = async (node, _config) => {
67
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
68
67
  const certName = node.certname.toLocaleLowerCase("en-US");
69
- const type = ((_c = (_b = (_a = node.facts) == null ? void 0 : _a.data) == null ? void 0 : _b.find((e) => e.name === "is_virtual")) == null ? void 0 : _c.value) ? "virtual-machine" : "physical-server";
70
- const kernel = (_f = (_e = (_d = node.facts) == null ? void 0 : _d.data) == null ? void 0 : _e.find((e) => e.name === "kernel")) == null ? void 0 : _f.value;
68
+ const type = node.facts?.data?.find((e) => e.name === "is_virtual")?.value ? "virtual-machine" : "physical-server";
69
+ const kernel = node.facts?.data?.find((e) => e.name === "kernel")?.value;
71
70
  const latest_report_status = node.latest_report_status;
72
71
  return {
73
72
  apiVersion: "backstage.io/v1beta1",
@@ -78,7 +77,7 @@ const defaultResourceTransformer = async (node, _config) => {
78
77
  [ANNOTATION_PUPPET_CERTNAME]: certName
79
78
  },
80
79
  namespace: catalogModel.DEFAULT_NAMESPACE,
81
- description: (_j = (_i = (_h = (_g = node.facts) == null ? void 0 : _g.data) == null ? void 0 : _h.find((e) => e.name === "ipaddress")) == null ? void 0 : _i.value) == null ? void 0 : _j.toString(),
80
+ description: node.facts?.data?.find((e) => e.name === "ipaddress")?.value?.toString(),
82
81
  tags: kernel ? [
83
82
  kernel.toString().toLocaleLowerCase("en-US"),
84
83
  latest_report_status.toString().toLocaleLowerCase("en-US")
@@ -94,13 +93,12 @@ const defaultResourceTransformer = async (node, _config) => {
94
93
  };
95
94
 
96
95
  async function readPuppetNodes(config, opts) {
97
- var _a;
98
- const transformFn = (_a = opts == null ? void 0 : opts.transformer) != null ? _a : defaultResourceTransformer;
96
+ const transformFn = opts?.transformer ?? defaultResourceTransformer;
99
97
  const url = new URL(ENDPOINT_FACTSETS, config.baseUrl);
100
98
  if (config.query) {
101
99
  url.searchParams.set("query", config.query);
102
100
  }
103
- if (opts == null ? void 0 : opts.logger) {
101
+ if (opts?.logger) {
104
102
  opts.logger.debug("Reading nodes from PuppetDB", { url: url.toString() });
105
103
  }
106
104
  const response = await fetch__default.default(url.toString(), {
@@ -124,36 +122,12 @@ async function readPuppetNodes(config, opts) {
124
122
  return entities;
125
123
  }
126
124
 
127
- var __defProp = Object.defineProperty;
128
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
129
- var __publicField = (obj, key, value) => {
130
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
131
- return value;
132
- };
133
125
  class PuppetDbEntityProvider {
134
- /**
135
- * Creates an instance of {@link PuppetDbEntityProvider}.
136
- *
137
- * @param config - Configuration of the provider.
138
- * @param logger - The instance of a {@link LoggerService}.
139
- * @param taskRunner - The instance of {@link TaskRunner}.
140
- * @param transformer - A {@link ResourceTransformer} function.
141
- *
142
- * @private
143
- */
144
- constructor(config, logger, taskRunner, transformer) {
145
- __publicField(this, "config");
146
- __publicField(this, "logger");
147
- __publicField(this, "scheduleFn");
148
- __publicField(this, "transformer");
149
- __publicField(this, "connection");
150
- this.config = config;
151
- this.logger = logger.child({
152
- target: this.getProviderName()
153
- });
154
- this.scheduleFn = this.createScheduleFn(taskRunner);
155
- this.transformer = transformer;
156
- }
126
+ config;
127
+ logger;
128
+ scheduleFn;
129
+ transformer;
130
+ connection;
157
131
  /**
158
132
  * Creates instances of {@link PuppetDbEntityProvider} from a configuration.
159
133
  *
@@ -167,14 +141,13 @@ class PuppetDbEntityProvider {
167
141
  throw new Error("Either schedule or scheduler must be provided.");
168
142
  }
169
143
  return readProviderConfigs(config).map((providerConfig) => {
170
- var _a, _b;
171
144
  if (!deps.schedule && !providerConfig.schedule) {
172
145
  throw new Error(
173
146
  `No schedule provided neither via code nor config for puppet-provider:${providerConfig.id}.`
174
147
  );
175
148
  }
176
- const taskRunner = (_a = deps.schedule) != null ? _a : deps.scheduler.createScheduledTaskRunner(providerConfig.schedule);
177
- const transformer = (_b = deps.transformer) != null ? _b : defaultResourceTransformer;
149
+ const taskRunner = deps.schedule ?? deps.scheduler.createScheduledTaskRunner(providerConfig.schedule);
150
+ const transformer = deps.transformer ?? defaultResourceTransformer;
178
151
  return new PuppetDbEntityProvider(
179
152
  providerConfig,
180
153
  deps.logger,
@@ -183,6 +156,24 @@ class PuppetDbEntityProvider {
183
156
  );
184
157
  });
185
158
  }
159
+ /**
160
+ * Creates an instance of {@link PuppetDbEntityProvider}.
161
+ *
162
+ * @param config - Configuration of the provider.
163
+ * @param logger - The instance of a {@link LoggerService}.
164
+ * @param taskRunner - The instance of {@link TaskRunner}.
165
+ * @param transformer - A {@link ResourceTransformer} function.
166
+ *
167
+ * @private
168
+ */
169
+ constructor(config, logger, taskRunner, transformer) {
170
+ this.config = config;
171
+ this.logger = logger.child({
172
+ target: this.getProviderName()
173
+ });
174
+ this.scheduleFn = this.createScheduleFn(taskRunner);
175
+ this.transformer = transformer;
176
+ }
186
177
  /** {@inheritdoc @backstage/plugin-catalog-node#EntityProvider.connect} */
187
178
  async connect(connection) {
188
179
  this.connection = connection;
@@ -248,8 +239,7 @@ class PuppetDbEntityProvider {
248
239
  }
249
240
  }
250
241
  function withLocations(baseUrl, entity) {
251
- var _a;
252
- const location = `${baseUrl}/${ENDPOINT_NODES}/${(_a = entity.metadata) == null ? void 0 : _a.name}`;
242
+ const location = `${baseUrl}/${ENDPOINT_NODES}/${entity.metadata?.name}`;
253
243
  return lodash.merge(
254
244
  {
255
245
  metadata: {
@@ -265,19 +255,17 @@ function withLocations(baseUrl, entity) {
265
255
  function trackProgress(logger) {
266
256
  let timestamp = Date.now();
267
257
  function markReadComplete(entities) {
268
- var _a;
269
258
  const readDuration = ((Date.now() - timestamp) / 1e3).toFixed(1);
270
259
  timestamp = Date.now();
271
260
  logger.info(
272
- `Read ${(_a = entities == null ? void 0 : entities.length) != null ? _a : 0} in ${readDuration} seconds. Committing...`
261
+ `Read ${entities?.length ?? 0} in ${readDuration} seconds. Committing...`
273
262
  );
274
263
  return { markCommitComplete };
275
264
  }
276
265
  function markCommitComplete(entities) {
277
- var _a;
278
266
  const commitDuration = ((Date.now() - timestamp) / 1e3).toFixed(1);
279
267
  logger.info(
280
- `Committed ${(_a = entities == null ? void 0 : entities.length) != null ? _a : 0} in ${commitDuration} seconds.`
268
+ `Committed ${entities?.length ?? 0} in ${commitDuration} seconds.`
281
269
  );
282
270
  }
283
271
  return { markReadComplete };
@@ -287,4 +275,4 @@ exports.ANNOTATION_PUPPET_CERTNAME = ANNOTATION_PUPPET_CERTNAME;
287
275
  exports.DEFAULT_PROVIDER_ID = DEFAULT_PROVIDER_ID;
288
276
  exports.PuppetDbEntityProvider = PuppetDbEntityProvider;
289
277
  exports.defaultResourceTransformer = defaultResourceTransformer;
290
- //# sourceMappingURL=PuppetDbEntityProvider-0YlNSUWD.cjs.js.map
278
+ //# sourceMappingURL=PuppetDbEntityProvider-CJxPJSiY.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PuppetDbEntityProvider-0YlNSUWD.cjs.js","sources":["../../src/providers/constants.ts","../../src/providers/PuppetDbEntityProviderConfig.ts","../../src/puppet/constants.ts","../../src/puppet/transformers.ts","../../src/puppet/read.ts","../../src/providers/PuppetDbEntityProvider.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\n/**\n * Name of the default provider when a using a simple configuration.\n *\n * @public\n */\nexport const DEFAULT_PROVIDER_ID = 'default';\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n readTaskScheduleDefinitionFromConfig,\n TaskScheduleDefinition,\n} from '@backstage/backend-tasks';\nimport { Config } from '@backstage/config';\nimport { DEFAULT_PROVIDER_ID } from './constants';\n\n/**\n * Configuration of {@link PuppetDbEntityProvider}.\n *\n * @public\n */\nexport type PuppetDbEntityProviderConfig = {\n /**\n * ID of the provider.\n */\n id: string;\n /**\n * (Required) The base URL of PuppetDB API instance.\n */\n baseUrl: string;\n /**\n * (Optional) PQL query to filter PuppetDB nodes.\n */\n query?: string;\n /**\n * (Optional) Task schedule definition for the refresh.\n */\n schedule?: TaskScheduleDefinition;\n};\n\n/**\n * Reads the configuration of the PuppetDB Entity Providers.\n *\n * @param config - The application configuration.\n *\n * @returns PuppetDB Entity Provider configurations list.\n */\nexport function readProviderConfigs(\n config: Config,\n): PuppetDbEntityProviderConfig[] {\n const providersConfig = config.getOptionalConfig(\n 'catalog.providers.puppetdb',\n );\n if (!providersConfig) {\n return [];\n }\n\n if (providersConfig.has('baseUrl')) {\n return [readProviderConfig(DEFAULT_PROVIDER_ID, providersConfig)];\n }\n\n return providersConfig.keys().map(id => {\n return readProviderConfig(id, providersConfig.getConfig(id));\n });\n}\n\n/**\n * Reads the configuration for the PuppetDB Entity Provider.\n *\n * @param id - ID of the provider.\n * @param config - The application configuration.\n *\n * @returns The PuppetDB Entity Provider configuration.\n */\nfunction readProviderConfig(\n id: string,\n config: Config,\n): PuppetDbEntityProviderConfig {\n const baseUrl = config.getString('baseUrl').replace(/\\/+$/, '');\n const query = config.getOptionalString('query');\n\n const schedule = config.has('schedule')\n ? readTaskScheduleDefinitionFromConfig(config.getConfig('schedule'))\n : undefined;\n\n return {\n id,\n baseUrl,\n query,\n schedule,\n };\n}\n","/*\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\n/**\n * Annotation for specifying the certificate name of a node in PuppetDB.\n *\n * @public\n */\nexport const ANNOTATION_PUPPET_CERTNAME = 'puppet.com/certname';\n\n/**\n * Path of PuppetDB FactSets endpoint.\n */\nexport const ENDPOINT_FACTSETS = 'pdb/query/v4/factsets';\n\n/**\n * Path of PuppetDB Nodes endpoint.\n */\nexport const ENDPOINT_NODES = 'pdb/query/v4/nodes';\n\n/**\n * Default owner for entities created by the PuppetDB provider.\n *\n * @public\n */\nexport const DEFAULT_ENTITY_OWNER = 'unknown';\n","/*\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 { ResourceTransformer } from './types';\nimport { DEFAULT_NAMESPACE, ResourceEntity } from '@backstage/catalog-model';\nimport { ANNOTATION_PUPPET_CERTNAME, DEFAULT_ENTITY_OWNER } from './constants';\n\n/**\n * A default implementation of the {@link ResourceTransformer}.\n *\n * @param node - The found PuppetDB node entry in its source format. This is the entry that you want to transform.\n * @param _config - The configuration for the entity provider.\n *\n * @returns A `ResourceEntity`.\n *\n * @public\n */\nexport const defaultResourceTransformer: ResourceTransformer = async (\n node,\n _config,\n): Promise<ResourceEntity | undefined> => {\n const certName = node.certname.toLocaleLowerCase('en-US');\n const type = node.facts?.data?.find(e => e.name === 'is_virtual')?.value\n ? 'virtual-machine'\n : 'physical-server';\n const kernel = node.facts?.data?.find(e => e.name === 'kernel')?.value;\n const latest_report_status = node.latest_report_status;\n\n return {\n apiVersion: 'backstage.io/v1beta1',\n kind: 'Resource',\n metadata: {\n name: certName,\n annotations: {\n [ANNOTATION_PUPPET_CERTNAME]: certName,\n },\n namespace: DEFAULT_NAMESPACE,\n description: node.facts?.data\n ?.find(e => e.name === 'ipaddress')\n ?.value?.toString(),\n tags: kernel\n ? [\n kernel.toString().toLocaleLowerCase('en-US'),\n latest_report_status.toString().toLocaleLowerCase('en-US'),\n ]\n : [],\n },\n spec: {\n type: type,\n owner: DEFAULT_ENTITY_OWNER,\n dependsOn: [],\n dependencyOf: [],\n },\n };\n};\n","/*\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 { PuppetDbEntityProviderConfig } from '../providers';\nimport { PuppetNode, ResourceTransformer } from './types';\nimport { ResourceEntity } from '@backstage/catalog-model';\nimport { defaultResourceTransformer } from './transformers';\nimport fetch from 'node-fetch';\nimport { ResponseError } from '@backstage/errors';\nimport { ENDPOINT_FACTSETS } from './constants';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\n/**\n * Reads nodes and their facts from PuppetDB.\n *\n * @param config - The provider configuration.\n * @param opts - Additional options.\n */\nexport async function readPuppetNodes(\n config: PuppetDbEntityProviderConfig,\n opts?: {\n transformer?: ResourceTransformer;\n logger?: LoggerService;\n },\n): Promise<ResourceEntity[]> {\n const transformFn = opts?.transformer ?? defaultResourceTransformer;\n const url = new URL(ENDPOINT_FACTSETS, config.baseUrl);\n\n if (config.query) {\n url.searchParams.set('query', config.query);\n }\n\n if (opts?.logger) {\n opts.logger.debug('Reading nodes from PuppetDB', { url: url.toString() });\n }\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n },\n });\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n const nodes = (await response.json()) as PuppetNode[];\n const entities: ResourceEntity[] = [];\n\n for (const node of nodes) {\n const entity = await transformFn(node, config);\n if (entity) {\n entities.push(entity);\n }\n }\n\n return entities;\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n EntityProvider,\n EntityProviderConnection,\n} from '@backstage/plugin-catalog-node';\nimport {\n PuppetDbEntityProviderConfig,\n readProviderConfigs,\n} from './PuppetDbEntityProviderConfig';\nimport { Config } from '@backstage/config';\nimport { PluginTaskScheduler, TaskRunner } from '@backstage/backend-tasks';\nimport * as uuid from 'uuid';\nimport { defaultResourceTransformer, ResourceTransformer } from '../puppet';\nimport {\n ANNOTATION_LOCATION,\n ANNOTATION_ORIGIN_LOCATION,\n Entity,\n} from '@backstage/catalog-model';\nimport { merge } from 'lodash';\nimport { readPuppetNodes } from '../puppet/read';\nimport { ENDPOINT_NODES } from '../puppet/constants';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\n/**\n * Reads nodes from [PuppetDB](https://www.puppet.com/docs/puppet/6/puppetdb_overview.html)\n * based on the provided query and registers them as Resource entities in the catalog.\n *\n * @public\n */\nexport class PuppetDbEntityProvider implements EntityProvider {\n private readonly config: PuppetDbEntityProviderConfig;\n private readonly logger: LoggerService;\n private readonly scheduleFn: () => Promise<void>;\n private readonly transformer: ResourceTransformer;\n private connection?: EntityProviderConnection;\n\n /**\n * Creates instances of {@link PuppetDbEntityProvider} from a configuration.\n *\n * @param config - The configuration to read provider information from.\n * @param deps - The dependencies for {@link PuppetDbEntityProvider}.\n *\n * @returns A list of {@link PuppetDbEntityProvider} instances.\n */\n static fromConfig(\n config: Config,\n deps: {\n logger: LoggerService;\n schedule?: TaskRunner;\n scheduler?: PluginTaskScheduler;\n transformer?: ResourceTransformer;\n },\n ): PuppetDbEntityProvider[] {\n if (!deps.schedule && !deps.scheduler) {\n throw new Error('Either schedule or scheduler must be provided.');\n }\n\n return readProviderConfigs(config).map(providerConfig => {\n if (!deps.schedule && !providerConfig.schedule) {\n throw new Error(\n `No schedule provided neither via code nor config for puppet-provider:${providerConfig.id}.`,\n );\n }\n\n const taskRunner =\n deps.schedule ??\n deps.scheduler!.createScheduledTaskRunner(providerConfig.schedule!);\n\n const transformer = deps.transformer ?? defaultResourceTransformer;\n\n return new PuppetDbEntityProvider(\n providerConfig,\n deps.logger,\n taskRunner,\n transformer,\n );\n });\n }\n\n /**\n * Creates an instance of {@link PuppetDbEntityProvider}.\n *\n * @param config - Configuration of the provider.\n * @param logger - The instance of a {@link LoggerService}.\n * @param taskRunner - The instance of {@link TaskRunner}.\n * @param transformer - A {@link ResourceTransformer} function.\n *\n * @private\n */\n private constructor(\n config: PuppetDbEntityProviderConfig,\n logger: LoggerService,\n taskRunner: TaskRunner,\n transformer: ResourceTransformer,\n ) {\n this.config = config;\n this.logger = logger.child({\n target: this.getProviderName(),\n });\n this.scheduleFn = this.createScheduleFn(taskRunner);\n this.transformer = transformer;\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-node#EntityProvider.connect} */\n async connect(connection: EntityProviderConnection): Promise<void> {\n this.connection = connection;\n await this.scheduleFn();\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-node#EntityProvider.getProviderName} */\n getProviderName(): string {\n return `puppetdb-provider:${this.config.id}`;\n }\n\n /**\n * Creates a function that can be used to schedule a refresh of the catalog.\n *\n * @param taskRunner - The instance of {@link TaskRunner}.\n *\n * @private\n */\n private createScheduleFn(taskRunner: TaskRunner): () => Promise<void> {\n return async () => {\n const taskId = `${this.getProviderName()}:refresh`;\n return taskRunner.run({\n id: taskId,\n fn: async () => {\n const logger = this.logger.child({\n class: PuppetDbEntityProvider.prototype.constructor.name,\n taskId,\n taskInstanceId: uuid.v4(),\n });\n try {\n await this.refresh(logger);\n } catch (error) {\n logger.error(\n `${this.getProviderName()} refresh failed, ${error}`,\n error,\n );\n }\n },\n });\n };\n }\n\n /**\n * Refreshes the catalog by reading nodes from PuppetDB and registering them as Resource Entities.\n *\n * @param logger - The instance of a Logger.\n */\n async refresh(logger: LoggerService) {\n if (!this.connection) {\n throw new Error('Not initialized');\n }\n\n const { markReadComplete } = trackProgress(logger);\n const entities = await readPuppetNodes(this.config, {\n logger,\n transformer: this.transformer,\n });\n const { markCommitComplete } = markReadComplete(entities);\n\n await this.connection.applyMutation({\n type: 'full',\n entities: [...entities].map(entity => ({\n locationKey: this.getProviderName(),\n entity: withLocations(this.config.baseUrl, entity),\n })),\n });\n markCommitComplete(entities);\n }\n}\n\n/**\n * Ensures the entities have required annotation data.\n *\n * @param baseUrl - The base URL of the PuppetDB instance.\n * @param entity - The entity to add the annotations to.\n *\n * @returns Entity with @{@link ANNOTATION_LOCATION} and @{@link ANNOTATION_ORIGIN_LOCATION} annotations.\n */\nfunction withLocations(baseUrl: string, entity: Entity): Entity {\n const location = `${baseUrl}/${ENDPOINT_NODES}/${entity.metadata?.name}`;\n\n return merge(\n {\n metadata: {\n annotations: {\n [ANNOTATION_LOCATION]: `url:${location}`,\n [ANNOTATION_ORIGIN_LOCATION]: `url:${location}`,\n },\n },\n },\n entity,\n ) as Entity;\n}\n\n/**\n * Tracks the progress of the PuppetDB read and commit operations.\n *\n * @param logger - The instance of a {@link LoggerService}.\n */\nfunction trackProgress(logger: LoggerService) {\n let timestamp = Date.now();\n\n function markReadComplete(entities: Entity[]) {\n const readDuration = ((Date.now() - timestamp) / 1000).toFixed(1);\n timestamp = Date.now();\n logger.info(\n `Read ${entities?.length ?? 0} in ${readDuration} seconds. Committing...`,\n );\n return { markCommitComplete };\n }\n\n function markCommitComplete(entities: Entity[]) {\n const commitDuration = ((Date.now() - timestamp) / 1000).toFixed(1);\n logger.info(\n `Committed ${entities?.length ?? 0} in ${commitDuration} seconds.`,\n );\n }\n\n return { markReadComplete };\n}\n"],"names":["readTaskScheduleDefinitionFromConfig","DEFAULT_NAMESPACE","fetch","ResponseError","uuid","merge","ANNOTATION_LOCATION","ANNOTATION_ORIGIN_LOCATION"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBO,MAAM,mBAAsB,GAAA;;ACiC5B,SAAS,oBACd,MACgC,EAAA;AAChC,EAAA,MAAM,kBAAkB,MAAO,CAAA,iBAAA;AAAA,IAC7B,4BAAA;AAAA,GACF,CAAA;AACA,EAAA,IAAI,CAAC,eAAiB,EAAA;AACpB,IAAA,OAAO,EAAC,CAAA;AAAA,GACV;AAEA,EAAI,IAAA,eAAA,CAAgB,GAAI,CAAA,SAAS,CAAG,EAAA;AAClC,IAAA,OAAO,CAAC,kBAAA,CAAmB,mBAAqB,EAAA,eAAe,CAAC,CAAA,CAAA;AAAA,GAClE;AAEA,EAAA,OAAO,eAAgB,CAAA,IAAA,EAAO,CAAA,GAAA,CAAI,CAAM,EAAA,KAAA;AACtC,IAAA,OAAO,kBAAmB,CAAA,E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B,IAAO,MAAA,CAAA,IAAA;AAAA,MACL,SAAQ,EAAU,GAAA,QAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,QAAA,CAAA,MAAA,KAAV,IAAoB,GAAA,EAAA,GAAA,CAAC,OAAO,YAAY,CAAA,uBAAA,CAAA;AAAA,KAClD,CAAA;AACA,IAAA,OAAO,EAAE,kBAAmB,EAAA,CAAA;AAAA,GAC9B;AAEA,EAAA,SAAS,mBAAmB,QAAoB,EAAA;AArOlD,IAAA,IAAA,EAAA,CAAA;AAsOI,IAAA,MAAM,mBAAmB,IAAK,CAAA,GAAA,KAAQ,SAAa,IAAA,GAAA,EAAM,QAAQ,CAAC,CAAA,CAAA;AAClE,IAAO,MAAA,CAAA,IAAA;AAAA,MACL,cAAa,EAAU,GAAA,QAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,QAAA,CAAA,MAAA,KAAV,IAAoB,GAAA,EAAA,GAAA,CAAC,OAAO,cAAc,CAAA,SAAA,CAAA;AAAA,KACzD,CAAA;AAAA,GACF;AAEA,EAAA,OAAO,EAAE,gBAAiB,EAAA,CAAA;AAC5B;;;;;;;"}
1
+ {"version":3,"file":"PuppetDbEntityProvider-CJxPJSiY.cjs.js","sources":["../../src/providers/constants.ts","../../src/providers/PuppetDbEntityProviderConfig.ts","../../src/puppet/constants.ts","../../src/puppet/transformers.ts","../../src/puppet/read.ts","../../src/providers/PuppetDbEntityProvider.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\n/**\n * Name of the default provider when a using a simple configuration.\n *\n * @public\n */\nexport const DEFAULT_PROVIDER_ID = 'default';\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n readTaskScheduleDefinitionFromConfig,\n TaskScheduleDefinition,\n} from '@backstage/backend-tasks';\nimport { Config } from '@backstage/config';\nimport { DEFAULT_PROVIDER_ID } from './constants';\n\n/**\n * Configuration of {@link PuppetDbEntityProvider}.\n *\n * @public\n */\nexport type PuppetDbEntityProviderConfig = {\n /**\n * ID of the provider.\n */\n id: string;\n /**\n * (Required) The base URL of PuppetDB API instance.\n */\n baseUrl: string;\n /**\n * (Optional) PQL query to filter PuppetDB nodes.\n */\n query?: string;\n /**\n * (Optional) Task schedule definition for the refresh.\n */\n schedule?: TaskScheduleDefinition;\n};\n\n/**\n * Reads the configuration of the PuppetDB Entity Providers.\n *\n * @param config - The application configuration.\n *\n * @returns PuppetDB Entity Provider configurations list.\n */\nexport function readProviderConfigs(\n config: Config,\n): PuppetDbEntityProviderConfig[] {\n const providersConfig = config.getOptionalConfig(\n 'catalog.providers.puppetdb',\n );\n if (!providersConfig) {\n return [];\n }\n\n if (providersConfig.has('baseUrl')) {\n return [readProviderConfig(DEFAULT_PROVIDER_ID, providersConfig)];\n }\n\n return providersConfig.keys().map(id => {\n return readProviderConfig(id, providersConfig.getConfig(id));\n });\n}\n\n/**\n * Reads the configuration for the PuppetDB Entity Provider.\n *\n * @param id - ID of the provider.\n * @param config - The application configuration.\n *\n * @returns The PuppetDB Entity Provider configuration.\n */\nfunction readProviderConfig(\n id: string,\n config: Config,\n): PuppetDbEntityProviderConfig {\n const baseUrl = config.getString('baseUrl').replace(/\\/+$/, '');\n const query = config.getOptionalString('query');\n\n const schedule = config.has('schedule')\n ? readTaskScheduleDefinitionFromConfig(config.getConfig('schedule'))\n : undefined;\n\n return {\n id,\n baseUrl,\n query,\n schedule,\n };\n}\n","/*\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\n/**\n * Annotation for specifying the certificate name of a node in PuppetDB.\n *\n * @public\n */\nexport const ANNOTATION_PUPPET_CERTNAME = 'puppet.com/certname';\n\n/**\n * Path of PuppetDB FactSets endpoint.\n */\nexport const ENDPOINT_FACTSETS = 'pdb/query/v4/factsets';\n\n/**\n * Path of PuppetDB Nodes endpoint.\n */\nexport const ENDPOINT_NODES = 'pdb/query/v4/nodes';\n\n/**\n * Default owner for entities created by the PuppetDB provider.\n *\n * @public\n */\nexport const DEFAULT_ENTITY_OWNER = 'unknown';\n","/*\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 { ResourceTransformer } from './types';\nimport { DEFAULT_NAMESPACE, ResourceEntity } from '@backstage/catalog-model';\nimport { ANNOTATION_PUPPET_CERTNAME, DEFAULT_ENTITY_OWNER } from './constants';\n\n/**\n * A default implementation of the {@link ResourceTransformer}.\n *\n * @param node - The found PuppetDB node entry in its source format. This is the entry that you want to transform.\n * @param _config - The configuration for the entity provider.\n *\n * @returns A `ResourceEntity`.\n *\n * @public\n */\nexport const defaultResourceTransformer: ResourceTransformer = async (\n node,\n _config,\n): Promise<ResourceEntity | undefined> => {\n const certName = node.certname.toLocaleLowerCase('en-US');\n const type = node.facts?.data?.find(e => e.name === 'is_virtual')?.value\n ? 'virtual-machine'\n : 'physical-server';\n const kernel = node.facts?.data?.find(e => e.name === 'kernel')?.value;\n const latest_report_status = node.latest_report_status;\n\n return {\n apiVersion: 'backstage.io/v1beta1',\n kind: 'Resource',\n metadata: {\n name: certName,\n annotations: {\n [ANNOTATION_PUPPET_CERTNAME]: certName,\n },\n namespace: DEFAULT_NAMESPACE,\n description: node.facts?.data\n ?.find(e => e.name === 'ipaddress')\n ?.value?.toString(),\n tags: kernel\n ? [\n kernel.toString().toLocaleLowerCase('en-US'),\n latest_report_status.toString().toLocaleLowerCase('en-US'),\n ]\n : [],\n },\n spec: {\n type: type,\n owner: DEFAULT_ENTITY_OWNER,\n dependsOn: [],\n dependencyOf: [],\n },\n };\n};\n","/*\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 { PuppetDbEntityProviderConfig } from '../providers';\nimport { PuppetNode, ResourceTransformer } from './types';\nimport { ResourceEntity } from '@backstage/catalog-model';\nimport { defaultResourceTransformer } from './transformers';\nimport fetch from 'node-fetch';\nimport { ResponseError } from '@backstage/errors';\nimport { ENDPOINT_FACTSETS } from './constants';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\n/**\n * Reads nodes and their facts from PuppetDB.\n *\n * @param config - The provider configuration.\n * @param opts - Additional options.\n */\nexport async function readPuppetNodes(\n config: PuppetDbEntityProviderConfig,\n opts?: {\n transformer?: ResourceTransformer;\n logger?: LoggerService;\n },\n): Promise<ResourceEntity[]> {\n const transformFn = opts?.transformer ?? defaultResourceTransformer;\n const url = new URL(ENDPOINT_FACTSETS, config.baseUrl);\n\n if (config.query) {\n url.searchParams.set('query', config.query);\n }\n\n if (opts?.logger) {\n opts.logger.debug('Reading nodes from PuppetDB', { url: url.toString() });\n }\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n },\n });\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n const nodes = (await response.json()) as PuppetNode[];\n const entities: ResourceEntity[] = [];\n\n for (const node of nodes) {\n const entity = await transformFn(node, config);\n if (entity) {\n entities.push(entity);\n }\n }\n\n return entities;\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n EntityProvider,\n EntityProviderConnection,\n} from '@backstage/plugin-catalog-node';\nimport {\n PuppetDbEntityProviderConfig,\n readProviderConfigs,\n} from './PuppetDbEntityProviderConfig';\nimport { Config } from '@backstage/config';\nimport { PluginTaskScheduler, TaskRunner } from '@backstage/backend-tasks';\nimport * as uuid from 'uuid';\nimport { defaultResourceTransformer, ResourceTransformer } from '../puppet';\nimport {\n ANNOTATION_LOCATION,\n ANNOTATION_ORIGIN_LOCATION,\n Entity,\n} from '@backstage/catalog-model';\nimport { merge } from 'lodash';\nimport { readPuppetNodes } from '../puppet/read';\nimport { ENDPOINT_NODES } from '../puppet/constants';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\n/**\n * Reads nodes from [PuppetDB](https://www.puppet.com/docs/puppet/6/puppetdb_overview.html)\n * based on the provided query and registers them as Resource entities in the catalog.\n *\n * @public\n */\nexport class PuppetDbEntityProvider implements EntityProvider {\n private readonly config: PuppetDbEntityProviderConfig;\n private readonly logger: LoggerService;\n private readonly scheduleFn: () => Promise<void>;\n private readonly transformer: ResourceTransformer;\n private connection?: EntityProviderConnection;\n\n /**\n * Creates instances of {@link PuppetDbEntityProvider} from a configuration.\n *\n * @param config - The configuration to read provider information from.\n * @param deps - The dependencies for {@link PuppetDbEntityProvider}.\n *\n * @returns A list of {@link PuppetDbEntityProvider} instances.\n */\n static fromConfig(\n config: Config,\n deps: {\n logger: LoggerService;\n schedule?: TaskRunner;\n scheduler?: PluginTaskScheduler;\n transformer?: ResourceTransformer;\n },\n ): PuppetDbEntityProvider[] {\n if (!deps.schedule && !deps.scheduler) {\n throw new Error('Either schedule or scheduler must be provided.');\n }\n\n return readProviderConfigs(config).map(providerConfig => {\n if (!deps.schedule && !providerConfig.schedule) {\n throw new Error(\n `No schedule provided neither via code nor config for puppet-provider:${providerConfig.id}.`,\n );\n }\n\n const taskRunner =\n deps.schedule ??\n deps.scheduler!.createScheduledTaskRunner(providerConfig.schedule!);\n\n const transformer = deps.transformer ?? defaultResourceTransformer;\n\n return new PuppetDbEntityProvider(\n providerConfig,\n deps.logger,\n taskRunner,\n transformer,\n );\n });\n }\n\n /**\n * Creates an instance of {@link PuppetDbEntityProvider}.\n *\n * @param config - Configuration of the provider.\n * @param logger - The instance of a {@link LoggerService}.\n * @param taskRunner - The instance of {@link TaskRunner}.\n * @param transformer - A {@link ResourceTransformer} function.\n *\n * @private\n */\n private constructor(\n config: PuppetDbEntityProviderConfig,\n logger: LoggerService,\n taskRunner: TaskRunner,\n transformer: ResourceTransformer,\n ) {\n this.config = config;\n this.logger = logger.child({\n target: this.getProviderName(),\n });\n this.scheduleFn = this.createScheduleFn(taskRunner);\n this.transformer = transformer;\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-node#EntityProvider.connect} */\n async connect(connection: EntityProviderConnection): Promise<void> {\n this.connection = connection;\n await this.scheduleFn();\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-node#EntityProvider.getProviderName} */\n getProviderName(): string {\n return `puppetdb-provider:${this.config.id}`;\n }\n\n /**\n * Creates a function that can be used to schedule a refresh of the catalog.\n *\n * @param taskRunner - The instance of {@link TaskRunner}.\n *\n * @private\n */\n private createScheduleFn(taskRunner: TaskRunner): () => Promise<void> {\n return async () => {\n const taskId = `${this.getProviderName()}:refresh`;\n return taskRunner.run({\n id: taskId,\n fn: async () => {\n const logger = this.logger.child({\n class: PuppetDbEntityProvider.prototype.constructor.name,\n taskId,\n taskInstanceId: uuid.v4(),\n });\n try {\n await this.refresh(logger);\n } catch (error) {\n logger.error(\n `${this.getProviderName()} refresh failed, ${error}`,\n error,\n );\n }\n },\n });\n };\n }\n\n /**\n * Refreshes the catalog by reading nodes from PuppetDB and registering them as Resource Entities.\n *\n * @param logger - The instance of a Logger.\n */\n async refresh(logger: LoggerService) {\n if (!this.connection) {\n throw new Error('Not initialized');\n }\n\n const { markReadComplete } = trackProgress(logger);\n const entities = await readPuppetNodes(this.config, {\n logger,\n transformer: this.transformer,\n });\n const { markCommitComplete } = markReadComplete(entities);\n\n await this.connection.applyMutation({\n type: 'full',\n entities: [...entities].map(entity => ({\n locationKey: this.getProviderName(),\n entity: withLocations(this.config.baseUrl, entity),\n })),\n });\n markCommitComplete(entities);\n }\n}\n\n/**\n * Ensures the entities have required annotation data.\n *\n * @param baseUrl - The base URL of the PuppetDB instance.\n * @param entity - The entity to add the annotations to.\n *\n * @returns Entity with @{@link ANNOTATION_LOCATION} and @{@link ANNOTATION_ORIGIN_LOCATION} annotations.\n */\nfunction withLocations(baseUrl: string, entity: Entity): Entity {\n const location = `${baseUrl}/${ENDPOINT_NODES}/${entity.metadata?.name}`;\n\n return merge(\n {\n metadata: {\n annotations: {\n [ANNOTATION_LOCATION]: `url:${location}`,\n [ANNOTATION_ORIGIN_LOCATION]: `url:${location}`,\n },\n },\n },\n entity,\n ) as Entity;\n}\n\n/**\n * Tracks the progress of the PuppetDB read and commit operations.\n *\n * @param logger - The instance of a {@link LoggerService}.\n */\nfunction trackProgress(logger: LoggerService) {\n let timestamp = Date.now();\n\n function markReadComplete(entities: Entity[]) {\n const readDuration = ((Date.now() - timestamp) / 1000).toFixed(1);\n timestamp = Date.now();\n logger.info(\n `Read ${entities?.length ?? 0} in ${readDuration} seconds. Committing...`,\n );\n return { markCommitComplete };\n }\n\n function markCommitComplete(entities: Entity[]) {\n const commitDuration = ((Date.now() - timestamp) / 1000).toFixed(1);\n logger.info(\n `Committed ${entities?.length ?? 0} in ${commitDuration} seconds.`,\n );\n }\n\n return { markReadComplete };\n}\n"],"names":["readTaskScheduleDefinitionFromConfig","DEFAULT_NAMESPACE","fetch","ResponseError","uuid","merge","ANNOTATION_LOCATION","ANNOTATION_ORIGIN_LOCATION"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBO,MAAM,mBAAsB,GAAA;;ACiC5B,SAAS,oBACd,MACgC,EAAA;AAChC,EAAA,MAAM,kBAAkB,MAAO,CAAA,iBAAA;AAAA,IAC7B,4BAAA;AAAA,GACF,CAAA;AACA,EAAA,IAAI,CAAC,eAAiB,EAAA;AACpB,IAAA,OAAO,EAAC,CAAA;AAAA,GACV;AAEA,EAAI,IAAA,eAAA,CAAgB,GAAI,CAAA,SAAS,CAAG,EAAA;AAClC,IAAA,OAAO,CAAC,kBAAA,CAAmB,mBAAqB,EAAA,eAAe,CAAC,CAAA,CAAA;AAAA,GAClE;AAEA,EAAA,OAAO,eAAgB,CAAA,IAAA,EAAO,CAAA,GAAA,CAAI,CAAM,EAAA,KAAA;AACtC,IAAA,OAAO,kBAAmB,CAAA,EAAA,EAAI,eAAgB,C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Y,CAAA,uBAAA,CAAA;AAAA,KAClD,CAAA;AACA,IAAA,OAAO,EAAE,kBAAmB,EAAA,CAAA;AAAA,GAC9B;AAEA,EAAA,SAAS,mBAAmB,QAAoB,EAAA;AAC9C,IAAA,MAAM,mBAAmB,IAAK,CAAA,GAAA,KAAQ,SAAa,IAAA,GAAA,EAAM,QAAQ,CAAC,CAAA,CAAA;AAClE,IAAO,MAAA,CAAA,IAAA;AAAA,MACL,CAAa,UAAA,EAAA,QAAA,EAAU,MAAU,IAAA,CAAC,OAAO,cAAc,CAAA,SAAA,CAAA;AAAA,KACzD,CAAA;AAAA,GACF;AAEA,EAAA,OAAO,EAAE,gBAAiB,EAAA,CAAA;AAC5B;;;;;;;"}
package/dist/index.cjs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var PuppetDbEntityProvider = require('./cjs/PuppetDbEntityProvider-0YlNSUWD.cjs.js');
3
+ var PuppetDbEntityProvider = require('./cjs/PuppetDbEntityProvider-CJxPJSiY.cjs.js');
4
4
  require('@backstage/backend-tasks');
5
5
  require('uuid');
6
6
  require('@backstage/catalog-model');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend-module-puppetdb",
3
- "version": "0.1.24-next.2",
3
+ "version": "0.1.25-next.0",
4
4
  "description": "A Backstage catalog backend module that helps integrate towards PuppetDB",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module"
@@ -50,13 +50,13 @@
50
50
  "test": "backstage-cli package test"
51
51
  },
52
52
  "dependencies": {
53
- "@backstage/backend-common": "^0.22.0-next.2",
54
- "@backstage/backend-plugin-api": "^0.6.18-next.1",
55
- "@backstage/backend-tasks": "^0.5.23-next.1",
56
- "@backstage/catalog-model": "^1.5.0-next.0",
53
+ "@backstage/backend-common": "^0.22.1-next.0",
54
+ "@backstage/backend-plugin-api": "^0.6.19-next.0",
55
+ "@backstage/backend-tasks": "^0.5.24-next.0",
56
+ "@backstage/catalog-model": "^1.5.0",
57
57
  "@backstage/config": "^1.2.0",
58
58
  "@backstage/errors": "^1.2.4",
59
- "@backstage/plugin-catalog-node": "^1.12.0-next.2",
59
+ "@backstage/plugin-catalog-node": "^1.12.1-next.0",
60
60
  "@backstage/types": "^1.1.1",
61
61
  "lodash": "^4.17.21",
62
62
  "luxon": "^3.0.0",
@@ -64,8 +64,8 @@
64
64
  "uuid": "^9.0.0"
65
65
  },
66
66
  "devDependencies": {
67
- "@backstage/backend-test-utils": "^0.3.8-next.2",
68
- "@backstage/cli": "^0.26.5-next.1",
67
+ "@backstage/backend-test-utils": "^0.3.9-next.0",
68
+ "@backstage/cli": "^0.26.6-next.0",
69
69
  "@types/lodash": "^4.14.151",
70
70
  "msw": "^1.0.0"
71
71
  },