@flatfile/listener 0.3.12 → 0.3.14

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/dist/index.d.ts CHANGED
@@ -73,6 +73,14 @@ declare class FlatfileEvent extends AuthenticatedClient {
73
73
  private afterAllCallbacks;
74
74
  afterAll<T>(callback: () => T, cacheKey?: string): void;
75
75
  update(records: RecordsWithLinks): Promise<void>;
76
+ /**
77
+ * Fetch the Secrets as indicated by this event context
78
+ *
79
+ * @param key - The name of the secret to fetch
80
+ * @param options - (Optional) environmentId and spaceId to override event context
81
+ *
82
+ * @returns The value of the secret (usually a credential or token)
83
+ */
76
84
  secrets(key: string, options?: {
77
85
  environmentId?: string;
78
86
  spaceId?: string;
package/dist/index.js CHANGED
@@ -266,7 +266,6 @@ var FlatfileEvent = class extends AuthenticatedClient {
266
266
  async fetchData(options) {
267
267
  const dataUrl = new URLSearchParams(this.src.dataUrl);
268
268
  if (options) {
269
- dataUrl.set("includeCounts", "true");
270
269
  for (const [key, values] of Object.entries(options)) {
271
270
  if (Array.isArray(values)) {
272
271
  for (const value of values) {
@@ -304,12 +303,26 @@ var FlatfileEvent = class extends AuthenticatedClient {
304
303
  data: records
305
304
  });
306
305
  }
306
+ /**
307
+ * Fetch the Secrets as indicated by this event context
308
+ *
309
+ * @param key - The name of the secret to fetch
310
+ * @param options - (Optional) environmentId and spaceId to override event context
311
+ *
312
+ * @returns The value of the secret (usually a credential or token)
313
+ */
307
314
  async secrets(key, options) {
308
- const environmentId = options?.environmentId || this.context.environmentId;
315
+ const environmentId = options?.environmentId || this.context.environmentId || "";
316
+ const spaceId = options?.spaceId || this.context.spaceId || "";
317
+ if (!environmentId) {
318
+ throw new Error("environmentId is required to fetch secrets");
319
+ }
320
+ let getSecrets = `v1/secrets?environmentId=${environmentId}`;
321
+ if (spaceId) {
322
+ getSecrets += `&spaceId=${spaceId}`;
323
+ }
309
324
  const secrets = await this.cache.init("secrets", async () => {
310
- const secretsResponse = await this.fetch(
311
- `v1/secrets?environmentId=${environmentId}${options?.spaceId ? `&spaceId=${options.spaceId}` : ""}`
312
- );
325
+ const secretsResponse = await this.fetch(getSecrets);
313
326
  const SecretMap = /* @__PURE__ */ new Map();
314
327
  secretsResponse.forEach((secret) => {
315
328
  SecretMap.set(secret.name, secret.value);
package/dist/index.mjs CHANGED
@@ -223,7 +223,6 @@ var FlatfileEvent = class extends AuthenticatedClient {
223
223
  async fetchData(options) {
224
224
  const dataUrl = new URLSearchParams(this.src.dataUrl);
225
225
  if (options) {
226
- dataUrl.set("includeCounts", "true");
227
226
  for (const [key, values] of Object.entries(options)) {
228
227
  if (Array.isArray(values)) {
229
228
  for (const value of values) {
@@ -261,12 +260,26 @@ var FlatfileEvent = class extends AuthenticatedClient {
261
260
  data: records
262
261
  });
263
262
  }
263
+ /**
264
+ * Fetch the Secrets as indicated by this event context
265
+ *
266
+ * @param key - The name of the secret to fetch
267
+ * @param options - (Optional) environmentId and spaceId to override event context
268
+ *
269
+ * @returns The value of the secret (usually a credential or token)
270
+ */
264
271
  async secrets(key, options) {
265
- const environmentId = options?.environmentId || this.context.environmentId;
272
+ const environmentId = options?.environmentId || this.context.environmentId || "";
273
+ const spaceId = options?.spaceId || this.context.spaceId || "";
274
+ if (!environmentId) {
275
+ throw new Error("environmentId is required to fetch secrets");
276
+ }
277
+ let getSecrets = `v1/secrets?environmentId=${environmentId}`;
278
+ if (spaceId) {
279
+ getSecrets += `&spaceId=${spaceId}`;
280
+ }
266
281
  const secrets = await this.cache.init("secrets", async () => {
267
- const secretsResponse = await this.fetch(
268
- `v1/secrets?environmentId=${environmentId}${options?.spaceId ? `&spaceId=${options.spaceId}` : ""}`
269
- );
282
+ const secretsResponse = await this.fetch(getSecrets);
270
283
  const SecretMap = /* @__PURE__ */ new Map();
271
284
  secretsResponse.forEach((secret) => {
272
285
  SecretMap.set(secret.name, secret.value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatfile/listener",
3
- "version": "0.3.12",
3
+ "version": "0.3.14",
4
4
  "description": "A PubSub Listener for configuring and using Flatfile",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",