@flatfile/listener 0.3.13 → 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 +8 -0
- package/dist/index.js +18 -4
- package/dist/index.mjs +18 -4
- package/package.json +1 -1
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
|
@@ -303,12 +303,26 @@ var FlatfileEvent = class extends AuthenticatedClient {
|
|
|
303
303
|
data: records
|
|
304
304
|
});
|
|
305
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
|
+
*/
|
|
306
314
|
async secrets(key, options) {
|
|
307
|
-
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
|
+
}
|
|
308
324
|
const secrets = await this.cache.init("secrets", async () => {
|
|
309
|
-
const secretsResponse = await this.fetch(
|
|
310
|
-
`v1/secrets?environmentId=${environmentId}${options?.spaceId ? `&spaceId=${options.spaceId}` : ""}`
|
|
311
|
-
);
|
|
325
|
+
const secretsResponse = await this.fetch(getSecrets);
|
|
312
326
|
const SecretMap = /* @__PURE__ */ new Map();
|
|
313
327
|
secretsResponse.forEach((secret) => {
|
|
314
328
|
SecretMap.set(secret.name, secret.value);
|
package/dist/index.mjs
CHANGED
|
@@ -260,12 +260,26 @@ var FlatfileEvent = class extends AuthenticatedClient {
|
|
|
260
260
|
data: records
|
|
261
261
|
});
|
|
262
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
|
+
*/
|
|
263
271
|
async secrets(key, options) {
|
|
264
|
-
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
|
+
}
|
|
265
281
|
const secrets = await this.cache.init("secrets", async () => {
|
|
266
|
-
const secretsResponse = await this.fetch(
|
|
267
|
-
`v1/secrets?environmentId=${environmentId}${options?.spaceId ? `&spaceId=${options.spaceId}` : ""}`
|
|
268
|
-
);
|
|
282
|
+
const secretsResponse = await this.fetch(getSecrets);
|
|
269
283
|
const SecretMap = /* @__PURE__ */ new Map();
|
|
270
284
|
secretsResponse.forEach((secret) => {
|
|
271
285
|
SecretMap.set(secret.name, secret.value);
|