@saws/core 2.0.0-beta.2 → 2.0.0-beta.4

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 (76) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/Host.d.ts +62 -0
  3. package/dist/Host.js +202 -0
  4. package/dist/ServiceDefinition.d.ts +46 -0
  5. package/dist/ServiceDefinition.js +119 -0
  6. package/dist/find-service-definition.d.ts +1 -8
  7. package/dist/find-service-definition.js +0 -6
  8. package/dist/get-saws-config.d.ts +7 -3
  9. package/dist/get-saws-config.js +6 -56
  10. package/dist/host-readiness.d.ts +12 -0
  11. package/dist/host-readiness.js +230 -0
  12. package/dist/index.d.ts +4 -5
  13. package/dist/index.js +4 -4
  14. package/dist/secrets-manager.d.ts +63 -0
  15. package/dist/secrets-manager.js +323 -0
  16. package/dist/tsconfig.tsbuildinfo +1 -0
  17. package/dist/utils/constants.d.ts +4 -0
  18. package/dist/utils/constants.js +5 -0
  19. package/dist/utils/create-directories.d.ts +2 -0
  20. package/dist/utils/create-directories.js +20 -0
  21. package/dist/utils/create-file-if-not-exists.d.ts +1 -0
  22. package/dist/utils/create-file-if-not-exists.js +12 -0
  23. package/dist/utils/create-file-if-note-exists.d.ts +1 -0
  24. package/dist/utils/create-file-if-note-exists.js +11 -0
  25. package/dist/utils/dependency-management.d.ts +16 -0
  26. package/dist/utils/dependency-management.js +111 -0
  27. package/dist/utils/file-exists.d.ts +1 -0
  28. package/dist/utils/file-exists.js +12 -0
  29. package/dist/utils/generate-token.d.ts +1 -0
  30. package/dist/utils/generate-token.js +13 -0
  31. package/dist/utils/get-project-name.d.ts +1 -0
  32. package/dist/utils/get-project-name.js +5 -0
  33. package/dist/utils/get-service-path.js +1 -0
  34. package/dist/utils/list-files.d.ts +1 -0
  35. package/dist/utils/list-files.js +17 -0
  36. package/dist/utils/on-exit.d.ts +1 -0
  37. package/dist/utils/on-exit.js +14 -0
  38. package/dist/utils/parameterized-env-var-name.d.ts +1 -0
  39. package/dist/utils/parameterized-env-var-name.js +1 -0
  40. package/dist/utils/recursively-read-dir.d.ts +1 -0
  41. package/dist/utils/recursively-read-dir.js +15 -0
  42. package/dist/utils/retry-until.d.ts +1 -0
  43. package/dist/utils/retry-until.js +9 -0
  44. package/dist/utils/run-local.d.ts +8 -0
  45. package/dist/utils/run-local.js +86 -0
  46. package/dist/utils/shell-quote.d.ts +1 -0
  47. package/dist/utils/shell-quote.js +3 -0
  48. package/dist/utils/stage-outputs.d.ts +3 -0
  49. package/dist/utils/stage-outputs.js +24 -0
  50. package/dist/utils/uppercase.d.ts +1 -0
  51. package/dist/utils/uppercase.js +4 -0
  52. package/package.json +32 -24
  53. package/dist/context.d.ts +0 -41
  54. package/dist/context.d.ts.map +0 -1
  55. package/dist/context.js +0 -38
  56. package/dist/context.test.d.ts +0 -2
  57. package/dist/context.test.d.ts.map +0 -1
  58. package/dist/context.test.js +0 -13
  59. package/dist/find-service-definition.d.ts.map +0 -1
  60. package/dist/find-service-definition.test.d.ts +0 -2
  61. package/dist/find-service-definition.test.d.ts.map +0 -1
  62. package/dist/find-service-definition.test.js +0 -44
  63. package/dist/get-saws-config.d.ts.map +0 -1
  64. package/dist/index.d.ts.map +0 -1
  65. package/dist/service-commands.d.ts +0 -10
  66. package/dist/service-commands.d.ts.map +0 -1
  67. package/dist/service-commands.js +0 -25
  68. package/dist/service-commands.test.d.ts +0 -2
  69. package/dist/service-commands.test.d.ts.map +0 -1
  70. package/dist/service-commands.test.js +0 -26
  71. package/dist/service-definition.d.ts +0 -36
  72. package/dist/service-definition.d.ts.map +0 -1
  73. package/dist/service-definition.js +0 -104
  74. package/dist/service-types.d.ts +0 -9
  75. package/dist/service-types.d.ts.map +0 -1
  76. /package/dist/{service-types.js → utils/get-service-path.d.ts} +0 -0
@@ -1,104 +0,0 @@
1
- import { DeployContext, DevContext, ExitContext, InitContext, } from "./context.js";
2
- export class ServiceDefinition {
3
- static getCommands() {
4
- return [];
5
- }
6
- name;
7
- dependencies;
8
- initializedStages = new Set();
9
- devedStages = new Set();
10
- deployedStages = new Set();
11
- outputsByStage = new Map();
12
- constructor(config) {
13
- this.name = config.name;
14
- this.dependencies = config.dependencies ?? [];
15
- }
16
- async init(context = new InitContext({ stage: "local" })) {
17
- if (this.initializedStages.has(context.stage))
18
- return;
19
- for (const dependency of this.dependencies) {
20
- await dependency.init(initContextForService(context, dependency.name));
21
- }
22
- await this.onInit(initContextForService(context, this.name));
23
- this.initializedStages.add(context.stage);
24
- }
25
- async dev(context = new DevContext({ stage: "local" })) {
26
- if (this.devedStages.has(context.stage))
27
- return;
28
- await this.init(initContextForService(context, this.name));
29
- for (const dependency of this.dependencies) {
30
- await dependency.dev(devContextForService(context, dependency.name));
31
- }
32
- await this.onDev(devContextForService(context, this.name));
33
- this.devedStages.add(context.stage);
34
- }
35
- async deploy(contextOrStage) {
36
- const context = typeof contextOrStage === "string"
37
- ? new DeployContext({ stage: contextOrStage })
38
- : contextOrStage;
39
- if (this.deployedStages.has(context.stage))
40
- return;
41
- for (const dependency of this.dependencies) {
42
- await dependency.deploy(context);
43
- }
44
- await this.onDeploy(context);
45
- this.deployedStages.add(context.stage);
46
- }
47
- async exit(context = new ExitContext({ stage: "local" })) {
48
- await this.onExit(context);
49
- for (const dependency of this.dependencies) {
50
- await dependency.exit(context);
51
- }
52
- }
53
- setOutputs(stage, outputs) {
54
- this.outputsByStage.set(stage, {
55
- ...this.outputsByStage.get(stage),
56
- ...outputs,
57
- });
58
- }
59
- async getOutputs(context) {
60
- return this.outputsByStage.get(context.stage) ?? {};
61
- }
62
- async getEnvironmentVariables(context, _target = "host") {
63
- return {};
64
- }
65
- async getDependenciesEnvironmentVariables(context, target = "host") {
66
- const environment = {};
67
- for (const dependency of this.dependencies) {
68
- Object.assign(environment, await dependency.getEnvironmentVariables(context, target));
69
- }
70
- return environment;
71
- }
72
- async getPermissions(context) {
73
- return [];
74
- }
75
- /**
76
- * Bootstrap application-owned files or dependencies required by this
77
- * service. Implementations must be safe to run again in a later process and
78
- * should resolve generated paths from context.rootDir.
79
- */
80
- async onInit(_context) { }
81
- async onDev(_context) { }
82
- async onDeploy(_context) { }
83
- async onExit(_context) { }
84
- }
85
- function initContextForService(context, serviceName) {
86
- return new InitContext({
87
- stage: context.stage,
88
- rootDir: context.rootDir,
89
- env: context.env,
90
- dryRun: context.dryRun,
91
- logSink: context.logSink,
92
- currentServiceName: serviceName,
93
- });
94
- }
95
- function devContextForService(context, serviceName) {
96
- return new DevContext({
97
- stage: context.stage,
98
- rootDir: context.rootDir,
99
- env: context.env,
100
- dryRun: context.dryRun,
101
- logSink: context.logSink,
102
- currentServiceName: serviceName,
103
- });
104
- }
@@ -1,9 +0,0 @@
1
- export type ServiceOutputs = Record<string, string | number | boolean | undefined>;
2
- export type EnvironmentVariables = Record<string, string>;
3
- export type EnvironmentVariableTarget = "host" | "container";
4
- export interface ServicePermission {
5
- provider: string;
6
- actions: string[];
7
- resources: string[];
8
- }
9
- //# sourceMappingURL=service-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"service-types.d.ts","sourceRoot":"","sources":["../src/service-types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;AACnF,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1D,MAAM,MAAM,yBAAyB,GAAG,MAAM,GAAG,WAAW,CAAC;AAE7D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB"}