sdk-environment 0.0.0 → 0.1.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.
Files changed (71) hide show
  1. package/dist/domain.objects/Environment.d.ts +21 -0
  2. package/dist/domain.objects/Environment.js +3 -0
  3. package/dist/domain.objects/Environment.js.map +1 -0
  4. package/dist/domain.objects/EnvironmentAccessTier.d.ts +5 -0
  5. package/dist/domain.objects/EnvironmentAccessTier.js +3 -0
  6. package/dist/domain.objects/EnvironmentAccessTier.js.map +1 -0
  7. package/dist/domain.objects/EnvironmentCommitSlug.d.ts +10 -0
  8. package/dist/domain.objects/EnvironmentCommitSlug.js +3 -0
  9. package/dist/domain.objects/EnvironmentCommitSlug.js.map +1 -0
  10. package/dist/domain.objects/EnvironmentServerTier.d.ts +9 -0
  11. package/dist/domain.objects/EnvironmentServerTier.js +3 -0
  12. package/dist/domain.objects/EnvironmentServerTier.js.map +1 -0
  13. package/dist/domain.operations/getEnvironment/getEnvironment.d.ts +60 -0
  14. package/dist/domain.operations/getEnvironment/getEnvironment.js +127 -0
  15. package/dist/domain.operations/getEnvironment/getEnvironment.js.map +1 -0
  16. package/dist/domain.operations/parsers/access/getEnvAccess.d.ts +11 -0
  17. package/dist/domain.operations/parsers/access/getEnvAccess.js +16 -0
  18. package/dist/domain.operations/parsers/access/getEnvAccess.js.map +1 -0
  19. package/dist/domain.operations/parsers/access/getEnvAccessFromAwsAccountAlias.d.ts +20 -0
  20. package/dist/domain.operations/parsers/access/getEnvAccessFromAwsAccountAlias.js +88 -0
  21. package/dist/domain.operations/parsers/access/getEnvAccessFromAwsAccountAlias.js.map +1 -0
  22. package/dist/domain.operations/parsers/access/getEnvAccessFromEnvar.d.ts +6 -0
  23. package/dist/domain.operations/parsers/access/getEnvAccessFromEnvar.js +18 -0
  24. package/dist/domain.operations/parsers/access/getEnvAccessFromEnvar.js.map +1 -0
  25. package/dist/domain.operations/parsers/access/getEnvAccessFromNodeEnv.d.ts +12 -0
  26. package/dist/domain.operations/parsers/access/getEnvAccessFromNodeEnv.js +23 -0
  27. package/dist/domain.operations/parsers/access/getEnvAccessFromNodeEnv.js.map +1 -0
  28. package/dist/domain.operations/parsers/commit/getEnvCommit.d.ts +8 -0
  29. package/dist/domain.operations/parsers/commit/getEnvCommit.js +14 -0
  30. package/dist/domain.operations/parsers/commit/getEnvCommit.js.map +1 -0
  31. package/dist/domain.operations/parsers/commit/getEnvCommitFromEnvar.d.ts +6 -0
  32. package/dist/domain.operations/parsers/commit/getEnvCommitFromEnvar.js +18 -0
  33. package/dist/domain.operations/parsers/commit/getEnvCommitFromEnvar.js.map +1 -0
  34. package/dist/domain.operations/parsers/commit/getEnvCommitFromGit.d.ts +6 -0
  35. package/dist/domain.operations/parsers/commit/getEnvCommitFromGit.js +72 -0
  36. package/dist/domain.operations/parsers/commit/getEnvCommitFromGit.js.map +1 -0
  37. package/dist/domain.operations/parsers/factories.d.ts +36 -0
  38. package/dist/domain.operations/parsers/factories.js +70 -0
  39. package/dist/domain.operations/parsers/factories.js.map +1 -0
  40. package/dist/domain.operations/parsers/fromEnvar.d.ts +5 -0
  41. package/dist/domain.operations/parsers/fromEnvar.js +19 -0
  42. package/dist/domain.operations/parsers/fromEnvar.js.map +1 -0
  43. package/dist/domain.operations/parsers/server/getEnvServer.d.ts +10 -0
  44. package/dist/domain.operations/parsers/server/getEnvServer.js +18 -0
  45. package/dist/domain.operations/parsers/server/getEnvServer.js.map +1 -0
  46. package/dist/domain.operations/parsers/server/getEnvServerFromCiEnvar.d.ts +6 -0
  47. package/dist/domain.operations/parsers/server/getEnvServerFromCiEnvar.js +15 -0
  48. package/dist/domain.operations/parsers/server/getEnvServerFromCiEnvar.js.map +1 -0
  49. package/dist/domain.operations/parsers/server/getEnvServerFromEnvar.d.ts +6 -0
  50. package/dist/domain.operations/parsers/server/getEnvServerFromEnvar.js +18 -0
  51. package/dist/domain.operations/parsers/server/getEnvServerFromEnvar.js.map +1 -0
  52. package/dist/domain.operations/parsers/server/getEnvServerFromLambdaTaskRoot.d.ts +6 -0
  53. package/dist/domain.operations/parsers/server/getEnvServerFromLambdaTaskRoot.js +15 -0
  54. package/dist/domain.operations/parsers/server/getEnvServerFromLambdaTaskRoot.js.map +1 -0
  55. package/dist/domain.operations/parsers/server/getEnvServerFromUnixDesktop.d.ts +6 -0
  56. package/dist/domain.operations/parsers/server/getEnvServerFromUnixDesktop.js +16 -0
  57. package/dist/domain.operations/parsers/server/getEnvServerFromUnixDesktop.js.map +1 -0
  58. package/dist/domain.operations/validators/isEnvironmentAccessTier.d.ts +6 -0
  59. package/dist/domain.operations/validators/isEnvironmentAccessTier.js +14 -0
  60. package/dist/domain.operations/validators/isEnvironmentAccessTier.js.map +1 -0
  61. package/dist/domain.operations/validators/isEnvironmentCommitSlug.d.ts +1 -0
  62. package/dist/domain.operations/validators/isEnvironmentCommitSlug.js +18 -0
  63. package/dist/domain.operations/validators/isEnvironmentCommitSlug.js.map +1 -0
  64. package/dist/domain.operations/validators/isEnvironmentServerTier.d.ts +10 -0
  65. package/dist/domain.operations/validators/isEnvironmentServerTier.js +17 -0
  66. package/dist/domain.operations/validators/isEnvironmentServerTier.js.map +1 -0
  67. package/dist/index.d.ts +14 -1
  68. package/dist/index.js +29 -2
  69. package/dist/index.js.map +1 -1
  70. package/package.json +40 -42
  71. package/readme.md +8 -7
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "sdk-environment",
3
3
  "author": "ehmpathy",
4
4
  "description": "parse and expose the environment your code runs in",
5
- "version": "0.0.0",
5
+ "version": "0.1.0",
6
6
  "repository": "ehmpathy/sdk-environment",
7
7
  "homepage": "https://github.com/ehmpathy/sdk-environment",
8
8
  "keywords": [
@@ -22,17 +22,49 @@
22
22
  "files": [
23
23
  "/dist"
24
24
  ],
25
+ "scripts": {
26
+ "build:ts": "tsc -p ./tsconfig.build.json",
27
+ "commit:with-cli": "npx cz",
28
+ "fix:format:biome": "biome check --write",
29
+ "fix:format": "npm run fix:format:biome",
30
+ "fix:lint": "biome check --write",
31
+ "fix": "npm run fix:format && npm run fix:lint",
32
+ "build:clean:bun": "rm -f ./bin/*.bc",
33
+ "build:clean:tsc": "(chmod -R u+w dist 2>/dev/null || true) && rm -rf dist/",
34
+ "build:clean": "npm run build:clean:tsc && npm run build:clean:bun",
35
+ "build:compile:tsc": "tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json",
36
+ "build:compile": "npm run build:compile:tsc && npm run build:compile:bun --if-present",
37
+ "build": "npm run build:clean && npm run build:compile && npm run build:complete --if-present",
38
+ "test:auth": "[ \"$ECHO\" = 'true' ] && echo '. .agent/repo=.this/role=any/skills/use.apikeys.sh' || . .agent/repo=.this/role=any/skills/use.apikeys.sh",
39
+ "test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose",
40
+ "test:types": "tsc -p ./tsconfig.json --noEmit",
41
+ "test:format:biome": "biome format",
42
+ "test:format": "npm run test:format:biome",
43
+ "test:lint:deps": "npx depcheck -c ./.depcheckrc.yml",
44
+ "test:lint:biome": "biome check --diagnostic-level=error",
45
+ "test:lint:biome:all": "biome check",
46
+ "test:lint": "npm run test:lint:biome && npm run test:lint:deps",
47
+ "test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
48
+ "test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
49
+ "test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
50
+ "test": "eval $(ECHO=true npm run --silent test:auth) && npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally",
51
+ "test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
52
+ "prepush": "npm run test && npm run build",
53
+ "prepublish": "npm run build",
54
+ "preversion": "npm run prepush",
55
+ "postversion": "git push origin HEAD --tags --no-verify",
56
+ "prepare:husky": "husky install && chmod ug+x .husky/*",
57
+ "prepare:rhachet": "rhachet init --hooks --roles behaver mechanic reviewer",
58
+ "prepare": "if [ -e .git ] && [ -z $CI ]; then npm run prepare:husky && npm run prepare:rhachet; fi",
59
+ "upgrade:rhachet": "rhachet upgrade"
60
+ },
25
61
  "dependencies": {
26
- "@noble/hashes": "2.0.1",
27
- "domain-glossaries": "1.0.0",
28
- "type-fns": "1.21.0"
62
+ "@aws-sdk/client-iam": "3.758.0"
29
63
  },
30
64
  "devDependencies": {
31
65
  "@biomejs/biome": "2.3.8",
32
66
  "@commitlint/cli": "19.5.0",
33
67
  "@commitlint/config-conventional": "19.5.0",
34
- "@ehmpathy/uni-time": "1.4.2",
35
- "@noble/hashes": "2.0.1",
36
68
  "@swc/core": "1.15.3",
37
69
  "@swc/jest": "0.2.39",
38
70
  "@tsconfig/node-lts-strictest": "18.12.1",
@@ -71,39 +103,5 @@
71
103
  "path": "./node_modules/cz-conventional-changelog"
72
104
  }
73
105
  },
74
- "scripts": {
75
- "build:ts": "tsc -p ./tsconfig.build.json",
76
- "commit:with-cli": "npx cz",
77
- "fix:format:biome": "biome check --write",
78
- "fix:format": "npm run fix:format:biome",
79
- "fix:lint": "biome check --write",
80
- "fix": "npm run fix:format && npm run fix:lint",
81
- "build:clean:bun": "rm -f ./bin/*.bc",
82
- "build:clean:tsc": "(chmod -R u+w dist 2>/dev/null || true) && rm -rf dist/",
83
- "build:clean": "npm run build:clean:tsc && npm run build:clean:bun",
84
- "build:compile:tsc": "tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json",
85
- "build:compile": "npm run build:compile:tsc && npm run build:compile:bun --if-present",
86
- "build": "npm run build:clean && npm run build:compile && npm run build:complete --if-present",
87
- "test:auth": "[ \"$ECHO\" = 'true' ] && echo '. .agent/repo=.this/role=any/skills/use.apikeys.sh' || . .agent/repo=.this/role=any/skills/use.apikeys.sh",
88
- "test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose",
89
- "test:types": "tsc -p ./tsconfig.json --noEmit",
90
- "test:format:biome": "biome format",
91
- "test:format": "npm run test:format:biome",
92
- "test:lint:deps": "npx depcheck -c ./.depcheckrc.yml",
93
- "test:lint:biome": "biome check --diagnostic-level=error",
94
- "test:lint:biome:all": "biome check",
95
- "test:lint": "npm run test:lint:biome && npm run test:lint:deps",
96
- "test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
97
- "test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
98
- "test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
99
- "test": "eval $(ECHO=true npm run --silent test:auth) && npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally",
100
- "test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
101
- "prepush": "npm run test && npm run build",
102
- "prepublish": "npm run build",
103
- "preversion": "npm run prepush",
104
- "postversion": "git push origin HEAD --tags --no-verify",
105
- "prepare:husky": "husky install && chmod ug+x .husky/*",
106
- "prepare:rhachet": "rhachet init --hooks --roles behaver mechanic reviewer",
107
- "upgrade:rhachet": "rhachet upgrade"
108
- }
109
- }
106
+ "packageManager": "pnpm@10.24.0"
107
+ }
package/readme.md CHANGED
@@ -18,7 +18,7 @@ an environment is defined by three attributes:
18
18
  ```ts
19
19
  interface Environment {
20
20
  access: 'test' | 'prep' | 'prod';
21
- server: string; // 'local' | 'local@cicd' | 'cloud@aws.lambda' | ...
21
+ server: string; // 'local@unix' | 'local@cicd' | 'cloud@aws.lambda' | ...
22
22
  commit: string; // '$gitref@$hash' or '$gitref@$hash+' if dirty
23
23
  }
24
24
  ```
@@ -41,11 +41,11 @@ which tier of resources this process can access.
41
41
 
42
42
  ## server
43
43
 
44
- where this process executes. format: `$tier` or `$tier@$platform`
44
+ where this process executes. format: `$tier@$platform`
45
45
 
46
46
  | value | what | examples |
47
47
  |-------|------|----------|
48
- | `local` | developer machine | laptop, docker compose |
48
+ | `local@unix` | developer machine | laptop, docker compose |
49
49
  | `local@cicd` | ci runner | github actions, circleci |
50
50
  | `cloud@aws.lambda` | aws lambda | serverless functions |
51
51
  | `cloud@aws.ecs` | aws ecs | containerized services |
@@ -102,6 +102,7 @@ import {
102
102
  fromNodeEnv,
103
103
  fromLambdaTaskRoot,
104
104
  fromCiEnvar,
105
+ fromUnixDesktop,
105
106
  fromGit,
106
107
  } from 'sdk-environment';
107
108
 
@@ -117,7 +118,7 @@ const environment = await getEnvironment({
117
118
  fromEnvar('SERVER'), // explicit override via SERVER=cloud@aws.lambda
118
119
  fromLambdaTaskRoot(), // LAMBDA_TASK_ROOT present → cloud@aws.lambda
119
120
  fromCiEnvar(), // CI=true → local@cicd
120
- () => 'local', // default to local
121
+ fromUnixDesktop(), // XDG_SESSION_TYPE or TERM_PROGRAM → local@unix
121
122
  ],
122
123
  commit: [
123
124
  fromEnvar('COMMIT'), // explicit override via COMMIT=v1.0.0@abc123
@@ -204,11 +205,11 @@ these are independent axes:
204
205
 
205
206
  | access | server | example |
206
207
  |--------|--------|---------|
207
- | test | local | `npm test` on laptop |
208
+ | test | local@unix | `npm test` on laptop |
208
209
  | test | local@cicd | ci runner runs tests |
209
- | prep | local | dev laptop against prep db |
210
+ | prep | local@unix | dev laptop against prep db |
210
211
  | prep | cloud@aws.lambda | prep lambda |
211
- | prod | local | production debug session |
212
+ | prod | local@unix | production debug session |
212
213
  | prod | cloud@aws.lambda | production lambda |
213
214
 
214
215
  this separation enables precise behavior: