dagger-env 0.6.8 → 1.0.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/README.md +16 -24
- package/dist/run-dagger-cmd.d.ts +17 -11
- package/dist/run-dagger-cmd.d.ts.map +1 -1
- package/dist/run-dagger-cmd.js +16 -21
- package/dist/run-dagger-cmd.js.map +1 -1
- package/package.json +2 -8
- package/src/examples/run-dagger-cmd-usage.ts +6 -15
- package/src/run-dagger-cmd.spec.ts +191 -0
- package/src/run-dagger-cmd.ts +34 -37
- package/dist/op.d.ts +0 -90
- package/dist/op.d.ts.map +0 -1
- package/dist/op.js +0 -34
- package/dist/op.js.map +0 -1
- package/src/op.ts +0 -58
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dagger-env
|
|
2
2
|
|
|
3
|
-
A type-safe, reusable environment configuration abstraction for Dagger modules with full Zod v4 validation and
|
|
3
|
+
A type-safe, reusable environment configuration abstraction for Dagger modules with full Zod v4 validation and Infisical integration.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ A type-safe, reusable environment configuration abstraction for Dagger modules w
|
|
|
9
9
|
- 🎯 **Consistent**: Standardized API across all Dagger modules
|
|
10
10
|
- 🛡️ **Validated**: Runtime validation of arguments, environment variables, and secrets
|
|
11
11
|
- 📦 **Modular**: Secret presets and derived environment variables
|
|
12
|
-
- 🔐 **
|
|
12
|
+
- 🔐 **Infisical Integration**: Built-in command runner backed by `infisical export`
|
|
13
13
|
- 🚀 **Easy to use**: Simple configuration-based setup
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
@@ -18,7 +18,7 @@ A type-safe, reusable environment configuration abstraction for Dagger modules w
|
|
|
18
18
|
npm install dagger-env zod
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
**Note:** The command runner functionality (`dagger-env/run`) requires the
|
|
21
|
+
**Note:** The command runner functionality (`dagger-env/run`) requires the Infisical CLI (`infisical`) to be installed and authenticated.
|
|
22
22
|
|
|
23
23
|
## Quick Start
|
|
24
24
|
|
|
@@ -73,9 +73,9 @@ export class MyModule {
|
|
|
73
73
|
}
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
## Command Runner (
|
|
76
|
+
## Command Runner (Infisical Integration)
|
|
77
77
|
|
|
78
|
-
For projects using
|
|
78
|
+
For projects using Infisical for secret management, `dagger-env` provides a convenient command runner that fetches secrets with `infisical export` and passes them to `dagger call` via the `DAGGER_OPTIONS` environment variable:
|
|
79
79
|
|
|
80
80
|
```typescript
|
|
81
81
|
import { createDaggerEnv } from 'dagger-env'
|
|
@@ -102,14 +102,9 @@ const myDaggerEnv = createDaggerEnv({
|
|
|
102
102
|
|
|
103
103
|
// Create a command runner - simply pass your DaggerEnv instance
|
|
104
104
|
const runDaggerCommand = createDaggerCommandRunner({
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
{
|
|
109
|
-
id: 'your-section-id',
|
|
110
|
-
label: 'Shared'
|
|
111
|
-
}
|
|
112
|
-
],
|
|
105
|
+
projectId: 'your-project-id',
|
|
106
|
+
env: 'prod',
|
|
107
|
+
path: '/ci/my-repo',
|
|
113
108
|
dockerCommands: ['build', 'deploy', 'test'],
|
|
114
109
|
daggerEnv: myDaggerEnv
|
|
115
110
|
})
|
|
@@ -124,14 +119,11 @@ await runDaggerCommand('test', {
|
|
|
124
119
|
### Advanced Configuration
|
|
125
120
|
|
|
126
121
|
```typescript
|
|
127
|
-
// Advanced configuration with
|
|
122
|
+
// Advanced configuration with pre-command setup
|
|
128
123
|
const runDaggerCommand = createDaggerCommandRunner({
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
{ id: 'shared-section-id', label: 'Shared' },
|
|
133
|
-
{ id: 'project-section-id', label: 'Project Specific' }
|
|
134
|
-
],
|
|
124
|
+
projectId: 'your-project-id',
|
|
125
|
+
env: 'prod',
|
|
126
|
+
path: '/ci/my-repo',
|
|
135
127
|
dockerCommands: ['build', 'deploy', 'test'],
|
|
136
128
|
beforeCommand: async () => {
|
|
137
129
|
// Setup vendor files, modules, etc.
|
|
@@ -208,13 +200,13 @@ Returns array of secret names for a specific preset.
|
|
|
208
200
|
|
|
209
201
|
#### `createDaggerCommandRunner(config)`
|
|
210
202
|
|
|
211
|
-
Creates a function to run Dagger commands with
|
|
203
|
+
Creates a function to run Dagger commands with Infisical integration.
|
|
212
204
|
|
|
213
205
|
**Parameters:**
|
|
214
206
|
|
|
215
|
-
- `config.
|
|
216
|
-
- `config.
|
|
217
|
-
- `config.
|
|
207
|
+
- `config.projectId`: Infisical project ID
|
|
208
|
+
- `config.env`: Infisical environment slug (e.g. `prod`)
|
|
209
|
+
- `config.path`: Infisical folder path to fetch secrets from (e.g. `/ci/my-repo`)
|
|
218
210
|
- `config.dockerCommands`: Optional array of command names that should include Docker socket
|
|
219
211
|
- `config.beforeCommand`: Optional async function to run before executing the command
|
|
220
212
|
- `config.daggerEnv`: DaggerEnv instance for schema validation and type safety
|
package/dist/run-dagger-cmd.d.ts
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
1
2
|
import type { DaggerEnv, DaggerEnvConfig } from './dagger-env.js';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* A single secret returned by `infisical export --format=json`
|
|
5
|
+
*/
|
|
6
|
+
export type InfisicalSecret = z.infer<typeof InfisicalSecret>;
|
|
7
|
+
export declare const InfisicalSecret: z.ZodObject<{
|
|
8
|
+
key: z.ZodString;
|
|
9
|
+
value: z.ZodString;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for running Dagger commands with Infisical integration
|
|
4
13
|
*/
|
|
5
14
|
export interface RunDaggerCommandConfig<T extends DaggerEnvConfig = DaggerEnvConfig> {
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
label: string;
|
|
13
|
-
id: string;
|
|
14
|
-
}>;
|
|
15
|
+
/** Infisical project ID */
|
|
16
|
+
projectId: string;
|
|
17
|
+
/** Infisical environment slug (e.g. `prod`) */
|
|
18
|
+
env: string;
|
|
19
|
+
/** Infisical folder path to fetch secrets from (e.g. `/ci/my-repo`) */
|
|
20
|
+
path: string;
|
|
15
21
|
/** Commands that should include Docker socket if available */
|
|
16
22
|
dockerCommands?: string[];
|
|
17
23
|
/** Hook to run before executing the command (e.g., vendor file setup) */
|
|
@@ -31,7 +37,7 @@ export interface RunDaggerCommandOptions {
|
|
|
31
37
|
extraArgs?: string[];
|
|
32
38
|
}
|
|
33
39
|
/**
|
|
34
|
-
* Creates a function to run Dagger commands with
|
|
40
|
+
* Creates a function to run Dagger commands with Infisical integration
|
|
35
41
|
* @param config Configuration for the command runner
|
|
36
42
|
* @returns Function to execute Dagger commands
|
|
37
43
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-dagger-cmd.d.ts","sourceRoot":"","sources":["../src/run-dagger-cmd.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run-dagger-cmd.d.ts","sourceRoot":"","sources":["../src/run-dagger-cmd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAG1B,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjE;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAC7D,eAAO,MAAM,eAAe;;;iBAG1B,CAAA;AAEF;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,eAAe,GAAG,eAAe;IAClF,2BAA2B;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,+CAA+C;IAC/C,GAAG,EAAE,MAAM,CAAA;IACX,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAA;IACZ,8DAA8D;IAC9D,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,yEAAyE;IACzE,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IACnC,+DAA+D;IAC/D,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAA;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,8CAA8C;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC1B,uCAAuC;IACvC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CACpB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,eAAe,EAClE,MAAM,EAAE,sBAAsB,CAAC,CAAC,CAAC,IAGhC,aAAa,MAAM,EACnB,UAAU,uBAAuB,KAC/B,OAAO,CAAC,IAAI,CAAC,CA8EhB"}
|
package/dist/run-dagger-cmd.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
1
2
|
import { $, fs } from 'zx';
|
|
2
|
-
|
|
3
|
+
export const InfisicalSecret = z.object({
|
|
4
|
+
key: z.string(),
|
|
5
|
+
value: z.string(),
|
|
6
|
+
});
|
|
3
7
|
/**
|
|
4
|
-
* Creates a function to run Dagger commands with
|
|
8
|
+
* Creates a function to run Dagger commands with Infisical integration
|
|
5
9
|
* @param config Configuration for the command runner
|
|
6
10
|
* @returns Function to execute Dagger commands
|
|
7
11
|
*/
|
|
8
12
|
export function createDaggerCommandRunner(config) {
|
|
9
|
-
const opItemUri = `op://${config.opVault}/${config.opItem}`;
|
|
10
13
|
return async function runDaggerCommand(commandName, options) {
|
|
11
14
|
const { args = {}, env = {}, extraArgs = [] } = options ?? {};
|
|
12
15
|
// Run any pre-command setup
|
|
13
16
|
if (config.beforeCommand) {
|
|
14
17
|
await config.beforeCommand();
|
|
15
18
|
}
|
|
16
|
-
// Environment variables to pass to the `
|
|
19
|
+
// Environment variables to pass to the `dagger` command
|
|
17
20
|
const envVars = {};
|
|
18
|
-
// Pass dagger cloud token in CI because we don't have user auth
|
|
19
|
-
if (process.env.CI !== undefined) {
|
|
20
|
-
envVars.DAGGER_CLOUD_TOKEN = `${opItemUri}/DAGGER_CLOUD_TOKEN`;
|
|
21
|
-
}
|
|
22
21
|
const commandArgs = [...extraArgs];
|
|
23
22
|
// Add Docker socket for specific commands if available
|
|
24
23
|
if (config.dockerCommands?.includes(commandName)) {
|
|
@@ -31,17 +30,17 @@ export function createDaggerCommandRunner(config) {
|
|
|
31
30
|
// Ignore if fs is not available or docker socket doesn't exist
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
|
-
// Fetch
|
|
35
|
-
const
|
|
36
|
-
//
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
const secrets = opItem.fields
|
|
40
|
-
.filter((f) => sectionsToInclude.some((s) => s.id === f.section?.id))
|
|
41
|
-
.reduce((acc, f) => {
|
|
42
|
-
acc[f.label] = f.value;
|
|
33
|
+
// Fetch secrets from Infisical
|
|
34
|
+
const exportedSecrets = InfisicalSecret.array().parse(await $ `infisical export --silent --format=json --projectId ${config.projectId} --env ${config.env} --path ${config.path}`.json());
|
|
35
|
+
// Extract secrets into a key/value map
|
|
36
|
+
const secrets = exportedSecrets.reduce((acc, s) => {
|
|
37
|
+
acc[s.key] = s.value;
|
|
43
38
|
return acc;
|
|
44
39
|
}, {});
|
|
40
|
+
// Pass dagger cloud token in CI because we don't have user auth
|
|
41
|
+
if (process.env.CI !== undefined && secrets.DAGGER_CLOUD_TOKEN !== undefined) {
|
|
42
|
+
envVars.DAGGER_CLOUD_TOKEN = secrets.DAGGER_CLOUD_TOKEN;
|
|
43
|
+
}
|
|
45
44
|
// Build environment variables for Dagger
|
|
46
45
|
const daggerEnv = { ...env };
|
|
47
46
|
if (process.env.CI !== undefined) {
|
|
@@ -59,10 +58,6 @@ export function createDaggerCommandRunner(config) {
|
|
|
59
58
|
envVars.DAGGER_OPTIONS = JSON.stringify(daggerOptions);
|
|
60
59
|
// Construct the command
|
|
61
60
|
const cmd = [
|
|
62
|
-
'op',
|
|
63
|
-
'run',
|
|
64
|
-
'--no-masking',
|
|
65
|
-
'--',
|
|
66
61
|
'dagger',
|
|
67
62
|
'call',
|
|
68
63
|
commandName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-dagger-cmd.js","sourceRoot":"","sources":["../src/run-dagger-cmd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"run-dagger-cmd.js","sourceRoot":"","sources":["../src/run-dagger-cmd.ts"],"names":[],"mappings":"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","sourcesContent":["import { z } from 'zod/v4'\nimport { $, fs } from 'zx'\n\nimport type { DaggerEnv, DaggerEnvConfig } from './dagger-env.js'\n\n/**\n * A single secret returned by `infisical export --format=json`\n */\nexport type InfisicalSecret = z.infer<typeof InfisicalSecret>\nexport const InfisicalSecret = z.object({\n\tkey: z.string(),\n\tvalue: z.string(),\n})\n\n/**\n * Configuration for running Dagger commands with Infisical integration\n */\nexport interface RunDaggerCommandConfig<T extends DaggerEnvConfig = DaggerEnvConfig> {\n\t/** Infisical project ID */\n\tprojectId: string\n\t/** Infisical environment slug (e.g. `prod`) */\n\tenv: string\n\t/** Infisical folder path to fetch secrets from (e.g. `/ci/my-repo`) */\n\tpath: string\n\t/** Commands that should include Docker socket if available */\n\tdockerCommands?: string[]\n\t/** Hook to run before executing the command (e.g., vendor file setup) */\n\tbeforeCommand?: () => Promise<void>\n\t/** DaggerEnv instance for schema validation and type safety */\n\tdaggerEnv: DaggerEnv<T>\n}\n\n/**\n * Options for individual command execution\n */\nexport interface RunDaggerCommandOptions {\n\t/** Arguments to pass to the Dagger command */\n\targs?: Record<string, any>\n\t/** Additional environment variables */\n\tenv?: Record<string, string>\n\t/** Additional command-line arguments */\n\textraArgs?: string[]\n}\n\n/**\n * Creates a function to run Dagger commands with Infisical integration\n * @param config Configuration for the command runner\n * @returns Function to execute Dagger commands\n */\nexport function createDaggerCommandRunner<T extends DaggerEnvConfig>(\n\tconfig: RunDaggerCommandConfig<T>\n) {\n\treturn async function runDaggerCommand(\n\t\tcommandName: string,\n\t\toptions?: RunDaggerCommandOptions\n\t): Promise<void> {\n\t\tconst { args = {}, env = {}, extraArgs = [] } = options ?? {}\n\n\t\t// Run any pre-command setup\n\t\tif (config.beforeCommand) {\n\t\t\tawait config.beforeCommand()\n\t\t}\n\n\t\t// Environment variables to pass to the `dagger` command\n\t\tconst envVars: Record<string, string> = {}\n\n\t\tconst commandArgs: string[] = [...extraArgs]\n\n\t\t// Add Docker socket for specific commands if available\n\t\tif (config.dockerCommands?.includes(commandName)) {\n\t\t\ttry {\n\t\t\t\tif (await fs.exists('/var/run/docker.sock')) {\n\t\t\t\t\tcommandArgs.push('--docker-socket=/var/run/docker.sock')\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Ignore if fs is not available or docker socket doesn't exist\n\t\t\t}\n\t\t}\n\n\t\t// Fetch secrets from Infisical\n\t\tconst exportedSecrets = InfisicalSecret.array().parse(\n\t\t\tawait $`infisical export --silent --format=json --projectId ${config.projectId} --env ${config.env} --path ${config.path}`.json()\n\t\t)\n\n\t\t// Extract secrets into a key/value map\n\t\tconst secrets = exportedSecrets.reduce(\n\t\t\t(acc, s) => {\n\t\t\t\tacc[s.key] = s.value\n\t\t\t\treturn acc\n\t\t\t},\n\t\t\t{} as Record<string, string>\n\t\t)\n\n\t\t// Pass dagger cloud token in CI because we don't have user auth\n\t\tif (process.env.CI !== undefined && secrets.DAGGER_CLOUD_TOKEN !== undefined) {\n\t\t\tenvVars.DAGGER_CLOUD_TOKEN = secrets.DAGGER_CLOUD_TOKEN\n\t\t}\n\n\t\t// Build environment variables for Dagger\n\t\tconst daggerEnv: Record<string, string> = { ...env }\n\t\tif (process.env.CI !== undefined) {\n\t\t\tdaggerEnv.CI = process.env.CI\n\t\t}\n\t\tif (process.env.GITHUB_ACTIONS !== undefined) {\n\t\t\tdaggerEnv.GITHUB_ACTIONS = process.env.GITHUB_ACTIONS\n\t\t}\n\n\t\t// Validate and serialize dagger options\n\t\tconst daggerOptions = config.daggerEnv.getOptionsSchema().parse({\n\t\t\targs,\n\t\t\tenv: daggerEnv,\n\t\t\tsecrets,\n\t\t})\n\t\tenvVars.DAGGER_OPTIONS = JSON.stringify(daggerOptions)\n\n\t\t// Construct the command\n\t\tconst cmd: string[] = [\n\t\t\t'dagger',\n\t\t\t'call',\n\t\t\tcommandName,\n\t\t\t...commandArgs,\n\t\t\t'--options=env://DAGGER_OPTIONS',\n\t\t]\n\n\t\t// Execute the command\n\t\tawait $({\n\t\t\tenv: {\n\t\t\t\t...process.env,\n\t\t\t\t...envVars,\n\t\t\t},\n\t\t\tstdio: 'inherit',\n\t\t})`${cmd}`\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dagger-env",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A type-safe, reusable environment configuration abstraction for Dagger modules.",
|
|
6
6
|
"keywords": [
|
|
@@ -28,12 +28,6 @@
|
|
|
28
28
|
"default": "./dist/index.js"
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
|
-
"./op": {
|
|
32
|
-
"import": {
|
|
33
|
-
"types": "./dist/op.d.ts",
|
|
34
|
-
"default": "./dist/op.js"
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
31
|
"./run": {
|
|
38
32
|
"import": {
|
|
39
33
|
"types": "./dist/run-dagger-cmd.d.ts",
|
|
@@ -65,7 +59,7 @@
|
|
|
65
59
|
"access": "public"
|
|
66
60
|
},
|
|
67
61
|
"scripts": {
|
|
68
|
-
"build": "runx build tsc ./src/index.ts ./src/
|
|
62
|
+
"build": "runx build tsc ./src/index.ts ./src/run-dagger-cmd.ts",
|
|
69
63
|
"check:exports": "runx check --exports",
|
|
70
64
|
"check:lint": "run-eslint",
|
|
71
65
|
"check:types": "run-tsc",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Example usage of the runDaggerCommand abstraction
|
|
3
3
|
*
|
|
4
4
|
* This example shows a realistic configuration for a project that uses Dagger
|
|
5
|
-
* with
|
|
5
|
+
* with Infisical integration for secret management.
|
|
6
6
|
*
|
|
7
7
|
* Import pattern:
|
|
8
8
|
* - Main DaggerEnv functionality: import { createDaggerEnv } from 'dagger-env'
|
|
@@ -56,21 +56,12 @@ const daggerEnv = createDaggerEnv({
|
|
|
56
56
|
derivedEnvVars: {} as const,
|
|
57
57
|
})
|
|
58
58
|
|
|
59
|
-
// Create the command runner with
|
|
59
|
+
// Create the command runner with Infisical configuration
|
|
60
60
|
export const runDaggerCommand = createDaggerCommandRunner({
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
{
|
|
66
|
-
id: 'shared-section-id',
|
|
67
|
-
label: 'Shared',
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
id: 'production-section-id',
|
|
71
|
-
label: 'Production',
|
|
72
|
-
},
|
|
73
|
-
],
|
|
61
|
+
// Infisical configuration
|
|
62
|
+
projectId: 'your-project-id', // Replace with your actual Infisical project ID
|
|
63
|
+
env: 'prod', // Infisical environment slug
|
|
64
|
+
path: '/ci/my-repo', // Infisical folder path to fetch secrets from
|
|
74
65
|
// Commands that need Docker socket access
|
|
75
66
|
dockerCommands: ['build', 'test', 'deploy', 'migrate', 'seed'],
|
|
76
67
|
// Optional: Run setup before executing commands
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { z } from 'zod/v4'
|
|
3
|
+
|
|
4
|
+
import { createDaggerEnv } from './dagger-env'
|
|
5
|
+
import { createDaggerCommandRunner } from './run-dagger-cmd'
|
|
6
|
+
|
|
7
|
+
import type { RunDaggerCommandConfig } from './run-dagger-cmd'
|
|
8
|
+
|
|
9
|
+
const mocks = vi.hoisted(() => ({
|
|
10
|
+
/** Resolves the JSON payload returned by `infisical export` */
|
|
11
|
+
exportJson: vi.fn(),
|
|
12
|
+
/** Records the rendered `infisical export` command string */
|
|
13
|
+
exportCmd: vi.fn(),
|
|
14
|
+
/** Records the final command execution: (options, argv) */
|
|
15
|
+
spawn: vi.fn(
|
|
16
|
+
async (_opts: { env: Record<string, string | undefined> }, _argv: string[]) => undefined
|
|
17
|
+
),
|
|
18
|
+
/** Mock for fs.exists() (docker socket probe) */
|
|
19
|
+
exists: vi.fn(async () => false),
|
|
20
|
+
}))
|
|
21
|
+
|
|
22
|
+
vi.mock('zx', () => {
|
|
23
|
+
const $ = (firstArg: unknown, ...vals: unknown[]) => {
|
|
24
|
+
if (Array.isArray(firstArg)) {
|
|
25
|
+
// Direct template call: $`infisical export ...`
|
|
26
|
+
const pieces = firstArg as readonly string[]
|
|
27
|
+
const cmd = pieces.reduce(
|
|
28
|
+
(acc, piece, i) => acc + piece + (i < vals.length ? String(vals[i]) : ''),
|
|
29
|
+
''
|
|
30
|
+
)
|
|
31
|
+
mocks.exportCmd(cmd)
|
|
32
|
+
return { json: mocks.exportJson }
|
|
33
|
+
}
|
|
34
|
+
// Options call: $({ env, stdio }) returns a template executor
|
|
35
|
+
return (_pieces: TemplateStringsArray, ...templateVals: unknown[]) =>
|
|
36
|
+
mocks.spawn(
|
|
37
|
+
firstArg as { env: Record<string, string | undefined> },
|
|
38
|
+
templateVals[0] as string[]
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
return { $, fs: { exists: mocks.exists } }
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Environment variables passed to the spawned process
|
|
46
|
+
*/
|
|
47
|
+
type SpawnEnv = Record<string, string | undefined>
|
|
48
|
+
|
|
49
|
+
function getSpawnCall(): { env: SpawnEnv; argv: string[] } {
|
|
50
|
+
expect(mocks.spawn).toHaveBeenCalledTimes(1)
|
|
51
|
+
const call = mocks.spawn.mock.calls.at(0)
|
|
52
|
+
if (!call) {
|
|
53
|
+
throw new Error('spawn was not called')
|
|
54
|
+
}
|
|
55
|
+
const [opts, argv] = call
|
|
56
|
+
return { env: opts.env, argv }
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function createRunner(overrides?: Partial<Pick<RunDaggerCommandConfig, 'dockerCommands'>>) {
|
|
60
|
+
const daggerEnv = createDaggerEnv({
|
|
61
|
+
args: z.object({
|
|
62
|
+
push: z.string().optional(),
|
|
63
|
+
}),
|
|
64
|
+
env: z.object({
|
|
65
|
+
CI: z.string().optional(),
|
|
66
|
+
GITHUB_ACTIONS: z.string().optional(),
|
|
67
|
+
NODE_ENV: z.string().optional(),
|
|
68
|
+
}),
|
|
69
|
+
secrets: z.object({
|
|
70
|
+
API_TOKEN: z.string(),
|
|
71
|
+
}),
|
|
72
|
+
secretPresets: {
|
|
73
|
+
api: ['API_TOKEN'],
|
|
74
|
+
},
|
|
75
|
+
derivedEnvVars: {},
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
return createDaggerCommandRunner({
|
|
79
|
+
projectId: 'test-project-id',
|
|
80
|
+
env: 'prod',
|
|
81
|
+
path: '/ci/test',
|
|
82
|
+
daggerEnv,
|
|
83
|
+
...overrides,
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
describe('createDaggerCommandRunner()', () => {
|
|
88
|
+
beforeEach(() => {
|
|
89
|
+
vi.clearAllMocks()
|
|
90
|
+
vi.stubEnv('CI', undefined)
|
|
91
|
+
vi.stubEnv('GITHUB_ACTIONS', undefined)
|
|
92
|
+
vi.stubEnv('DAGGER_CLOUD_TOKEN', undefined)
|
|
93
|
+
mocks.exportJson.mockResolvedValue([
|
|
94
|
+
{ key: 'API_TOKEN', value: 'test-api-token', comment: '' },
|
|
95
|
+
{ key: 'DAGGER_CLOUD_TOKEN', value: 'test-dagger-cloud-token', comment: '' },
|
|
96
|
+
])
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
afterEach(() => {
|
|
100
|
+
vi.unstubAllEnvs()
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('builds the expected DAGGER_OPTIONS payload from the infisical export', async () => {
|
|
104
|
+
const runDaggerCommand = createRunner()
|
|
105
|
+
await runDaggerCommand('test-cmd', {
|
|
106
|
+
args: { push: 'true' },
|
|
107
|
+
env: { NODE_ENV: 'production' },
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
expect(mocks.exportCmd).toHaveBeenCalledWith(
|
|
111
|
+
'infisical export --silent --format=json --projectId test-project-id --env prod --path /ci/test'
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
const { env } = getSpawnCall()
|
|
115
|
+
expect(JSON.parse(env.DAGGER_OPTIONS as string)).toStrictEqual({
|
|
116
|
+
args: { push: 'true' },
|
|
117
|
+
env: { NODE_ENV: 'production' },
|
|
118
|
+
secrets: { API_TOKEN: 'test-api-token' },
|
|
119
|
+
})
|
|
120
|
+
expect(env.DAGGER_CLOUD_TOKEN).toBeUndefined()
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
it('passes DAGGER_CLOUD_TOKEN to the runner env (but not DAGGER_OPTIONS) in CI', async () => {
|
|
124
|
+
vi.stubEnv('CI', 'true')
|
|
125
|
+
vi.stubEnv('GITHUB_ACTIONS', 'true')
|
|
126
|
+
|
|
127
|
+
const runDaggerCommand = createRunner()
|
|
128
|
+
await runDaggerCommand('test-cmd')
|
|
129
|
+
|
|
130
|
+
const { env } = getSpawnCall()
|
|
131
|
+
const daggerOptions = JSON.parse(env.DAGGER_OPTIONS as string)
|
|
132
|
+
expect(daggerOptions.secrets).not.toHaveProperty('DAGGER_CLOUD_TOKEN')
|
|
133
|
+
expect(daggerOptions.env).toStrictEqual({ CI: 'true', GITHUB_ACTIONS: 'true' })
|
|
134
|
+
expect(env.DAGGER_CLOUD_TOKEN).toBe('test-dagger-cloud-token')
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
it('spawns dagger directly without an op wrapper', async () => {
|
|
138
|
+
const runDaggerCommand = createRunner()
|
|
139
|
+
await runDaggerCommand('test-cmd', { extraArgs: ['--verbose'] })
|
|
140
|
+
|
|
141
|
+
const { argv } = getSpawnCall()
|
|
142
|
+
expect(argv[0]).toBe('dagger')
|
|
143
|
+
expect(argv).not.toContain('op')
|
|
144
|
+
expect(argv).toStrictEqual([
|
|
145
|
+
'dagger',
|
|
146
|
+
'call',
|
|
147
|
+
'test-cmd',
|
|
148
|
+
'--verbose',
|
|
149
|
+
'--options=env://DAGGER_OPTIONS',
|
|
150
|
+
])
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
describe('docker socket', () => {
|
|
154
|
+
it('appends --docker-socket for dockerCommands when the socket exists', async () => {
|
|
155
|
+
mocks.exists.mockResolvedValue(true)
|
|
156
|
+
|
|
157
|
+
const runDaggerCommand = createRunner({ dockerCommands: ['build'] })
|
|
158
|
+
await runDaggerCommand('build')
|
|
159
|
+
|
|
160
|
+
const { argv } = getSpawnCall()
|
|
161
|
+
expect(argv).toStrictEqual([
|
|
162
|
+
'dagger',
|
|
163
|
+
'call',
|
|
164
|
+
'build',
|
|
165
|
+
'--docker-socket=/var/run/docker.sock',
|
|
166
|
+
'--options=env://DAGGER_OPTIONS',
|
|
167
|
+
])
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
it('does not append --docker-socket for non-docker commands', async () => {
|
|
171
|
+
mocks.exists.mockResolvedValue(true)
|
|
172
|
+
|
|
173
|
+
const runDaggerCommand = createRunner({ dockerCommands: ['build'] })
|
|
174
|
+
await runDaggerCommand('test-cmd')
|
|
175
|
+
|
|
176
|
+
const { argv } = getSpawnCall()
|
|
177
|
+
expect(argv).not.toContain('--docker-socket=/var/run/docker.sock')
|
|
178
|
+
expect(mocks.exists).not.toHaveBeenCalled()
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
it('does not append --docker-socket when the socket does not exist', async () => {
|
|
182
|
+
mocks.exists.mockResolvedValue(false)
|
|
183
|
+
|
|
184
|
+
const runDaggerCommand = createRunner({ dockerCommands: ['build'] })
|
|
185
|
+
await runDaggerCommand('build')
|
|
186
|
+
|
|
187
|
+
const { argv } = getSpawnCall()
|
|
188
|
+
expect(argv).not.toContain('--docker-socket=/var/run/docker.sock')
|
|
189
|
+
})
|
|
190
|
+
})
|
|
191
|
+
})
|
package/src/run-dagger-cmd.ts
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod/v4'
|
|
1
2
|
import { $, fs } from 'zx'
|
|
2
3
|
|
|
3
|
-
import { OPItem, OPSection } from './op.js'
|
|
4
|
-
|
|
5
4
|
import type { DaggerEnv, DaggerEnvConfig } from './dagger-env.js'
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
7
|
+
* A single secret returned by `infisical export --format=json`
|
|
8
|
+
*/
|
|
9
|
+
export type InfisicalSecret = z.infer<typeof InfisicalSecret>
|
|
10
|
+
export const InfisicalSecret = z.object({
|
|
11
|
+
key: z.string(),
|
|
12
|
+
value: z.string(),
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Configuration for running Dagger commands with Infisical integration
|
|
9
17
|
*/
|
|
10
18
|
export interface RunDaggerCommandConfig<T extends DaggerEnvConfig = DaggerEnvConfig> {
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
|
|
19
|
+
/** Infisical project ID */
|
|
20
|
+
projectId: string
|
|
21
|
+
/** Infisical environment slug (e.g. `prod`) */
|
|
22
|
+
env: string
|
|
23
|
+
/** Infisical folder path to fetch secrets from (e.g. `/ci/my-repo`) */
|
|
24
|
+
path: string
|
|
17
25
|
/** Commands that should include Docker socket if available */
|
|
18
26
|
dockerCommands?: string[]
|
|
19
27
|
/** Hook to run before executing the command (e.g., vendor file setup) */
|
|
@@ -35,15 +43,13 @@ export interface RunDaggerCommandOptions {
|
|
|
35
43
|
}
|
|
36
44
|
|
|
37
45
|
/**
|
|
38
|
-
* Creates a function to run Dagger commands with
|
|
46
|
+
* Creates a function to run Dagger commands with Infisical integration
|
|
39
47
|
* @param config Configuration for the command runner
|
|
40
48
|
* @returns Function to execute Dagger commands
|
|
41
49
|
*/
|
|
42
50
|
export function createDaggerCommandRunner<T extends DaggerEnvConfig>(
|
|
43
51
|
config: RunDaggerCommandConfig<T>
|
|
44
52
|
) {
|
|
45
|
-
const opItemUri = `op://${config.opVault}/${config.opItem}`
|
|
46
|
-
|
|
47
53
|
return async function runDaggerCommand(
|
|
48
54
|
commandName: string,
|
|
49
55
|
options?: RunDaggerCommandOptions
|
|
@@ -55,14 +61,9 @@ export function createDaggerCommandRunner<T extends DaggerEnvConfig>(
|
|
|
55
61
|
await config.beforeCommand()
|
|
56
62
|
}
|
|
57
63
|
|
|
58
|
-
// Environment variables to pass to the `
|
|
64
|
+
// Environment variables to pass to the `dagger` command
|
|
59
65
|
const envVars: Record<string, string> = {}
|
|
60
66
|
|
|
61
|
-
// Pass dagger cloud token in CI because we don't have user auth
|
|
62
|
-
if (process.env.CI !== undefined) {
|
|
63
|
-
envVars.DAGGER_CLOUD_TOKEN = `${opItemUri}/DAGGER_CLOUD_TOKEN`
|
|
64
|
-
}
|
|
65
|
-
|
|
66
67
|
const commandArgs: string[] = [...extraArgs]
|
|
67
68
|
|
|
68
69
|
// Add Docker socket for specific commands if available
|
|
@@ -76,24 +77,24 @@ export function createDaggerCommandRunner<T extends DaggerEnvConfig>(
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
// Fetch
|
|
80
|
-
const
|
|
81
|
-
await $`
|
|
80
|
+
// Fetch secrets from Infisical
|
|
81
|
+
const exportedSecrets = InfisicalSecret.array().parse(
|
|
82
|
+
await $`infisical export --silent --format=json --projectId ${config.projectId} --env ${config.env} --path ${config.path}`.json()
|
|
82
83
|
)
|
|
83
84
|
|
|
84
|
-
//
|
|
85
|
-
const
|
|
85
|
+
// Extract secrets into a key/value map
|
|
86
|
+
const secrets = exportedSecrets.reduce(
|
|
87
|
+
(acc, s) => {
|
|
88
|
+
acc[s.key] = s.value
|
|
89
|
+
return acc
|
|
90
|
+
},
|
|
91
|
+
{} as Record<string, string>
|
|
92
|
+
)
|
|
86
93
|
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
.
|
|
90
|
-
|
|
91
|
-
(acc, f) => {
|
|
92
|
-
acc[f.label] = f.value
|
|
93
|
-
return acc
|
|
94
|
-
},
|
|
95
|
-
{} as Record<string, string>
|
|
96
|
-
)
|
|
94
|
+
// Pass dagger cloud token in CI because we don't have user auth
|
|
95
|
+
if (process.env.CI !== undefined && secrets.DAGGER_CLOUD_TOKEN !== undefined) {
|
|
96
|
+
envVars.DAGGER_CLOUD_TOKEN = secrets.DAGGER_CLOUD_TOKEN
|
|
97
|
+
}
|
|
97
98
|
|
|
98
99
|
// Build environment variables for Dagger
|
|
99
100
|
const daggerEnv: Record<string, string> = { ...env }
|
|
@@ -114,10 +115,6 @@ export function createDaggerCommandRunner<T extends DaggerEnvConfig>(
|
|
|
114
115
|
|
|
115
116
|
// Construct the command
|
|
116
117
|
const cmd: string[] = [
|
|
117
|
-
'op',
|
|
118
|
-
'run',
|
|
119
|
-
'--no-masking',
|
|
120
|
-
'--',
|
|
121
118
|
'dagger',
|
|
122
119
|
'call',
|
|
123
120
|
commandName,
|
package/dist/op.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod/v4';
|
|
2
|
-
/**
|
|
3
|
-
* 1Password vault information
|
|
4
|
-
*/
|
|
5
|
-
export type OPVault = z.infer<typeof OPVault>;
|
|
6
|
-
export declare const OPVault: z.ZodObject<{
|
|
7
|
-
id: z.ZodString;
|
|
8
|
-
name: z.ZodString;
|
|
9
|
-
}, z.core.$strip>;
|
|
10
|
-
/**
|
|
11
|
-
* 1Password item section information
|
|
12
|
-
*/
|
|
13
|
-
export type OPSection = z.infer<typeof OPSection>;
|
|
14
|
-
export declare const OPSection: z.ZodObject<{
|
|
15
|
-
id: z.ZodString;
|
|
16
|
-
label: z.ZodOptional<z.ZodString>;
|
|
17
|
-
}, z.core.$strip>;
|
|
18
|
-
/**
|
|
19
|
-
* 1Password item field
|
|
20
|
-
*/
|
|
21
|
-
export type OPField = z.infer<typeof OPField>;
|
|
22
|
-
export declare const OPField: z.ZodObject<{
|
|
23
|
-
id: z.ZodString;
|
|
24
|
-
section: z.ZodOptional<z.ZodObject<{
|
|
25
|
-
id: z.ZodString;
|
|
26
|
-
label: z.ZodOptional<z.ZodString>;
|
|
27
|
-
}, z.core.$strip>>;
|
|
28
|
-
type: z.ZodEnum<{
|
|
29
|
-
STRING: "STRING";
|
|
30
|
-
CONCEALED: "CONCEALED";
|
|
31
|
-
MONTH_YEAR: "MONTH_YEAR";
|
|
32
|
-
}>;
|
|
33
|
-
purpose: z.ZodOptional<z.ZodEnum<{
|
|
34
|
-
NOTES: "NOTES";
|
|
35
|
-
}>>;
|
|
36
|
-
label: z.ZodString;
|
|
37
|
-
value: z.ZodString;
|
|
38
|
-
reference: z.ZodString;
|
|
39
|
-
}, z.core.$strip>;
|
|
40
|
-
/**
|
|
41
|
-
* 1Password item category
|
|
42
|
-
*/
|
|
43
|
-
export type OPCategory = z.infer<typeof OPCategory>;
|
|
44
|
-
export declare const OPCategory: z.ZodEnum<{
|
|
45
|
-
SECURE_NOTE: "SECURE_NOTE";
|
|
46
|
-
}>;
|
|
47
|
-
/**
|
|
48
|
-
* Complete 1Password item structure
|
|
49
|
-
*/
|
|
50
|
-
export type OPItem = z.infer<typeof OPItem>;
|
|
51
|
-
export declare const OPItem: z.ZodObject<{
|
|
52
|
-
id: z.ZodString;
|
|
53
|
-
title: z.ZodString;
|
|
54
|
-
favorite: z.ZodBoolean;
|
|
55
|
-
version: z.ZodInt;
|
|
56
|
-
vault: z.ZodObject<{
|
|
57
|
-
id: z.ZodString;
|
|
58
|
-
name: z.ZodString;
|
|
59
|
-
}, z.core.$strip>;
|
|
60
|
-
category: z.ZodEnum<{
|
|
61
|
-
SECURE_NOTE: "SECURE_NOTE";
|
|
62
|
-
}>;
|
|
63
|
-
last_edited_by: z.ZodString;
|
|
64
|
-
created_at: z.ZodISODateTime;
|
|
65
|
-
updated_at: z.ZodISODateTime;
|
|
66
|
-
additional_information: z.ZodString;
|
|
67
|
-
sections: z.ZodArray<z.ZodObject<{
|
|
68
|
-
id: z.ZodString;
|
|
69
|
-
label: z.ZodOptional<z.ZodString>;
|
|
70
|
-
}, z.core.$strip>>;
|
|
71
|
-
fields: z.ZodArray<z.ZodObject<{
|
|
72
|
-
id: z.ZodString;
|
|
73
|
-
section: z.ZodOptional<z.ZodObject<{
|
|
74
|
-
id: z.ZodString;
|
|
75
|
-
label: z.ZodOptional<z.ZodString>;
|
|
76
|
-
}, z.core.$strip>>;
|
|
77
|
-
type: z.ZodEnum<{
|
|
78
|
-
STRING: "STRING";
|
|
79
|
-
CONCEALED: "CONCEALED";
|
|
80
|
-
MONTH_YEAR: "MONTH_YEAR";
|
|
81
|
-
}>;
|
|
82
|
-
purpose: z.ZodOptional<z.ZodEnum<{
|
|
83
|
-
NOTES: "NOTES";
|
|
84
|
-
}>>;
|
|
85
|
-
label: z.ZodString;
|
|
86
|
-
value: z.ZodString;
|
|
87
|
-
reference: z.ZodString;
|
|
88
|
-
}, z.core.$strip>>;
|
|
89
|
-
}, z.core.$strip>;
|
|
90
|
-
//# sourceMappingURL=op.d.ts.map
|
package/dist/op.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"op.d.ts","sourceRoot":"","sources":["../src/op.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,CAAA;AAC7C,eAAO,MAAM,OAAO;;;iBAGlB,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA;AACjD,eAAO,MAAM,SAAS;;;iBAGpB,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,CAAA;AAC7C,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;iBAQlB,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAA;AACnD,eAAO,MAAM,UAAU;;EAA0B,CAAA;AAEjD;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,CAAA;AAC3C,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAajB,CAAA"}
|
package/dist/op.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod/v4';
|
|
2
|
-
export const OPVault = z.object({
|
|
3
|
-
id: z.string(),
|
|
4
|
-
name: z.string(),
|
|
5
|
-
});
|
|
6
|
-
export const OPSection = z.object({
|
|
7
|
-
id: z.string(),
|
|
8
|
-
label: z.string().optional(),
|
|
9
|
-
});
|
|
10
|
-
export const OPField = z.object({
|
|
11
|
-
id: z.string(),
|
|
12
|
-
section: OPSection.optional(),
|
|
13
|
-
type: z.enum(['STRING', 'CONCEALED', 'MONTH_YEAR']),
|
|
14
|
-
purpose: z.enum(['NOTES']).optional(),
|
|
15
|
-
label: z.string(),
|
|
16
|
-
value: z.string(),
|
|
17
|
-
reference: z.string(),
|
|
18
|
-
});
|
|
19
|
-
export const OPCategory = z.enum(['SECURE_NOTE']);
|
|
20
|
-
export const OPItem = z.object({
|
|
21
|
-
id: z.string(),
|
|
22
|
-
title: z.string(),
|
|
23
|
-
favorite: z.boolean(),
|
|
24
|
-
version: z.int(),
|
|
25
|
-
vault: OPVault,
|
|
26
|
-
category: OPCategory,
|
|
27
|
-
last_edited_by: z.string(),
|
|
28
|
-
created_at: z.iso.datetime(),
|
|
29
|
-
updated_at: z.iso.datetime(),
|
|
30
|
-
additional_information: z.string(),
|
|
31
|
-
sections: z.array(OPSection),
|
|
32
|
-
fields: z.array(OPField),
|
|
33
|
-
});
|
|
34
|
-
//# sourceMappingURL=op.js.map
|
package/dist/op.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"op.js","sourceRoot":"","sources":["../src/op.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAM1B,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;CAChB,CAAC,CAAA;AAMF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC5B,CAAC,CAAA;AAMF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,OAAO,EAAE,SAAS,CAAC,QAAQ,EAAE;IAC7B,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;IACnD,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE;IACrC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACrB,CAAC,CAAA;AAMF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,CAAC,CAAA;AAMjD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;IACrB,OAAO,EAAE,CAAC,CAAC,GAAG,EAAE;IAChB,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;IACpB,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,UAAU,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE;IAC5B,UAAU,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE;IAC5B,sBAAsB,EAAE,CAAC,CAAC,MAAM,EAAE;IAClC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;IAC5B,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;CACxB,CAAC,CAAA","sourcesContent":["import { z } from 'zod/v4'\n\n/**\n * 1Password vault information\n */\nexport type OPVault = z.infer<typeof OPVault>\nexport const OPVault = z.object({\n\tid: z.string(),\n\tname: z.string(),\n})\n\n/**\n * 1Password item section information\n */\nexport type OPSection = z.infer<typeof OPSection>\nexport const OPSection = z.object({\n\tid: z.string(),\n\tlabel: z.string().optional(),\n})\n\n/**\n * 1Password item field\n */\nexport type OPField = z.infer<typeof OPField>\nexport const OPField = z.object({\n\tid: z.string(),\n\tsection: OPSection.optional(),\n\ttype: z.enum(['STRING', 'CONCEALED', 'MONTH_YEAR']),\n\tpurpose: z.enum(['NOTES']).optional(),\n\tlabel: z.string(),\n\tvalue: z.string(),\n\treference: z.string(),\n})\n\n/**\n * 1Password item category\n */\nexport type OPCategory = z.infer<typeof OPCategory>\nexport const OPCategory = z.enum(['SECURE_NOTE'])\n\n/**\n * Complete 1Password item structure\n */\nexport type OPItem = z.infer<typeof OPItem>\nexport const OPItem = z.object({\n\tid: z.string(),\n\ttitle: z.string(),\n\tfavorite: z.boolean(),\n\tversion: z.int(),\n\tvault: OPVault,\n\tcategory: OPCategory,\n\tlast_edited_by: z.string(),\n\tcreated_at: z.iso.datetime(),\n\tupdated_at: z.iso.datetime(),\n\tadditional_information: z.string(),\n\tsections: z.array(OPSection),\n\tfields: z.array(OPField),\n})\n"]}
|
package/src/op.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod/v4'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 1Password vault information
|
|
5
|
-
*/
|
|
6
|
-
export type OPVault = z.infer<typeof OPVault>
|
|
7
|
-
export const OPVault = z.object({
|
|
8
|
-
id: z.string(),
|
|
9
|
-
name: z.string(),
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 1Password item section information
|
|
14
|
-
*/
|
|
15
|
-
export type OPSection = z.infer<typeof OPSection>
|
|
16
|
-
export const OPSection = z.object({
|
|
17
|
-
id: z.string(),
|
|
18
|
-
label: z.string().optional(),
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* 1Password item field
|
|
23
|
-
*/
|
|
24
|
-
export type OPField = z.infer<typeof OPField>
|
|
25
|
-
export const OPField = z.object({
|
|
26
|
-
id: z.string(),
|
|
27
|
-
section: OPSection.optional(),
|
|
28
|
-
type: z.enum(['STRING', 'CONCEALED', 'MONTH_YEAR']),
|
|
29
|
-
purpose: z.enum(['NOTES']).optional(),
|
|
30
|
-
label: z.string(),
|
|
31
|
-
value: z.string(),
|
|
32
|
-
reference: z.string(),
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 1Password item category
|
|
37
|
-
*/
|
|
38
|
-
export type OPCategory = z.infer<typeof OPCategory>
|
|
39
|
-
export const OPCategory = z.enum(['SECURE_NOTE'])
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Complete 1Password item structure
|
|
43
|
-
*/
|
|
44
|
-
export type OPItem = z.infer<typeof OPItem>
|
|
45
|
-
export const OPItem = z.object({
|
|
46
|
-
id: z.string(),
|
|
47
|
-
title: z.string(),
|
|
48
|
-
favorite: z.boolean(),
|
|
49
|
-
version: z.int(),
|
|
50
|
-
vault: OPVault,
|
|
51
|
-
category: OPCategory,
|
|
52
|
-
last_edited_by: z.string(),
|
|
53
|
-
created_at: z.iso.datetime(),
|
|
54
|
-
updated_at: z.iso.datetime(),
|
|
55
|
-
additional_information: z.string(),
|
|
56
|
-
sections: z.array(OPSection),
|
|
57
|
-
fields: z.array(OPField),
|
|
58
|
-
})
|