@shipfox/client-secrets 5.0.0 → 6.0.2
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +49 -0
- package/dist/components/form-errors.d.ts.map +1 -1
- package/dist/components/form-errors.js +0 -6
- package/dist/components/form-errors.js.map +1 -1
- package/dist/components/secret-form.d.ts.map +1 -1
- package/dist/components/secret-form.js +6 -8
- package/dist/components/secret-form.js.map +1 -1
- package/dist/components/variable-form.d.ts.map +1 -1
- package/dist/components/variable-form.js +6 -8
- package/dist/components/variable-form.js.map +1 -1
- package/dist/components/workspace-secrets-section.d.ts.map +1 -1
- package/dist/components/workspace-secrets-section.js +4 -2
- package/dist/components/workspace-secrets-section.js.map +1 -1
- package/dist/components/workspace-secrets-section.stories.d.ts.map +1 -1
- package/dist/components/workspace-secrets-section.stories.js.map +1 -1
- package/dist/components/workspace-variables-section.d.ts.map +1 -1
- package/dist/components/workspace-variables-section.js +5 -3
- package/dist/components/workspace-variables-section.js.map +1 -1
- package/dist/components/workspace-variables-section.stories.d.ts.map +1 -1
- package/dist/components/workspace-variables-section.stories.js.map +1 -1
- package/dist/core/store.d.ts +54 -0
- package/dist/core/store.d.ts.map +1 -0
- package/dist/core/store.js +44 -0
- package/dist/core/store.js.map +1 -0
- package/dist/feature.d.ts +13 -0
- package/dist/feature.d.ts.map +1 -1
- package/dist/feature.js +17 -16
- package/dist/feature.js.map +1 -1
- package/dist/hooks/api/create-store-api.d.ts +31 -49
- package/dist/hooks/api/create-store-api.d.ts.map +1 -1
- package/dist/hooks/api/create-store-api.js +44 -45
- package/dist/hooks/api/create-store-api.js.map +1 -1
- package/dist/hooks/api/secrets.d.ts +16 -55
- package/dist/hooks/api/secrets.d.ts.map +1 -1
- package/dist/hooks/api/secrets.js +10 -2
- package/dist/hooks/api/secrets.js.map +1 -1
- package/dist/hooks/api/store-mapper.d.ts +7 -0
- package/dist/hooks/api/store-mapper.d.ts.map +1 -0
- package/dist/hooks/api/store-mapper.js +36 -0
- package/dist/hooks/api/store-mapper.js.map +1 -0
- package/dist/hooks/api/variables.d.ts +25 -78
- package/dist/hooks/api/variables.d.ts.map +1 -1
- package/dist/hooks/api/variables.js +37 -28
- package/dist/hooks/api/variables.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +9 -10
- package/src/components/form-errors.test.ts +2 -2
- package/src/components/form-errors.ts +0 -3
- package/src/components/secret-form.tsx +15 -5
- package/src/components/variable-form.tsx +15 -5
- package/src/components/workspace-secrets-section.stories.tsx +1 -2
- package/src/components/workspace-secrets-section.tsx +8 -4
- package/src/components/workspace-variables-section.stories.tsx +1 -2
- package/src/components/workspace-variables-section.tsx +10 -6
- package/src/core/store.test.ts +38 -0
- package/src/core/store.ts +91 -0
- package/src/feature.ts +13 -11
- package/src/hooks/api/create-store-api.ts +104 -75
- package/src/hooks/api/secrets.test.ts +16 -10
- package/src/hooks/api/secrets.ts +11 -14
- package/src/hooks/api/store-mapper.test.ts +39 -0
- package/src/hooks/api/store-mapper.ts +47 -0
- package/src/hooks/api/variables.ts +52 -36
- package/tsconfig.build.tsbuildinfo +1 -1
- package/vercel.json +5 -0
- package/dist/components/store-key.d.ts +0 -20
- package/dist/components/store-key.d.ts.map +0 -1
- package/dist/components/store-key.js +0 -25
- package/dist/components/store-key.js.map +0 -1
- package/src/components/store-key.test.ts +0 -53
- package/src/components/store-key.ts +0 -36
package/vercel.json
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
"buildCommand": "turbo build && pnpm run storybook:build",
|
|
4
4
|
"devCommand": "pnpm run storybook",
|
|
5
5
|
"installCommand": "pnpm install",
|
|
6
|
+
"git": {
|
|
7
|
+
"deploymentEnabled": {
|
|
8
|
+
"changeset-release/main": false
|
|
9
|
+
}
|
|
10
|
+
},
|
|
6
11
|
"framework": null,
|
|
7
12
|
"outputDirectory": "./storybook-static"
|
|
8
13
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare const STORE_KEY_HELP = "Uppercase letters, digits and underscores; must start with a letter or underscore.";
|
|
2
|
-
/**
|
|
3
|
-
* Validates a store key against the shared `secretKeySchema` and returns a
|
|
4
|
-
* human-readable message (not Zod's default) when it fails. The name input is
|
|
5
|
-
* also auto-uppercased at the call site, so the common case never trips this.
|
|
6
|
-
*/
|
|
7
|
-
export declare function validateStoreKey(value: string): string | undefined;
|
|
8
|
-
/**
|
|
9
|
-
* Format validation plus a create-mode collision guard. `PUT /:key` is an
|
|
10
|
-
* upsert and single writes never return a duplicate-key error, so without this
|
|
11
|
-
* a create with an existing name would silently overwrite the current value —
|
|
12
|
-
* unrecoverable for write-only secrets. Edit mode locks the key, so it skips
|
|
13
|
-
* the collision check.
|
|
14
|
-
*/
|
|
15
|
-
export declare function validateNewStoreKey(value: string, { mode, reservedKeys, kind, }: {
|
|
16
|
-
mode: 'create' | 'edit';
|
|
17
|
-
reservedKeys: readonly string[];
|
|
18
|
-
kind: 'secret' | 'variable';
|
|
19
|
-
}): string | undefined;
|
|
20
|
-
//# sourceMappingURL=store-key.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"store-key.d.ts","sourceRoot":"","sources":["../../src/components/store-key.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,uFAC2D,CAAC;AAEvF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAElE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,EACE,IAAI,EACJ,YAAY,EACZ,IAAI,GACL,EAAE;IAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,CAAA;CAAC,GACzF,MAAM,GAAG,SAAS,CAOpB"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { secretKeySchema } from '@shipfox/api-secrets-dto';
|
|
2
|
-
export const STORE_KEY_HELP = 'Uppercase letters, digits and underscores; must start with a letter or underscore.';
|
|
3
|
-
/**
|
|
4
|
-
* Validates a store key against the shared `secretKeySchema` and returns a
|
|
5
|
-
* human-readable message (not Zod's default) when it fails. The name input is
|
|
6
|
-
* also auto-uppercased at the call site, so the common case never trips this.
|
|
7
|
-
*/ export function validateStoreKey(value) {
|
|
8
|
-
return secretKeySchema.safeParse(value).success ? undefined : STORE_KEY_HELP;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Format validation plus a create-mode collision guard. `PUT /:key` is an
|
|
12
|
-
* upsert and single writes never return a duplicate-key error, so without this
|
|
13
|
-
* a create with an existing name would silently overwrite the current value —
|
|
14
|
-
* unrecoverable for write-only secrets. Edit mode locks the key, so it skips
|
|
15
|
-
* the collision check.
|
|
16
|
-
*/ export function validateNewStoreKey(value, { mode, reservedKeys, kind }) {
|
|
17
|
-
const formatError = validateStoreKey(value);
|
|
18
|
-
if (formatError) return formatError;
|
|
19
|
-
if (mode === 'create' && reservedKeys.includes(value)) {
|
|
20
|
-
return `A ${kind} with this name already exists. Edit it instead.`;
|
|
21
|
-
}
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
//# sourceMappingURL=store-key.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/store-key.ts"],"sourcesContent":["import {secretKeySchema} from '@shipfox/api-secrets-dto';\n\nexport const STORE_KEY_HELP =\n 'Uppercase letters, digits and underscores; must start with a letter or underscore.';\n\n/**\n * Validates a store key against the shared `secretKeySchema` and returns a\n * human-readable message (not Zod's default) when it fails. The name input is\n * also auto-uppercased at the call site, so the common case never trips this.\n */\nexport function validateStoreKey(value: string): string | undefined {\n return secretKeySchema.safeParse(value).success ? undefined : STORE_KEY_HELP;\n}\n\n/**\n * Format validation plus a create-mode collision guard. `PUT /:key` is an\n * upsert and single writes never return a duplicate-key error, so without this\n * a create with an existing name would silently overwrite the current value —\n * unrecoverable for write-only secrets. Edit mode locks the key, so it skips\n * the collision check.\n */\nexport function validateNewStoreKey(\n value: string,\n {\n mode,\n reservedKeys,\n kind,\n }: {mode: 'create' | 'edit'; reservedKeys: readonly string[]; kind: 'secret' | 'variable'},\n): string | undefined {\n const formatError = validateStoreKey(value);\n if (formatError) return formatError;\n if (mode === 'create' && reservedKeys.includes(value)) {\n return `A ${kind} with this name already exists. Edit it instead.`;\n }\n return undefined;\n}\n"],"names":["secretKeySchema","STORE_KEY_HELP","validateStoreKey","value","safeParse","success","undefined","validateNewStoreKey","mode","reservedKeys","kind","formatError","includes"],"mappings":"AAAA,SAAQA,eAAe,QAAO,2BAA2B;AAEzD,OAAO,MAAMC,iBACX,qFAAqF;AAEvF;;;;CAIC,GACD,OAAO,SAASC,iBAAiBC,KAAa;IAC5C,OAAOH,gBAAgBI,SAAS,CAACD,OAAOE,OAAO,GAAGC,YAAYL;AAChE;AAEA;;;;;;CAMC,GACD,OAAO,SAASM,oBACdJ,KAAa,EACb,EACEK,IAAI,EACJC,YAAY,EACZC,IAAI,EACoF;IAE1F,MAAMC,cAAcT,iBAAiBC;IACrC,IAAIQ,aAAa,OAAOA;IACxB,IAAIH,SAAS,YAAYC,aAAaG,QAAQ,CAACT,QAAQ;QACrD,OAAO,CAAC,EAAE,EAAEO,KAAK,gDAAgD,CAAC;IACpE;IACA,OAAOJ;AACT"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {STORE_KEY_HELP, validateNewStoreKey, validateStoreKey} from './store-key.js';
|
|
2
|
-
|
|
3
|
-
describe('validateStoreKey', () => {
|
|
4
|
-
test('accepts a valid uppercase identifier', () => {
|
|
5
|
-
expect(validateStoreKey('MY_TOKEN')).toBeUndefined();
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
test('rejects a malformed key', () => {
|
|
9
|
-
expect(validateStoreKey('my token')).toBe(STORE_KEY_HELP);
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
describe('validateNewStoreKey', () => {
|
|
14
|
-
test('blocks a create that collides with an existing key', () => {
|
|
15
|
-
const error = validateNewStoreKey('API_TOKEN', {
|
|
16
|
-
mode: 'create',
|
|
17
|
-
reservedKeys: ['API_TOKEN', 'DATABASE_URL'],
|
|
18
|
-
kind: 'secret',
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
expect(error).toBe('A secret with this name already exists. Edit it instead.');
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test('allows a create with a fresh key', () => {
|
|
25
|
-
const error = validateNewStoreKey('NEW_KEY', {
|
|
26
|
-
mode: 'create',
|
|
27
|
-
reservedKeys: ['API_TOKEN'],
|
|
28
|
-
kind: 'secret',
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
expect(error).toBeUndefined();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('does not treat the locked key as a collision in edit mode', () => {
|
|
35
|
-
const error = validateNewStoreKey('LOG_LEVEL', {
|
|
36
|
-
mode: 'edit',
|
|
37
|
-
reservedKeys: ['LOG_LEVEL'],
|
|
38
|
-
kind: 'variable',
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
expect(error).toBeUndefined();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test('enforces the format before the collision check', () => {
|
|
45
|
-
const error = validateNewStoreKey('bad key', {
|
|
46
|
-
mode: 'create',
|
|
47
|
-
reservedKeys: [],
|
|
48
|
-
kind: 'secret',
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
expect(error).toBe(STORE_KEY_HELP);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {secretKeySchema} from '@shipfox/api-secrets-dto';
|
|
2
|
-
|
|
3
|
-
export const STORE_KEY_HELP =
|
|
4
|
-
'Uppercase letters, digits and underscores; must start with a letter or underscore.';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Validates a store key against the shared `secretKeySchema` and returns a
|
|
8
|
-
* human-readable message (not Zod's default) when it fails. The name input is
|
|
9
|
-
* also auto-uppercased at the call site, so the common case never trips this.
|
|
10
|
-
*/
|
|
11
|
-
export function validateStoreKey(value: string): string | undefined {
|
|
12
|
-
return secretKeySchema.safeParse(value).success ? undefined : STORE_KEY_HELP;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Format validation plus a create-mode collision guard. `PUT /:key` is an
|
|
17
|
-
* upsert and single writes never return a duplicate-key error, so without this
|
|
18
|
-
* a create with an existing name would silently overwrite the current value —
|
|
19
|
-
* unrecoverable for write-only secrets. Edit mode locks the key, so it skips
|
|
20
|
-
* the collision check.
|
|
21
|
-
*/
|
|
22
|
-
export function validateNewStoreKey(
|
|
23
|
-
value: string,
|
|
24
|
-
{
|
|
25
|
-
mode,
|
|
26
|
-
reservedKeys,
|
|
27
|
-
kind,
|
|
28
|
-
}: {mode: 'create' | 'edit'; reservedKeys: readonly string[]; kind: 'secret' | 'variable'},
|
|
29
|
-
): string | undefined {
|
|
30
|
-
const formatError = validateStoreKey(value);
|
|
31
|
-
if (formatError) return formatError;
|
|
32
|
-
if (mode === 'create' && reservedKeys.includes(value)) {
|
|
33
|
-
return `A ${kind} with this name already exists. Edit it instead.`;
|
|
34
|
-
}
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|