@flatfile/listener
Advanced tools
Comparing version 0.3.13 to 0.3.14
@@ -76,2 +76,10 @@ import { Event, RecordsWithLinks } from '@flatfile/api/api'; | ||
update(records: RecordsWithLinks): Promise<void>; | ||
/** | ||
* Fetch the Secrets as indicated by this event context | ||
* | ||
* @param key - The name of the secret to fetch | ||
* @param options - (Optional) environmentId and spaceId to override event context | ||
* | ||
* @returns The value of the secret (usually a credential or token) | ||
*/ | ||
secrets(key: string, options?: { | ||
@@ -78,0 +86,0 @@ environmentId?: string; |
@@ -306,8 +306,22 @@ "use strict"; | ||
} | ||
/** | ||
* Fetch the Secrets as indicated by this event context | ||
* | ||
* @param key - The name of the secret to fetch | ||
* @param options - (Optional) environmentId and spaceId to override event context | ||
* | ||
* @returns The value of the secret (usually a credential or token) | ||
*/ | ||
async secrets(key, options) { | ||
const environmentId = options?.environmentId || this.context.environmentId; | ||
const environmentId = options?.environmentId || this.context.environmentId || ""; | ||
const spaceId = options?.spaceId || this.context.spaceId || ""; | ||
if (!environmentId) { | ||
throw new Error("environmentId is required to fetch secrets"); | ||
} | ||
let getSecrets = `v1/secrets?environmentId=${environmentId}`; | ||
if (spaceId) { | ||
getSecrets += `&spaceId=${spaceId}`; | ||
} | ||
const secrets = await this.cache.init("secrets", async () => { | ||
const secretsResponse = await this.fetch( | ||
`v1/secrets?environmentId=${environmentId}${options?.spaceId ? `&spaceId=${options.spaceId}` : ""}` | ||
); | ||
const secretsResponse = await this.fetch(getSecrets); | ||
const SecretMap = /* @__PURE__ */ new Map(); | ||
@@ -314,0 +328,0 @@ secretsResponse.forEach((secret) => { |
{ | ||
"name": "@flatfile/listener", | ||
"version": "0.3.13", | ||
"version": "0.3.14", | ||
"description": "A PubSub Listener for configuring and using Flatfile", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52585
1710