@lazyenv/doppler 0.2.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/LICENSE +21 -0
- package/dist/index.cjs +276 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +121 -0
- package/dist/index.d.ts +121 -0
- package/dist/index.js +238 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 methodacting
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
DopplerStore: () => DopplerStore,
|
|
34
|
+
DopplerStoreAdmin: () => DopplerStoreAdmin
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
37
|
+
|
|
38
|
+
// src/store.ts
|
|
39
|
+
var import_node_sdk = __toESM(require("@dopplerhq/node-sdk"), 1);
|
|
40
|
+
var import_core = require("@lazyenv/core");
|
|
41
|
+
var DopplerStore = class {
|
|
42
|
+
name = "doppler";
|
|
43
|
+
sdk;
|
|
44
|
+
isRecord(value) {
|
|
45
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
46
|
+
}
|
|
47
|
+
getSecretValue(value) {
|
|
48
|
+
if (!this.isRecord(value)) return void 0;
|
|
49
|
+
const computed = value.computed;
|
|
50
|
+
if (typeof computed === "string" && computed.length > 0) return computed;
|
|
51
|
+
const raw = value.raw;
|
|
52
|
+
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Create a new Doppler secret store
|
|
57
|
+
*
|
|
58
|
+
* Uses DOPPLER_TOKEN environment variable for authentication.
|
|
59
|
+
*
|
|
60
|
+
* @throws Error if DOPPLER_TOKEN is not set
|
|
61
|
+
*/
|
|
62
|
+
constructor(options) {
|
|
63
|
+
const token = options?.token || process.env.DOPPLER_TOKEN;
|
|
64
|
+
if (!token) {
|
|
65
|
+
throw new Error("DOPPLER_TOKEN is required");
|
|
66
|
+
}
|
|
67
|
+
this.sdk = new import_node_sdk.default({ accessToken: token });
|
|
68
|
+
}
|
|
69
|
+
async listProjects() {
|
|
70
|
+
const response = await this.sdk.projects.list();
|
|
71
|
+
return (response.projects || []).map((p) => ({
|
|
72
|
+
// Treat slug as the stable identifier (matches Doppler URLs and most SDK calls).
|
|
73
|
+
id: p.slug || p.name || p.id || "",
|
|
74
|
+
name: p.name || p.slug || ""
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
async getWorkplaceId() {
|
|
78
|
+
const res = await this.sdk.workplace.get();
|
|
79
|
+
return res.workplace?.id || null;
|
|
80
|
+
}
|
|
81
|
+
async listConfigs(project) {
|
|
82
|
+
const response = await this.sdk.configs.list(project);
|
|
83
|
+
return (response.configs || []).map((c) => ({
|
|
84
|
+
id: c.name || "",
|
|
85
|
+
name: c.name || "",
|
|
86
|
+
slug: c.name || ""
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
async listEnvironments(project) {
|
|
90
|
+
const response = await this.sdk.environments.list(project);
|
|
91
|
+
return (response.environments || []).map((env) => {
|
|
92
|
+
const name = env.name || env.id || "";
|
|
93
|
+
const slug = name;
|
|
94
|
+
return {
|
|
95
|
+
id: env.id || slug,
|
|
96
|
+
name,
|
|
97
|
+
slug
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
async createEnvironment(project, slug, name) {
|
|
102
|
+
await this.sdk.environments.create(
|
|
103
|
+
{
|
|
104
|
+
slug,
|
|
105
|
+
name: name || slug
|
|
106
|
+
},
|
|
107
|
+
project
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
async updateEnvironment(project, environmentSlug, input) {
|
|
111
|
+
await this.sdk.environments.rename(
|
|
112
|
+
{
|
|
113
|
+
...input.slug ? { slug: input.slug } : {},
|
|
114
|
+
...input.name ? { name: input.name } : {}
|
|
115
|
+
},
|
|
116
|
+
project,
|
|
117
|
+
environmentSlug
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
async deleteEnvironment(project, environmentSlug) {
|
|
121
|
+
await this.sdk.environments.delete(project, environmentSlug);
|
|
122
|
+
}
|
|
123
|
+
async projectExists(project) {
|
|
124
|
+
try {
|
|
125
|
+
const response = await this.sdk.projects.list();
|
|
126
|
+
return (response.projects || []).some(
|
|
127
|
+
(p) => p.id === project || p.slug === project || p.name === project
|
|
128
|
+
);
|
|
129
|
+
} catch {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
async setupProject() {
|
|
134
|
+
throw new Error("Use Doppler SDK directly for project setup");
|
|
135
|
+
}
|
|
136
|
+
async listSecrets(project, config, folder = "/") {
|
|
137
|
+
const normalizedFolder = (0, import_core.normalizeFolderPath)(folder);
|
|
138
|
+
const response = await this.sdk.secrets.list(project, config);
|
|
139
|
+
const secrets = this.isRecord(response.secrets) ? response.secrets : {};
|
|
140
|
+
return Object.keys(secrets).flatMap((encodedKey) => {
|
|
141
|
+
const decoded = (0, import_core.decodeFolderScopedKey)(encodedKey);
|
|
142
|
+
if (!decoded || decoded.folder !== normalizedFolder) {
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
return [decoded.key];
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
async getSecret(project, config, key, folder = "/") {
|
|
149
|
+
const prefixedKey = (0, import_core.encodeFolderScopedKey)(folder, key);
|
|
150
|
+
try {
|
|
151
|
+
const response = await this.sdk.secrets.get(project, config, prefixedKey);
|
|
152
|
+
return this.getSecretValue(response.value);
|
|
153
|
+
} catch {
|
|
154
|
+
return void 0;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async setSecret(project, config, key, value, folder = "/") {
|
|
158
|
+
const prefixedKey = (0, import_core.encodeFolderScopedKey)(folder, key);
|
|
159
|
+
const payload = {
|
|
160
|
+
project,
|
|
161
|
+
config,
|
|
162
|
+
secrets: {
|
|
163
|
+
[prefixedKey]: value
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
await this.sdk.secrets.update(payload);
|
|
167
|
+
}
|
|
168
|
+
async deleteSecret(project, config, key, folder = "/") {
|
|
169
|
+
const prefixedKey = (0, import_core.encodeFolderScopedKey)(folder, key);
|
|
170
|
+
await this.sdk.secrets.delete(project, config, prefixedKey);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Set/update multiple secrets at once
|
|
174
|
+
*
|
|
175
|
+
* Doppler SDK's update method already supports multiple secrets.
|
|
176
|
+
*
|
|
177
|
+
* @param project - Project name
|
|
178
|
+
* @param config - Config name
|
|
179
|
+
* @param secrets - Record of secret key-value pairs
|
|
180
|
+
* @param folder - Folder path (default: '/')
|
|
181
|
+
*/
|
|
182
|
+
async setSecrets(project, config, secrets, folder = "/") {
|
|
183
|
+
const prefixedSecrets = {};
|
|
184
|
+
for (const [key, value] of Object.entries(secrets)) {
|
|
185
|
+
const prefixedKey = (0, import_core.encodeFolderScopedKey)(folder, key);
|
|
186
|
+
prefixedSecrets[prefixedKey] = value;
|
|
187
|
+
}
|
|
188
|
+
if (Object.keys(prefixedSecrets).length === 0) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const payload = {
|
|
192
|
+
project,
|
|
193
|
+
config,
|
|
194
|
+
secrets: prefixedSecrets
|
|
195
|
+
};
|
|
196
|
+
await this.sdk.secrets.update(payload);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Delete multiple secrets at once
|
|
200
|
+
*
|
|
201
|
+
* Doppler SDK doesn't have a batch delete, so we delete sequentially.
|
|
202
|
+
*
|
|
203
|
+
* @param project - Project name
|
|
204
|
+
* @param config - Config name
|
|
205
|
+
* @param keys - Array of secret keys to delete
|
|
206
|
+
* @param folder - Folder path (default: '/')
|
|
207
|
+
*/
|
|
208
|
+
async deleteSecrets(project, config, keys, folder = "/") {
|
|
209
|
+
if (keys.length === 0) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
for (const key of keys) {
|
|
213
|
+
const prefixedKey = (0, import_core.encodeFolderScopedKey)(folder, key);
|
|
214
|
+
await this.sdk.secrets.delete(project, config, prefixedKey);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// src/admin.ts
|
|
220
|
+
var DopplerStoreAdmin = class {
|
|
221
|
+
provider = "doppler";
|
|
222
|
+
capabilities = {
|
|
223
|
+
listProjects: true,
|
|
224
|
+
listEnvironments: true,
|
|
225
|
+
createProject: false,
|
|
226
|
+
createEnvironment: true,
|
|
227
|
+
updateEnvironment: true,
|
|
228
|
+
deleteEnvironment: true
|
|
229
|
+
};
|
|
230
|
+
missingEnvironmentsPolicy = "create";
|
|
231
|
+
store = null;
|
|
232
|
+
getStore() {
|
|
233
|
+
if (!this.store) this.store = new DopplerStore();
|
|
234
|
+
return this.store;
|
|
235
|
+
}
|
|
236
|
+
assertReady() {
|
|
237
|
+
if (!process.env.DOPPLER_TOKEN) {
|
|
238
|
+
throw new Error("DOPPLER_TOKEN environment variable is required");
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
async getProjectUrl(input) {
|
|
242
|
+
const cfg = input.config;
|
|
243
|
+
const workplaceId = cfg.organizationId || await this.getWorkplaceId().catch(() => null);
|
|
244
|
+
if (!workplaceId) return "https://dashboard.doppler.com";
|
|
245
|
+
return `https://dashboard.doppler.com/workplace/${encodeURIComponent(workplaceId)}/projects/${encodeURIComponent(cfg.projectId)}`;
|
|
246
|
+
}
|
|
247
|
+
async getWorkplaceId() {
|
|
248
|
+
return await this.getStore().getWorkplaceId();
|
|
249
|
+
}
|
|
250
|
+
async listProjects() {
|
|
251
|
+
const projs = await this.getStore().listProjects();
|
|
252
|
+
return projs.map((p) => ({ id: p.id, name: p.name, organizationId: p.organizationId }));
|
|
253
|
+
}
|
|
254
|
+
async listEnvironments(projectId) {
|
|
255
|
+
const envs = await this.getStore().listEnvironments(projectId);
|
|
256
|
+
return envs.map((e) => ({ id: e.id, name: e.name, slug: e.slug }));
|
|
257
|
+
}
|
|
258
|
+
async createEnvironment(input) {
|
|
259
|
+
await this.getStore().createEnvironment(input.projectId, input.slug, input.name);
|
|
260
|
+
}
|
|
261
|
+
async updateEnvironment(input) {
|
|
262
|
+
await this.getStore().updateEnvironment(input.projectId, input.id, {
|
|
263
|
+
...input.slug ? { slug: input.slug } : {},
|
|
264
|
+
...input.name ? { name: input.name } : {}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
async deleteEnvironment(input) {
|
|
268
|
+
await this.getStore().deleteEnvironment(input.projectId, input.id);
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
272
|
+
0 && (module.exports = {
|
|
273
|
+
DopplerStore,
|
|
274
|
+
DopplerStoreAdmin
|
|
275
|
+
});
|
|
276
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/store.ts","../src/admin.ts"],"sourcesContent":["// Doppler integration exports - will be populated when moving files\nexport * from './admin.js';\nexport * from './store.js';\n","// Doppler SecretStore implementation using @dopplerhq/node-sdk\n//\n// Implements the SecretStore interface for Doppler using the official SDK.\n// Handles folder-scoped key encoding for monorepo support (LZ1_<path>__<key>).\n\nimport DopplerSDK from '@dopplerhq/node-sdk';\nimport { decodeFolderScopedKey, encodeFolderScopedKey, normalizeFolderPath } from '@lazyenv/core';\nimport type { SecretStore } from '@lazyenv/core';\n\n/**\n * Doppler SecretStore implementation\n *\n * Uses the official Doppler SDK to interact with Doppler's API.\n * Supports folder-scoped key encoding for monorepo organization.\n *\n * @example\n * ```ts\n * const store = new DopplerStore({ token: 'dp.pt.xxx' });\n * const secrets = await store.listSecrets('my-project', 'dev', '/apps/web');\n * // Returns: ['DATABASE_URL', 'API_KEY']\n * ```\n */\nexport class DopplerStore implements SecretStore {\n name = 'doppler';\n private sdk: DopplerSDK;\n\n private isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n }\n\n private getSecretValue(value: unknown): string | undefined {\n if (!this.isRecord(value)) return undefined;\n const computed = value.computed;\n if (typeof computed === 'string' && computed.length > 0) return computed;\n const raw = value.raw;\n if (typeof raw === 'string' && raw.length > 0) return raw;\n return undefined;\n }\n\n /**\n * Create a new Doppler secret store\n *\n * Uses DOPPLER_TOKEN environment variable for authentication.\n *\n * @throws Error if DOPPLER_TOKEN is not set\n */\n constructor(options?: { token?: string }) {\n const token = options?.token || process.env.DOPPLER_TOKEN;\n if (!token) {\n throw new Error('DOPPLER_TOKEN is required');\n }\n this.sdk = new DopplerSDK({ accessToken: token });\n }\n\n async listProjects(): Promise<Array<{ id: string; name: string; organizationId?: string }>> {\n const response = await this.sdk.projects.list();\n return (response.projects || []).map(p => ({\n // Treat slug as the stable identifier (matches Doppler URLs and most SDK calls).\n id: p.slug || p.name || p.id || '',\n name: p.name || p.slug || '',\n }));\n }\n\n async getWorkplaceId(): Promise<string | null> {\n const res = await this.sdk.workplace.get();\n return res.workplace?.id || null;\n }\n\n async listConfigs(project: string): Promise<Array<{ id: string; name: string; slug: string }>> {\n const response = await this.sdk.configs.list(project);\n return (response.configs || []).map(c => ({\n id: c.name || '',\n name: c.name || '',\n slug: c.name || '',\n }));\n }\n\n async listEnvironments(project: string): Promise<Array<{ id: string; name: string; slug: string }>> {\n const response = await this.sdk.environments.list(project);\n return (response.environments || []).map((env) => {\n const name = env.name || env.id || '';\n const slug = name;\n return {\n id: env.id || slug,\n name,\n slug,\n };\n });\n }\n\n async createEnvironment(project: string, slug: string, name?: string): Promise<void> {\n await this.sdk.environments.create(\n {\n slug,\n name: name || slug,\n },\n project\n );\n }\n\n async updateEnvironment(project: string, environmentSlug: string, input: { slug?: string; name?: string }): Promise<void> {\n await this.sdk.environments.rename(\n {\n ...(input.slug ? { slug: input.slug } : {}),\n ...(input.name ? { name: input.name } : {}),\n },\n project,\n environmentSlug\n );\n }\n\n async deleteEnvironment(project: string, environmentSlug: string): Promise<void> {\n await this.sdk.environments.delete(project, environmentSlug);\n }\n\n async projectExists(project: string): Promise<boolean> {\n try {\n const response = await this.sdk.projects.list();\n return (response.projects || []).some(\n p => p.id === project || p.slug === project || p.name === project\n );\n } catch {\n return false;\n }\n }\n\n async setupProject(): Promise<void> {\n throw new Error('Use Doppler SDK directly for project setup');\n }\n\n async listSecrets(project: string, config: string, folder = '/'): Promise<string[]> {\n const normalizedFolder = normalizeFolderPath(folder);\n const response = await this.sdk.secrets.list(project, config);\n\n // The SDK returns secrets as an object with secret names as keys\n // Each secret has { raw?: string, computed?: string, note?: string }\n const secrets = this.isRecord(response.secrets) ? response.secrets : {};\n\n return Object.keys(secrets).flatMap((encodedKey) => {\n const decoded = decodeFolderScopedKey(encodedKey);\n if (!decoded || decoded.folder !== normalizedFolder) {\n return [];\n }\n return [decoded.key];\n });\n }\n\n async getSecret(\n project: string,\n config: string,\n key: string,\n folder = '/'\n ): Promise<string | undefined> {\n const prefixedKey = encodeFolderScopedKey(folder, key);\n\n try {\n const response = await this.sdk.secrets.get(project, config, prefixedKey);\n // response.value has { raw?: string, computed?: string }\n return this.getSecretValue(response.value);\n } catch {\n return undefined;\n }\n }\n\n async setSecret(project: string, config: string, key: string, value: string, folder = '/'): Promise<void> {\n const prefixedKey = encodeFolderScopedKey(folder, key);\n\n // The SDK update method takes: { project, config, secrets: { [key]: value } }\n const payload: Parameters<DopplerSDK['secrets']['update']>[0] = {\n project,\n config,\n secrets: {\n [prefixedKey]: value,\n },\n };\n await this.sdk.secrets.update(payload);\n }\n\n async deleteSecret(project: string, config: string, key: string, folder = '/'): Promise<void> {\n const prefixedKey = encodeFolderScopedKey(folder, key);\n\n await this.sdk.secrets.delete(project, config, prefixedKey);\n }\n\n /**\n * Set/update multiple secrets at once\n *\n * Doppler SDK's update method already supports multiple secrets.\n *\n * @param project - Project name\n * @param config - Config name\n * @param secrets - Record of secret key-value pairs\n * @param folder - Folder path (default: '/')\n */\n async setSecrets(project: string, config: string, secrets: Record<string, string>, folder = '/'): Promise<void> {\n const prefixedSecrets: Record<string, string> = {};\n for (const [key, value] of Object.entries(secrets)) {\n const prefixedKey = encodeFolderScopedKey(folder, key);\n prefixedSecrets[prefixedKey] = value;\n }\n\n if (Object.keys(prefixedSecrets).length === 0) {\n return;\n }\n\n // Doppler SDK's update method can take multiple secrets at once\n const payload: Parameters<DopplerSDK['secrets']['update']>[0] = {\n project,\n config,\n secrets: prefixedSecrets,\n };\n await this.sdk.secrets.update(payload);\n }\n\n /**\n * Delete multiple secrets at once\n *\n * Doppler SDK doesn't have a batch delete, so we delete sequentially.\n *\n * @param project - Project name\n * @param config - Config name\n * @param keys - Array of secret keys to delete\n * @param folder - Folder path (default: '/')\n */\n async deleteSecrets(project: string, config: string, keys: string[], folder = '/'): Promise<void> {\n if (keys.length === 0) {\n return;\n }\n\n // Delete sequentially (Doppler doesn't have batch delete)\n for (const key of keys) {\n const prefixedKey = encodeFolderScopedKey(folder, key);\n await this.sdk.secrets.delete(project, config, prefixedKey);\n }\n }\n}\n","import type { Config, Project, SecretStoreAdmin } from '@lazyenv/core';\nimport { DopplerStore } from './store.js';\n\nexport class DopplerStoreAdmin implements SecretStoreAdmin {\n readonly provider = 'doppler' as const;\n readonly capabilities = {\n listProjects: true,\n listEnvironments: true,\n createProject: false,\n createEnvironment: true,\n updateEnvironment: true,\n deleteEnvironment: true,\n } as const;\n readonly missingEnvironmentsPolicy = 'create' as const;\n\n private store: DopplerStore | null = null;\n\n private getStore(): DopplerStore {\n if (!this.store) this.store = new DopplerStore();\n return this.store;\n }\n\n assertReady(): void {\n if (!process.env.DOPPLER_TOKEN) {\n throw new Error('DOPPLER_TOKEN environment variable is required');\n }\n }\n\n async getProjectUrl(input: { config: import('@lazyenv/core').SecretsConfig }): Promise<string> {\n const cfg = input.config;\n const workplaceId = cfg.organizationId || (await this.getWorkplaceId().catch(() => null));\n if (!workplaceId) return 'https://dashboard.doppler.com';\n\n // `projectId` is treated as the project slug for Doppler.\n return `https://dashboard.doppler.com/workplace/${encodeURIComponent(workplaceId)}/projects/${encodeURIComponent(cfg.projectId)}`;\n }\n\n async getWorkplaceId(): Promise<string | null> {\n return await this.getStore().getWorkplaceId();\n }\n\n async listProjects(): Promise<Project[]> {\n const projs = await this.getStore().listProjects();\n return projs.map((p) => ({ id: p.id, name: p.name, organizationId: p.organizationId }));\n }\n\n async listEnvironments(projectId: string): Promise<Config[]> {\n const envs = await this.getStore().listEnvironments(projectId);\n return envs.map((e) => ({ id: e.id, name: e.name, slug: e.slug }));\n }\n\n async createEnvironment(input: { projectId: string; slug: string; name?: string }): Promise<void> {\n await this.getStore().createEnvironment(input.projectId, input.slug, input.name);\n }\n\n async updateEnvironment(input: { projectId: string; id: string; slug?: string; name?: string }): Promise<void> {\n await this.getStore().updateEnvironment(input.projectId, input.id, {\n ...(input.slug ? { slug: input.slug } : {}),\n ...(input.name ? { name: input.name } : {}),\n });\n }\n\n async deleteEnvironment(input: { projectId: string; id: string }): Promise<void> {\n await this.getStore().deleteEnvironment(input.projectId, input.id);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,sBAAuB;AACvB,kBAAkF;AAgB3E,IAAM,eAAN,MAA0C;AAAA,EAC/C,OAAO;AAAA,EACC;AAAA,EAEA,SAAS,OAAkD;AACjE,WAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAAA,EAC5E;AAAA,EAEQ,eAAe,OAAoC;AACzD,QAAI,CAAC,KAAK,SAAS,KAAK,EAAG,QAAO;AAClC,UAAM,WAAW,MAAM;AACvB,QAAI,OAAO,aAAa,YAAY,SAAS,SAAS,EAAG,QAAO;AAChE,UAAM,MAAM,MAAM;AAClB,QAAI,OAAO,QAAQ,YAAY,IAAI,SAAS,EAAG,QAAO;AACtD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,YAAY,SAA8B;AACxC,UAAM,QAAQ,SAAS,SAAS,QAAQ,IAAI;AAC5C,QAAI,CAAC,OAAO;AACV,YAAM,IAAI,MAAM,2BAA2B;AAAA,IAC7C;AACA,SAAK,MAAM,IAAI,gBAAAA,QAAW,EAAE,aAAa,MAAM,CAAC;AAAA,EAClD;AAAA,EAEA,MAAM,eAAsF;AAC1F,UAAM,WAAW,MAAM,KAAK,IAAI,SAAS,KAAK;AAC9C,YAAQ,SAAS,YAAY,CAAC,GAAG,IAAI,QAAM;AAAA;AAAA,MAEzC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM;AAAA,MAChC,MAAM,EAAE,QAAQ,EAAE,Q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AAW,MAAM,IAAI;AAAA,MACjE,GAAI,MAAM,OAAO,EAAE,MAAM,MAAM,KAAK,IAAI,CAAC;AAAA,MACzC,GAAI,MAAM,OAAO,EAAE,MAAM,MAAM,KAAK,IAAI,CAAC;AAAA,IAC3C,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,kBAAkB,OAAyD;AAC/E,UAAM,KAAK,SAAS,EAAE,kBAAkB,MAAM,WAAW,MAAM,EAAE;AAAA,EACnE;AACF;","names":["DopplerSDK"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import * as _lazyenv_core from '@lazyenv/core';
|
|
2
|
+
import { SecretStoreAdmin, Project, Config, SecretStore } from '@lazyenv/core';
|
|
3
|
+
|
|
4
|
+
declare class DopplerStoreAdmin implements SecretStoreAdmin {
|
|
5
|
+
readonly provider: "doppler";
|
|
6
|
+
readonly capabilities: {
|
|
7
|
+
readonly listProjects: true;
|
|
8
|
+
readonly listEnvironments: true;
|
|
9
|
+
readonly createProject: false;
|
|
10
|
+
readonly createEnvironment: true;
|
|
11
|
+
readonly updateEnvironment: true;
|
|
12
|
+
readonly deleteEnvironment: true;
|
|
13
|
+
};
|
|
14
|
+
readonly missingEnvironmentsPolicy: "create";
|
|
15
|
+
private store;
|
|
16
|
+
private getStore;
|
|
17
|
+
assertReady(): void;
|
|
18
|
+
getProjectUrl(input: {
|
|
19
|
+
config: _lazyenv_core.SecretsConfig;
|
|
20
|
+
}): Promise<string>;
|
|
21
|
+
getWorkplaceId(): Promise<string | null>;
|
|
22
|
+
listProjects(): Promise<Project[]>;
|
|
23
|
+
listEnvironments(projectId: string): Promise<Config[]>;
|
|
24
|
+
createEnvironment(input: {
|
|
25
|
+
projectId: string;
|
|
26
|
+
slug: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
updateEnvironment(input: {
|
|
30
|
+
projectId: string;
|
|
31
|
+
id: string;
|
|
32
|
+
slug?: string;
|
|
33
|
+
name?: string;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
deleteEnvironment(input: {
|
|
36
|
+
projectId: string;
|
|
37
|
+
id: string;
|
|
38
|
+
}): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Doppler SecretStore implementation
|
|
43
|
+
*
|
|
44
|
+
* Uses the official Doppler SDK to interact with Doppler's API.
|
|
45
|
+
* Supports folder-scoped key encoding for monorepo organization.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const store = new DopplerStore({ token: 'dp.pt.xxx' });
|
|
50
|
+
* const secrets = await store.listSecrets('my-project', 'dev', '/apps/web');
|
|
51
|
+
* // Returns: ['DATABASE_URL', 'API_KEY']
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare class DopplerStore implements SecretStore {
|
|
55
|
+
name: string;
|
|
56
|
+
private sdk;
|
|
57
|
+
private isRecord;
|
|
58
|
+
private getSecretValue;
|
|
59
|
+
/**
|
|
60
|
+
* Create a new Doppler secret store
|
|
61
|
+
*
|
|
62
|
+
* Uses DOPPLER_TOKEN environment variable for authentication.
|
|
63
|
+
*
|
|
64
|
+
* @throws Error if DOPPLER_TOKEN is not set
|
|
65
|
+
*/
|
|
66
|
+
constructor(options?: {
|
|
67
|
+
token?: string;
|
|
68
|
+
});
|
|
69
|
+
listProjects(): Promise<Array<{
|
|
70
|
+
id: string;
|
|
71
|
+
name: string;
|
|
72
|
+
organizationId?: string;
|
|
73
|
+
}>>;
|
|
74
|
+
getWorkplaceId(): Promise<string | null>;
|
|
75
|
+
listConfigs(project: string): Promise<Array<{
|
|
76
|
+
id: string;
|
|
77
|
+
name: string;
|
|
78
|
+
slug: string;
|
|
79
|
+
}>>;
|
|
80
|
+
listEnvironments(project: string): Promise<Array<{
|
|
81
|
+
id: string;
|
|
82
|
+
name: string;
|
|
83
|
+
slug: string;
|
|
84
|
+
}>>;
|
|
85
|
+
createEnvironment(project: string, slug: string, name?: string): Promise<void>;
|
|
86
|
+
updateEnvironment(project: string, environmentSlug: string, input: {
|
|
87
|
+
slug?: string;
|
|
88
|
+
name?: string;
|
|
89
|
+
}): Promise<void>;
|
|
90
|
+
deleteEnvironment(project: string, environmentSlug: string): Promise<void>;
|
|
91
|
+
projectExists(project: string): Promise<boolean>;
|
|
92
|
+
setupProject(): Promise<void>;
|
|
93
|
+
listSecrets(project: string, config: string, folder?: string): Promise<string[]>;
|
|
94
|
+
getSecret(project: string, config: string, key: string, folder?: string): Promise<string | undefined>;
|
|
95
|
+
setSecret(project: string, config: string, key: string, value: string, folder?: string): Promise<void>;
|
|
96
|
+
deleteSecret(project: string, config: string, key: string, folder?: string): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Set/update multiple secrets at once
|
|
99
|
+
*
|
|
100
|
+
* Doppler SDK's update method already supports multiple secrets.
|
|
101
|
+
*
|
|
102
|
+
* @param project - Project name
|
|
103
|
+
* @param config - Config name
|
|
104
|
+
* @param secrets - Record of secret key-value pairs
|
|
105
|
+
* @param folder - Folder path (default: '/')
|
|
106
|
+
*/
|
|
107
|
+
setSecrets(project: string, config: string, secrets: Record<string, string>, folder?: string): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Delete multiple secrets at once
|
|
110
|
+
*
|
|
111
|
+
* Doppler SDK doesn't have a batch delete, so we delete sequentially.
|
|
112
|
+
*
|
|
113
|
+
* @param project - Project name
|
|
114
|
+
* @param config - Config name
|
|
115
|
+
* @param keys - Array of secret keys to delete
|
|
116
|
+
* @param folder - Folder path (default: '/')
|
|
117
|
+
*/
|
|
118
|
+
deleteSecrets(project: string, config: string, keys: string[], folder?: string): Promise<void>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export { DopplerStore, DopplerStoreAdmin };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import * as _lazyenv_core from '@lazyenv/core';
|
|
2
|
+
import { SecretStoreAdmin, Project, Config, SecretStore } from '@lazyenv/core';
|
|
3
|
+
|
|
4
|
+
declare class DopplerStoreAdmin implements SecretStoreAdmin {
|
|
5
|
+
readonly provider: "doppler";
|
|
6
|
+
readonly capabilities: {
|
|
7
|
+
readonly listProjects: true;
|
|
8
|
+
readonly listEnvironments: true;
|
|
9
|
+
readonly createProject: false;
|
|
10
|
+
readonly createEnvironment: true;
|
|
11
|
+
readonly updateEnvironment: true;
|
|
12
|
+
readonly deleteEnvironment: true;
|
|
13
|
+
};
|
|
14
|
+
readonly missingEnvironmentsPolicy: "create";
|
|
15
|
+
private store;
|
|
16
|
+
private getStore;
|
|
17
|
+
assertReady(): void;
|
|
18
|
+
getProjectUrl(input: {
|
|
19
|
+
config: _lazyenv_core.SecretsConfig;
|
|
20
|
+
}): Promise<string>;
|
|
21
|
+
getWorkplaceId(): Promise<string | null>;
|
|
22
|
+
listProjects(): Promise<Project[]>;
|
|
23
|
+
listEnvironments(projectId: string): Promise<Config[]>;
|
|
24
|
+
createEnvironment(input: {
|
|
25
|
+
projectId: string;
|
|
26
|
+
slug: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
updateEnvironment(input: {
|
|
30
|
+
projectId: string;
|
|
31
|
+
id: string;
|
|
32
|
+
slug?: string;
|
|
33
|
+
name?: string;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
deleteEnvironment(input: {
|
|
36
|
+
projectId: string;
|
|
37
|
+
id: string;
|
|
38
|
+
}): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Doppler SecretStore implementation
|
|
43
|
+
*
|
|
44
|
+
* Uses the official Doppler SDK to interact with Doppler's API.
|
|
45
|
+
* Supports folder-scoped key encoding for monorepo organization.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const store = new DopplerStore({ token: 'dp.pt.xxx' });
|
|
50
|
+
* const secrets = await store.listSecrets('my-project', 'dev', '/apps/web');
|
|
51
|
+
* // Returns: ['DATABASE_URL', 'API_KEY']
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare class DopplerStore implements SecretStore {
|
|
55
|
+
name: string;
|
|
56
|
+
private sdk;
|
|
57
|
+
private isRecord;
|
|
58
|
+
private getSecretValue;
|
|
59
|
+
/**
|
|
60
|
+
* Create a new Doppler secret store
|
|
61
|
+
*
|
|
62
|
+
* Uses DOPPLER_TOKEN environment variable for authentication.
|
|
63
|
+
*
|
|
64
|
+
* @throws Error if DOPPLER_TOKEN is not set
|
|
65
|
+
*/
|
|
66
|
+
constructor(options?: {
|
|
67
|
+
token?: string;
|
|
68
|
+
});
|
|
69
|
+
listProjects(): Promise<Array<{
|
|
70
|
+
id: string;
|
|
71
|
+
name: string;
|
|
72
|
+
organizationId?: string;
|
|
73
|
+
}>>;
|
|
74
|
+
getWorkplaceId(): Promise<string | null>;
|
|
75
|
+
listConfigs(project: string): Promise<Array<{
|
|
76
|
+
id: string;
|
|
77
|
+
name: string;
|
|
78
|
+
slug: string;
|
|
79
|
+
}>>;
|
|
80
|
+
listEnvironments(project: string): Promise<Array<{
|
|
81
|
+
id: string;
|
|
82
|
+
name: string;
|
|
83
|
+
slug: string;
|
|
84
|
+
}>>;
|
|
85
|
+
createEnvironment(project: string, slug: string, name?: string): Promise<void>;
|
|
86
|
+
updateEnvironment(project: string, environmentSlug: string, input: {
|
|
87
|
+
slug?: string;
|
|
88
|
+
name?: string;
|
|
89
|
+
}): Promise<void>;
|
|
90
|
+
deleteEnvironment(project: string, environmentSlug: string): Promise<void>;
|
|
91
|
+
projectExists(project: string): Promise<boolean>;
|
|
92
|
+
setupProject(): Promise<void>;
|
|
93
|
+
listSecrets(project: string, config: string, folder?: string): Promise<string[]>;
|
|
94
|
+
getSecret(project: string, config: string, key: string, folder?: string): Promise<string | undefined>;
|
|
95
|
+
setSecret(project: string, config: string, key: string, value: string, folder?: string): Promise<void>;
|
|
96
|
+
deleteSecret(project: string, config: string, key: string, folder?: string): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Set/update multiple secrets at once
|
|
99
|
+
*
|
|
100
|
+
* Doppler SDK's update method already supports multiple secrets.
|
|
101
|
+
*
|
|
102
|
+
* @param project - Project name
|
|
103
|
+
* @param config - Config name
|
|
104
|
+
* @param secrets - Record of secret key-value pairs
|
|
105
|
+
* @param folder - Folder path (default: '/')
|
|
106
|
+
*/
|
|
107
|
+
setSecrets(project: string, config: string, secrets: Record<string, string>, folder?: string): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Delete multiple secrets at once
|
|
110
|
+
*
|
|
111
|
+
* Doppler SDK doesn't have a batch delete, so we delete sequentially.
|
|
112
|
+
*
|
|
113
|
+
* @param project - Project name
|
|
114
|
+
* @param config - Config name
|
|
115
|
+
* @param keys - Array of secret keys to delete
|
|
116
|
+
* @param folder - Folder path (default: '/')
|
|
117
|
+
*/
|
|
118
|
+
deleteSecrets(project: string, config: string, keys: string[], folder?: string): Promise<void>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export { DopplerStore, DopplerStoreAdmin };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
// src/store.ts
|
|
2
|
+
import DopplerSDK from "@dopplerhq/node-sdk";
|
|
3
|
+
import { decodeFolderScopedKey, encodeFolderScopedKey, normalizeFolderPath } from "@lazyenv/core";
|
|
4
|
+
var DopplerStore = class {
|
|
5
|
+
name = "doppler";
|
|
6
|
+
sdk;
|
|
7
|
+
isRecord(value) {
|
|
8
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
getSecretValue(value) {
|
|
11
|
+
if (!this.isRecord(value)) return void 0;
|
|
12
|
+
const computed = value.computed;
|
|
13
|
+
if (typeof computed === "string" && computed.length > 0) return computed;
|
|
14
|
+
const raw = value.raw;
|
|
15
|
+
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
16
|
+
return void 0;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create a new Doppler secret store
|
|
20
|
+
*
|
|
21
|
+
* Uses DOPPLER_TOKEN environment variable for authentication.
|
|
22
|
+
*
|
|
23
|
+
* @throws Error if DOPPLER_TOKEN is not set
|
|
24
|
+
*/
|
|
25
|
+
constructor(options) {
|
|
26
|
+
const token = options?.token || process.env.DOPPLER_TOKEN;
|
|
27
|
+
if (!token) {
|
|
28
|
+
throw new Error("DOPPLER_TOKEN is required");
|
|
29
|
+
}
|
|
30
|
+
this.sdk = new DopplerSDK({ accessToken: token });
|
|
31
|
+
}
|
|
32
|
+
async listProjects() {
|
|
33
|
+
const response = await this.sdk.projects.list();
|
|
34
|
+
return (response.projects || []).map((p) => ({
|
|
35
|
+
// Treat slug as the stable identifier (matches Doppler URLs and most SDK calls).
|
|
36
|
+
id: p.slug || p.name || p.id || "",
|
|
37
|
+
name: p.name || p.slug || ""
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
async getWorkplaceId() {
|
|
41
|
+
const res = await this.sdk.workplace.get();
|
|
42
|
+
return res.workplace?.id || null;
|
|
43
|
+
}
|
|
44
|
+
async listConfigs(project) {
|
|
45
|
+
const response = await this.sdk.configs.list(project);
|
|
46
|
+
return (response.configs || []).map((c) => ({
|
|
47
|
+
id: c.name || "",
|
|
48
|
+
name: c.name || "",
|
|
49
|
+
slug: c.name || ""
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
async listEnvironments(project) {
|
|
53
|
+
const response = await this.sdk.environments.list(project);
|
|
54
|
+
return (response.environments || []).map((env) => {
|
|
55
|
+
const name = env.name || env.id || "";
|
|
56
|
+
const slug = name;
|
|
57
|
+
return {
|
|
58
|
+
id: env.id || slug,
|
|
59
|
+
name,
|
|
60
|
+
slug
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async createEnvironment(project, slug, name) {
|
|
65
|
+
await this.sdk.environments.create(
|
|
66
|
+
{
|
|
67
|
+
slug,
|
|
68
|
+
name: name || slug
|
|
69
|
+
},
|
|
70
|
+
project
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
async updateEnvironment(project, environmentSlug, input) {
|
|
74
|
+
await this.sdk.environments.rename(
|
|
75
|
+
{
|
|
76
|
+
...input.slug ? { slug: input.slug } : {},
|
|
77
|
+
...input.name ? { name: input.name } : {}
|
|
78
|
+
},
|
|
79
|
+
project,
|
|
80
|
+
environmentSlug
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
async deleteEnvironment(project, environmentSlug) {
|
|
84
|
+
await this.sdk.environments.delete(project, environmentSlug);
|
|
85
|
+
}
|
|
86
|
+
async projectExists(project) {
|
|
87
|
+
try {
|
|
88
|
+
const response = await this.sdk.projects.list();
|
|
89
|
+
return (response.projects || []).some(
|
|
90
|
+
(p) => p.id === project || p.slug === project || p.name === project
|
|
91
|
+
);
|
|
92
|
+
} catch {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async setupProject() {
|
|
97
|
+
throw new Error("Use Doppler SDK directly for project setup");
|
|
98
|
+
}
|
|
99
|
+
async listSecrets(project, config, folder = "/") {
|
|
100
|
+
const normalizedFolder = normalizeFolderPath(folder);
|
|
101
|
+
const response = await this.sdk.secrets.list(project, config);
|
|
102
|
+
const secrets = this.isRecord(response.secrets) ? response.secrets : {};
|
|
103
|
+
return Object.keys(secrets).flatMap((encodedKey) => {
|
|
104
|
+
const decoded = decodeFolderScopedKey(encodedKey);
|
|
105
|
+
if (!decoded || decoded.folder !== normalizedFolder) {
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
return [decoded.key];
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
async getSecret(project, config, key, folder = "/") {
|
|
112
|
+
const prefixedKey = encodeFolderScopedKey(folder, key);
|
|
113
|
+
try {
|
|
114
|
+
const response = await this.sdk.secrets.get(project, config, prefixedKey);
|
|
115
|
+
return this.getSecretValue(response.value);
|
|
116
|
+
} catch {
|
|
117
|
+
return void 0;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async setSecret(project, config, key, value, folder = "/") {
|
|
121
|
+
const prefixedKey = encodeFolderScopedKey(folder, key);
|
|
122
|
+
const payload = {
|
|
123
|
+
project,
|
|
124
|
+
config,
|
|
125
|
+
secrets: {
|
|
126
|
+
[prefixedKey]: value
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
await this.sdk.secrets.update(payload);
|
|
130
|
+
}
|
|
131
|
+
async deleteSecret(project, config, key, folder = "/") {
|
|
132
|
+
const prefixedKey = encodeFolderScopedKey(folder, key);
|
|
133
|
+
await this.sdk.secrets.delete(project, config, prefixedKey);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Set/update multiple secrets at once
|
|
137
|
+
*
|
|
138
|
+
* Doppler SDK's update method already supports multiple secrets.
|
|
139
|
+
*
|
|
140
|
+
* @param project - Project name
|
|
141
|
+
* @param config - Config name
|
|
142
|
+
* @param secrets - Record of secret key-value pairs
|
|
143
|
+
* @param folder - Folder path (default: '/')
|
|
144
|
+
*/
|
|
145
|
+
async setSecrets(project, config, secrets, folder = "/") {
|
|
146
|
+
const prefixedSecrets = {};
|
|
147
|
+
for (const [key, value] of Object.entries(secrets)) {
|
|
148
|
+
const prefixedKey = encodeFolderScopedKey(folder, key);
|
|
149
|
+
prefixedSecrets[prefixedKey] = value;
|
|
150
|
+
}
|
|
151
|
+
if (Object.keys(prefixedSecrets).length === 0) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const payload = {
|
|
155
|
+
project,
|
|
156
|
+
config,
|
|
157
|
+
secrets: prefixedSecrets
|
|
158
|
+
};
|
|
159
|
+
await this.sdk.secrets.update(payload);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Delete multiple secrets at once
|
|
163
|
+
*
|
|
164
|
+
* Doppler SDK doesn't have a batch delete, so we delete sequentially.
|
|
165
|
+
*
|
|
166
|
+
* @param project - Project name
|
|
167
|
+
* @param config - Config name
|
|
168
|
+
* @param keys - Array of secret keys to delete
|
|
169
|
+
* @param folder - Folder path (default: '/')
|
|
170
|
+
*/
|
|
171
|
+
async deleteSecrets(project, config, keys, folder = "/") {
|
|
172
|
+
if (keys.length === 0) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
for (const key of keys) {
|
|
176
|
+
const prefixedKey = encodeFolderScopedKey(folder, key);
|
|
177
|
+
await this.sdk.secrets.delete(project, config, prefixedKey);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// src/admin.ts
|
|
183
|
+
var DopplerStoreAdmin = class {
|
|
184
|
+
provider = "doppler";
|
|
185
|
+
capabilities = {
|
|
186
|
+
listProjects: true,
|
|
187
|
+
listEnvironments: true,
|
|
188
|
+
createProject: false,
|
|
189
|
+
createEnvironment: true,
|
|
190
|
+
updateEnvironment: true,
|
|
191
|
+
deleteEnvironment: true
|
|
192
|
+
};
|
|
193
|
+
missingEnvironmentsPolicy = "create";
|
|
194
|
+
store = null;
|
|
195
|
+
getStore() {
|
|
196
|
+
if (!this.store) this.store = new DopplerStore();
|
|
197
|
+
return this.store;
|
|
198
|
+
}
|
|
199
|
+
assertReady() {
|
|
200
|
+
if (!process.env.DOPPLER_TOKEN) {
|
|
201
|
+
throw new Error("DOPPLER_TOKEN environment variable is required");
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
async getProjectUrl(input) {
|
|
205
|
+
const cfg = input.config;
|
|
206
|
+
const workplaceId = cfg.organizationId || await this.getWorkplaceId().catch(() => null);
|
|
207
|
+
if (!workplaceId) return "https://dashboard.doppler.com";
|
|
208
|
+
return `https://dashboard.doppler.com/workplace/${encodeURIComponent(workplaceId)}/projects/${encodeURIComponent(cfg.projectId)}`;
|
|
209
|
+
}
|
|
210
|
+
async getWorkplaceId() {
|
|
211
|
+
return await this.getStore().getWorkplaceId();
|
|
212
|
+
}
|
|
213
|
+
async listProjects() {
|
|
214
|
+
const projs = await this.getStore().listProjects();
|
|
215
|
+
return projs.map((p) => ({ id: p.id, name: p.name, organizationId: p.organizationId }));
|
|
216
|
+
}
|
|
217
|
+
async listEnvironments(projectId) {
|
|
218
|
+
const envs = await this.getStore().listEnvironments(projectId);
|
|
219
|
+
return envs.map((e) => ({ id: e.id, name: e.name, slug: e.slug }));
|
|
220
|
+
}
|
|
221
|
+
async createEnvironment(input) {
|
|
222
|
+
await this.getStore().createEnvironment(input.projectId, input.slug, input.name);
|
|
223
|
+
}
|
|
224
|
+
async updateEnvironment(input) {
|
|
225
|
+
await this.getStore().updateEnvironment(input.projectId, input.id, {
|
|
226
|
+
...input.slug ? { slug: input.slug } : {},
|
|
227
|
+
...input.name ? { name: input.name } : {}
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
async deleteEnvironment(input) {
|
|
231
|
+
await this.getStore().deleteEnvironment(input.projectId, input.id);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
export {
|
|
235
|
+
DopplerStore,
|
|
236
|
+
DopplerStoreAdmin
|
|
237
|
+
};
|
|
238
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/store.ts","../src/admin.ts"],"sourcesContent":["// Doppler SecretStore implementation using @dopplerhq/node-sdk\n//\n// Implements the SecretStore interface for Doppler using the official SDK.\n// Handles folder-scoped key encoding for monorepo support (LZ1_<path>__<key>).\n\nimport DopplerSDK from '@dopplerhq/node-sdk';\nimport { decodeFolderScopedKey, encodeFolderScopedKey, normalizeFolderPath } from '@lazyenv/core';\nimport type { SecretStore } from '@lazyenv/core';\n\n/**\n * Doppler SecretStore implementation\n *\n * Uses the official Doppler SDK to interact with Doppler's API.\n * Supports folder-scoped key encoding for monorepo organization.\n *\n * @example\n * ```ts\n * const store = new DopplerStore({ token: 'dp.pt.xxx' });\n * const secrets = await store.listSecrets('my-project', 'dev', '/apps/web');\n * // Returns: ['DATABASE_URL', 'API_KEY']\n * ```\n */\nexport class DopplerStore implements SecretStore {\n name = 'doppler';\n private sdk: DopplerSDK;\n\n private isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n }\n\n private getSecretValue(value: unknown): string | undefined {\n if (!this.isRecord(value)) return undefined;\n const computed = value.computed;\n if (typeof computed === 'string' && computed.length > 0) return computed;\n const raw = value.raw;\n if (typeof raw === 'string' && raw.length > 0) return raw;\n return undefined;\n }\n\n /**\n * Create a new Doppler secret store\n *\n * Uses DOPPLER_TOKEN environment variable for authentication.\n *\n * @throws Error if DOPPLER_TOKEN is not set\n */\n constructor(options?: { token?: string }) {\n const token = options?.token || process.env.DOPPLER_TOKEN;\n if (!token) {\n throw new Error('DOPPLER_TOKEN is required');\n }\n this.sdk = new DopplerSDK({ accessToken: token });\n }\n\n async listProjects(): Promise<Array<{ id: string; name: string; organizationId?: string }>> {\n const response = await this.sdk.projects.list();\n return (response.projects || []).map(p => ({\n // Treat slug as the stable identifier (matches Doppler URLs and most SDK calls).\n id: p.slug || p.name || p.id || '',\n name: p.name || p.slug || '',\n }));\n }\n\n async getWorkplaceId(): Promise<string | null> {\n const res = await this.sdk.workplace.get();\n return res.workplace?.id || null;\n }\n\n async listConfigs(project: string): Promise<Array<{ id: string; name: string; slug: string }>> {\n const response = await this.sdk.configs.list(project);\n return (response.configs || []).map(c => ({\n id: c.name || '',\n name: c.name || '',\n slug: c.name || '',\n }));\n }\n\n async listEnvironments(project: string): Promise<Array<{ id: string; name: string; slug: string }>> {\n const response = await this.sdk.environments.list(project);\n return (response.environments || []).map((env) => {\n const name = env.name || env.id || '';\n const slug = name;\n return {\n id: env.id || slug,\n name,\n slug,\n };\n });\n }\n\n async createEnvironment(project: string, slug: string, name?: string): Promise<void> {\n await this.sdk.environments.create(\n {\n slug,\n name: name || slug,\n },\n project\n );\n }\n\n async updateEnvironment(project: string, environmentSlug: string, input: { slug?: string; name?: string }): Promise<void> {\n await this.sdk.environments.rename(\n {\n ...(input.slug ? { slug: input.slug } : {}),\n ...(input.name ? { name: input.name } : {}),\n },\n project,\n environmentSlug\n );\n }\n\n async deleteEnvironment(project: string, environmentSlug: string): Promise<void> {\n await this.sdk.environments.delete(project, environmentSlug);\n }\n\n async projectExists(project: string): Promise<boolean> {\n try {\n const response = await this.sdk.projects.list();\n return (response.projects || []).some(\n p => p.id === project || p.slug === project || p.name === project\n );\n } catch {\n return false;\n }\n }\n\n async setupProject(): Promise<void> {\n throw new Error('Use Doppler SDK directly for project setup');\n }\n\n async listSecrets(project: string, config: string, folder = '/'): Promise<string[]> {\n const normalizedFolder = normalizeFolderPath(folder);\n const response = await this.sdk.secrets.list(project, config);\n\n // The SDK returns secrets as an object with secret names as keys\n // Each secret has { raw?: string, computed?: string, note?: string }\n const secrets = this.isRecord(response.secrets) ? response.secrets : {};\n\n return Object.keys(secrets).flatMap((encodedKey) => {\n const decoded = decodeFolderScopedKey(encodedKey);\n if (!decoded || decoded.folder !== normalizedFolder) {\n return [];\n }\n return [decoded.key];\n });\n }\n\n async getSecret(\n project: string,\n config: string,\n key: string,\n folder = '/'\n ): Promise<string | undefined> {\n const prefixedKey = encodeFolderScopedKey(folder, key);\n\n try {\n const response = await this.sdk.secrets.get(project, config, prefixedKey);\n // response.value has { raw?: string, computed?: string }\n return this.getSecretValue(response.value);\n } catch {\n return undefined;\n }\n }\n\n async setSecret(project: string, config: string, key: string, value: string, folder = '/'): Promise<void> {\n const prefixedKey = encodeFolderScopedKey(folder, key);\n\n // The SDK update method takes: { project, config, secrets: { [key]: value } }\n const payload: Parameters<DopplerSDK['secrets']['update']>[0] = {\n project,\n config,\n secrets: {\n [prefixedKey]: value,\n },\n };\n await this.sdk.secrets.update(payload);\n }\n\n async deleteSecret(project: string, config: string, key: string, folder = '/'): Promise<void> {\n const prefixedKey = encodeFolderScopedKey(folder, key);\n\n await this.sdk.secrets.delete(project, config, prefixedKey);\n }\n\n /**\n * Set/update multiple secrets at once\n *\n * Doppler SDK's update method already supports multiple secrets.\n *\n * @param project - Project name\n * @param config - Config name\n * @param secrets - Record of secret key-value pairs\n * @param folder - Folder path (default: '/')\n */\n async setSecrets(project: string, config: string, secrets: Record<string, string>, folder = '/'): Promise<void> {\n const prefixedSecrets: Record<string, string> = {};\n for (const [key, value] of Object.entries(secrets)) {\n const prefixedKey = encodeFolderScopedKey(folder, key);\n prefixedSecrets[prefixedKey] = value;\n }\n\n if (Object.keys(prefixedSecrets).length === 0) {\n return;\n }\n\n // Doppler SDK's update method can take multiple secrets at once\n const payload: Parameters<DopplerSDK['secrets']['update']>[0] = {\n project,\n config,\n secrets: prefixedSecrets,\n };\n await this.sdk.secrets.update(payload);\n }\n\n /**\n * Delete multiple secrets at once\n *\n * Doppler SDK doesn't have a batch delete, so we delete sequentially.\n *\n * @param project - Project name\n * @param config - Config name\n * @param keys - Array of secret keys to delete\n * @param folder - Folder path (default: '/')\n */\n async deleteSecrets(project: string, config: string, keys: string[], folder = '/'): Promise<void> {\n if (keys.length === 0) {\n return;\n }\n\n // Delete sequentially (Doppler doesn't have batch delete)\n for (const key of keys) {\n const prefixedKey = encodeFolderScopedKey(folder, key);\n await this.sdk.secrets.delete(project, config, prefixedKey);\n }\n }\n}\n","import type { Config, Project, SecretStoreAdmin } from '@lazyenv/core';\nimport { DopplerStore } from './store.js';\n\nexport class DopplerStoreAdmin implements SecretStoreAdmin {\n readonly provider = 'doppler' as const;\n readonly capabilities = {\n listProjects: true,\n listEnvironments: true,\n createProject: false,\n createEnvironment: true,\n updateEnvironment: true,\n deleteEnvironment: true,\n } as const;\n readonly missingEnvironmentsPolicy = 'create' as const;\n\n private store: DopplerStore | null = null;\n\n private getStore(): DopplerStore {\n if (!this.store) this.store = new DopplerStore();\n return this.store;\n }\n\n assertReady(): void {\n if (!process.env.DOPPLER_TOKEN) {\n throw new Error('DOPPLER_TOKEN environment variable is required');\n }\n }\n\n async getProjectUrl(input: { config: import('@lazyenv/core').SecretsConfig }): Promise<string> {\n const cfg = input.config;\n const workplaceId = cfg.organizationId || (await this.getWorkplaceId().catch(() => null));\n if (!workplaceId) return 'https://dashboard.doppler.com';\n\n // `projectId` is treated as the project slug for Doppler.\n return `https://dashboard.doppler.com/workplace/${encodeURIComponent(workplaceId)}/projects/${encodeURIComponent(cfg.projectId)}`;\n }\n\n async getWorkplaceId(): Promise<string | null> {\n return await this.getStore().getWorkplaceId();\n }\n\n async listProjects(): Promise<Project[]> {\n const projs = await this.getStore().listProjects();\n return projs.map((p) => ({ id: p.id, name: p.name, organizationId: p.organizationId }));\n }\n\n async listEnvironments(projectId: string): Promise<Config[]> {\n const envs = await this.getStore().listEnvironments(projectId);\n return envs.map((e) => ({ id: e.id, name: e.name, slug: e.slug }));\n }\n\n async createEnvironment(input: { projectId: string; slug: string; name?: string }): Promise<void> {\n await this.getStore().createEnvironment(input.projectId, input.slug, input.name);\n }\n\n async updateEnvironment(input: { projectId: string; id: string; slug?: string; name?: string }): Promise<void> {\n await this.getStore().updateEnvironment(input.projectId, input.id, {\n ...(input.slug ? { slug: input.slug } : {}),\n ...(input.name ? { name: input.name } : {}),\n });\n }\n\n async deleteEnvironment(input: { projectId: string; id: string }): Promise<void> {\n await this.getStore().deleteEnvironment(input.projectId, input.id);\n }\n}\n"],"mappings":";AAKA,OAAO,gBAAgB;AACvB,SAAS,uBAAuB,uBAAuB,2BAA2B;AAgB3E,IAAM,eAAN,MAA0C;AAAA,EAC/C,OAAO;AAAA,EACC;AAAA,EAEA,SAAS,OAAkD;AACjE,WAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAAA,EAC5E;AAAA,EAEQ,eAAe,OAAoC;AACzD,QAAI,CAAC,KAAK,SAAS,KAAK,EAAG,QAAO;AAClC,UAAM,WAAW,MAAM;AACvB,QAAI,OAAO,aAAa,YAAY,SAAS,SAAS,EAAG,QAAO;AAChE,UAAM,MAAM,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M,KAAK,SAAS,EAAE,aAAa;AACjD,WAAO,MAAM,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,MAAM,EAAE,MAAM,gBAAgB,EAAE,eAAe,EAAE;AAAA,EACxF;AAAA,EAEA,MAAM,iBAAiB,WAAsC;AAC3D,UAAM,OAAO,MAAM,KAAK,SAAS,EAAE,iBAAiB,SAAS;AAC7D,WAAO,KAAK,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,EAAE,KAAK,EAAE;AAAA,EACnE;AAAA,EAEA,MAAM,kBAAkB,OAA0E;AAChG,UAAM,KAAK,SAAS,EAAE,kBAAkB,MAAM,WAAW,MAAM,MAAM,MAAM,IAAI;AAAA,EACjF;AAAA,EAEA,MAAM,kBAAkB,OAAuF;AAC7G,UAAM,KAAK,SAAS,EAAE,kBAAkB,MAAM,WAAW,MAAM,IAAI;AAAA,MACjE,GAAI,MAAM,OAAO,EAAE,MAAM,MAAM,KAAK,IAAI,CAAC;AAAA,MACzC,GAAI,MAAM,OAAO,EAAE,MAAM,MAAM,KAAK,IAAI,CAAC;AAAA,IAC3C,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,kBAAkB,OAAyD;AAC/E,UAAM,KAAK,SAAS,EAAE,kBAAkB,MAAM,WAAW,MAAM,EAAE;AAAA,EACnE;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lazyenv/doppler",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Doppler integration for lazyenv",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/methodacting/lazyenv",
|
|
13
|
+
"directory": "packages/doppler"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/methodacting/lazyenv/issues"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/methodacting/lazyenv#readme",
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"module": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js",
|
|
26
|
+
"require": "./dist/index.cjs"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"LICENSE"
|
|
32
|
+
],
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@dopplerhq/node-sdk": "^1.3.0",
|
|
35
|
+
"@lazyenv/core": "0.2.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^20.19.30",
|
|
39
|
+
"tsup": "^8.5.1",
|
|
40
|
+
"typescript": "^5.3.0",
|
|
41
|
+
"vitest": "^1.6.1"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=20.0.0"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsup",
|
|
48
|
+
"dev": "tsup --watch",
|
|
49
|
+
"test": "vitest",
|
|
50
|
+
"test:ci": "vitest --run",
|
|
51
|
+
"typecheck": "tsc --noEmit"
|
|
52
|
+
}
|
|
53
|
+
}
|