@optimizely/ocp-cli 1.0.0-beta.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.
Files changed (283) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +18 -0
  3. package/bin/opti.js +3 -0
  4. package/dist/commands/accounts/Whoami.d.ts +3 -0
  5. package/dist/commands/accounts/Whoami.js +34 -0
  6. package/dist/commands/accounts/Whoami.js.map +1 -0
  7. package/dist/commands/accounts/Whois.d.ts +6 -0
  8. package/dist/commands/accounts/Whois.js +65 -0
  9. package/dist/commands/accounts/Whois.js.map +1 -0
  10. package/dist/commands/app/BaseBuildCommand.d.ts +23 -0
  11. package/dist/commands/app/BaseBuildCommand.js +227 -0
  12. package/dist/commands/app/BaseBuildCommand.js.map +1 -0
  13. package/dist/commands/app/Init.d.ts +20 -0
  14. package/dist/commands/app/Init.js +285 -0
  15. package/dist/commands/app/Init.js.map +1 -0
  16. package/dist/commands/app/Logs.d.ts +19 -0
  17. package/dist/commands/app/Logs.js +230 -0
  18. package/dist/commands/app/Logs.js.map +1 -0
  19. package/dist/commands/app/Package.d.ts +4 -0
  20. package/dist/commands/app/Package.js +51 -0
  21. package/dist/commands/app/Package.js.map +1 -0
  22. package/dist/commands/app/Prepare.d.ts +8 -0
  23. package/dist/commands/app/Prepare.js +112 -0
  24. package/dist/commands/app/Prepare.js.map +1 -0
  25. package/dist/commands/app/Register.d.ts +7 -0
  26. package/dist/commands/app/Register.js +58 -0
  27. package/dist/commands/app/Register.js.map +1 -0
  28. package/dist/commands/app/Validate.d.ts +4 -0
  29. package/dist/commands/app/Validate.js +27 -0
  30. package/dist/commands/app/Validate.js.map +1 -0
  31. package/dist/commands/availability/List.d.ts +4 -0
  32. package/dist/commands/availability/List.js +47 -0
  33. package/dist/commands/availability/List.js.map +1 -0
  34. package/dist/commands/directory/Info.d.ts +7 -0
  35. package/dist/commands/directory/Info.js +92 -0
  36. package/dist/commands/directory/Info.js.map +1 -0
  37. package/dist/commands/directory/Install.d.ts +6 -0
  38. package/dist/commands/directory/Install.js +54 -0
  39. package/dist/commands/directory/Install.js.map +1 -0
  40. package/dist/commands/directory/List.d.ts +8 -0
  41. package/dist/commands/directory/List.js +102 -0
  42. package/dist/commands/directory/List.js.map +1 -0
  43. package/dist/commands/directory/ListFunctions.d.ts +7 -0
  44. package/dist/commands/directory/ListFunctions.js +77 -0
  45. package/dist/commands/directory/ListFunctions.js.map +1 -0
  46. package/dist/commands/directory/ListGlobalFunctions.d.ts +6 -0
  47. package/dist/commands/directory/ListGlobalFunctions.js +72 -0
  48. package/dist/commands/directory/ListGlobalFunctions.js.map +1 -0
  49. package/dist/commands/directory/ListInstalls.d.ts +8 -0
  50. package/dist/commands/directory/ListInstalls.js +81 -0
  51. package/dist/commands/directory/ListInstalls.js.map +1 -0
  52. package/dist/commands/directory/Publish.d.ts +8 -0
  53. package/dist/commands/directory/Publish.js +180 -0
  54. package/dist/commands/directory/Publish.js.map +1 -0
  55. package/dist/commands/directory/Status.d.ts +5 -0
  56. package/dist/commands/directory/Status.js +60 -0
  57. package/dist/commands/directory/Status.js.map +1 -0
  58. package/dist/commands/directory/Uninstall.d.ts +6 -0
  59. package/dist/commands/directory/Uninstall.js +50 -0
  60. package/dist/commands/directory/Uninstall.js.map +1 -0
  61. package/dist/commands/directory/Unpublish.d.ts +10 -0
  62. package/dist/commands/directory/Unpublish.js +181 -0
  63. package/dist/commands/directory/Unpublish.js.map +1 -0
  64. package/dist/commands/directory/Uprade.d.ts +8 -0
  65. package/dist/commands/directory/Uprade.js +100 -0
  66. package/dist/commands/directory/Uprade.js.map +1 -0
  67. package/dist/commands/env/GetEnvironment.d.ts +3 -0
  68. package/dist/commands/env/GetEnvironment.js +28 -0
  69. package/dist/commands/env/GetEnvironment.js.map +1 -0
  70. package/dist/commands/env/SetEnvironment.d.ts +4 -0
  71. package/dist/commands/env/SetEnvironment.js +63 -0
  72. package/dist/commands/env/SetEnvironment.js.map +1 -0
  73. package/dist/commands/jobs/List.d.ts +21 -0
  74. package/dist/commands/jobs/List.js +268 -0
  75. package/dist/commands/jobs/List.js.map +1 -0
  76. package/dist/commands/jobs/RuntimeStatus.d.ts +5 -0
  77. package/dist/commands/jobs/RuntimeStatus.js +65 -0
  78. package/dist/commands/jobs/RuntimeStatus.js.map +1 -0
  79. package/dist/commands/jobs/Terminate.d.ts +5 -0
  80. package/dist/commands/jobs/Terminate.js +45 -0
  81. package/dist/commands/jobs/Terminate.js.map +1 -0
  82. package/dist/commands/jobs/Trigger.d.ts +8 -0
  83. package/dist/commands/jobs/Trigger.js +58 -0
  84. package/dist/commands/jobs/Trigger.js.map +1 -0
  85. package/dist/commands/review/List.d.ts +5 -0
  86. package/dist/commands/review/List.js +81 -0
  87. package/dist/commands/review/List.js.map +1 -0
  88. package/dist/commands/review/Open.d.ts +4 -0
  89. package/dist/commands/review/Open.js +42 -0
  90. package/dist/commands/review/Open.js.map +1 -0
  91. package/dist/index.d.ts +1 -0
  92. package/dist/index.js +15 -0
  93. package/dist/index.js.map +1 -0
  94. package/dist/lib/AppContext.d.ts +9 -0
  95. package/dist/lib/AppContext.js +43 -0
  96. package/dist/lib/AppContext.js.map +1 -0
  97. package/dist/lib/AppPackager.d.ts +8 -0
  98. package/dist/lib/AppPackager.js +40 -0
  99. package/dist/lib/AppPackager.js.map +1 -0
  100. package/dist/lib/AppUpdater.d.ts +9 -0
  101. package/dist/lib/AppUpdater.js +155 -0
  102. package/dist/lib/AppUpdater.js.map +1 -0
  103. package/dist/lib/AppUploader.d.ts +8 -0
  104. package/dist/lib/AppUploader.js +36 -0
  105. package/dist/lib/AppUploader.js.map +1 -0
  106. package/dist/lib/Config.d.ts +15 -0
  107. package/dist/lib/Config.js +47 -0
  108. package/dist/lib/Config.js.map +1 -0
  109. package/dist/lib/EnvironmentalOutput.d.ts +1 -0
  110. package/dist/lib/EnvironmentalOutput.js +21 -0
  111. package/dist/lib/EnvironmentalOutput.js.map +1 -0
  112. package/dist/lib/Moria.d.ts +51 -0
  113. package/dist/lib/Moria.js +30 -0
  114. package/dist/lib/Moria.js.map +1 -0
  115. package/dist/lib/MoriaApi.d.ts +22 -0
  116. package/dist/lib/MoriaApi.js +75 -0
  117. package/dist/lib/MoriaApi.js.map +1 -0
  118. package/dist/lib/Rivendell.d.ts +351 -0
  119. package/dist/lib/Rivendell.js +328 -0
  120. package/dist/lib/Rivendell.js.map +1 -0
  121. package/dist/lib/RivendellApi.d.ts +22 -0
  122. package/dist/lib/RivendellApi.js +90 -0
  123. package/dist/lib/RivendellApi.js.map +1 -0
  124. package/dist/lib/Shards.d.ts +3 -0
  125. package/dist/lib/Shards.js +34 -0
  126. package/dist/lib/Shards.js.map +1 -0
  127. package/dist/lib/StringUtils.d.ts +1 -0
  128. package/dist/lib/StringUtils.js +9 -0
  129. package/dist/lib/StringUtils.js.map +1 -0
  130. package/dist/lib/TeminalPassthru.d.ts +5 -0
  131. package/dist/lib/TeminalPassthru.js +12 -0
  132. package/dist/lib/TeminalPassthru.js.map +1 -0
  133. package/dist/lib/TerminalConfirm.d.ts +3 -0
  134. package/dist/lib/TerminalConfirm.js +26 -0
  135. package/dist/lib/TerminalConfirm.js.map +1 -0
  136. package/dist/lib/TerminalInput.d.ts +32 -0
  137. package/dist/lib/TerminalInput.js +207 -0
  138. package/dist/lib/TerminalInput.js.map +1 -0
  139. package/dist/lib/TerminalMenu.d.ts +34 -0
  140. package/dist/lib/TerminalMenu.js +186 -0
  141. package/dist/lib/TerminalMenu.js.map +1 -0
  142. package/dist/lib/TerminalOutput.d.ts +5 -0
  143. package/dist/lib/TerminalOutput.js +12 -0
  144. package/dist/lib/TerminalOutput.js.map +1 -0
  145. package/dist/lib/TerminalSpinner.d.ts +15 -0
  146. package/dist/lib/TerminalSpinner.js +71 -0
  147. package/dist/lib/TerminalSpinner.js.map +1 -0
  148. package/dist/lib/build.d.ts +5 -0
  149. package/dist/lib/build.js +35 -0
  150. package/dist/lib/build.js.map +1 -0
  151. package/dist/lib/checkForUpdate.d.ts +2 -0
  152. package/dist/lib/checkForUpdate.js +58 -0
  153. package/dist/lib/checkForUpdate.js.map +1 -0
  154. package/dist/lib/dev/app.d.ts +8 -0
  155. package/dist/lib/dev/app.js +53 -0
  156. package/dist/lib/dev/app.js.map +1 -0
  157. package/dist/lib/dev/index.d.ts +1 -0
  158. package/dist/lib/dev/index.js +14 -0
  159. package/dist/lib/dev/index.js.map +1 -0
  160. package/dist/lib/dev/logger.d.ts +15 -0
  161. package/dist/lib/dev/logger.js +58 -0
  162. package/dist/lib/dev/logger.js.map +1 -0
  163. package/dist/lib/die.d.ts +5 -0
  164. package/dist/lib/die.js +14 -0
  165. package/dist/lib/die.js.map +1 -0
  166. package/dist/lib/directoryExists.d.ts +1 -0
  167. package/dist/lib/directoryExists.js +9 -0
  168. package/dist/lib/directoryExists.js.map +1 -0
  169. package/dist/lib/formatBuildState.d.ts +2 -0
  170. package/dist/lib/formatBuildState.js +23 -0
  171. package/dist/lib/formatBuildState.js.map +1 -0
  172. package/dist/lib/formatError.d.ts +1 -0
  173. package/dist/lib/formatError.js +45 -0
  174. package/dist/lib/formatError.js.map +1 -0
  175. package/dist/lib/formatJobStatus.d.ts +3 -0
  176. package/dist/lib/formatJobStatus.js +28 -0
  177. package/dist/lib/formatJobStatus.js.map +1 -0
  178. package/dist/lib/formatReviewStatus.d.ts +4 -0
  179. package/dist/lib/formatReviewStatus.js +28 -0
  180. package/dist/lib/formatReviewStatus.js.map +1 -0
  181. package/dist/lib/formatTimstamp.d.ts +1 -0
  182. package/dist/lib/formatTimstamp.js +25 -0
  183. package/dist/lib/formatTimstamp.js.map +1 -0
  184. package/dist/lib/formatVersionState.d.ts +2 -0
  185. package/dist/lib/formatVersionState.js +35 -0
  186. package/dist/lib/formatVersionState.js.map +1 -0
  187. package/dist/lib/gatherAppEnv.d.ts +3 -0
  188. package/dist/lib/gatherAppEnv.js +71 -0
  189. package/dist/lib/gatherAppEnv.js.map +1 -0
  190. package/dist/lib/handleInterrupt.d.ts +1 -0
  191. package/dist/lib/handleInterrupt.js +17 -0
  192. package/dist/lib/handleInterrupt.js.map +1 -0
  193. package/dist/lib/jobRuntime.d.ts +3 -0
  194. package/dist/lib/jobRuntime.js +16 -0
  195. package/dist/lib/jobRuntime.js.map +1 -0
  196. package/dist/lib/parseDate.d.ts +2 -0
  197. package/dist/lib/parseDate.js +26 -0
  198. package/dist/lib/parseDate.js.map +1 -0
  199. package/dist/lib/templating/TemplateRenderer.d.ts +13 -0
  200. package/dist/lib/templating/TemplateRenderer.js +62 -0
  201. package/dist/lib/templating/TemplateRenderer.js.map +1 -0
  202. package/dist/lib/templating/fetchTemplatesManifest.d.ts +1 -0
  203. package/dist/lib/templating/fetchTemplatesManifest.js +10 -0
  204. package/dist/lib/templating/fetchTemplatesManifest.js.map +1 -0
  205. package/dist/lib/templating/types.d.ts +27 -0
  206. package/dist/lib/templating/types.js +3 -0
  207. package/dist/lib/templating/types.js.map +1 -0
  208. package/dist/oo-cli.manifest.json +1142 -0
  209. package/dist/test/setup.d.ts +0 -0
  210. package/dist/test/setup.js +4 -0
  211. package/dist/test/setup.js.map +1 -0
  212. package/package.json +94 -0
  213. package/src/commands/accounts/Whoami.ts +19 -0
  214. package/src/commands/accounts/Whois.ts +51 -0
  215. package/src/commands/app/BaseBuildCommand.ts +266 -0
  216. package/src/commands/app/Init.ts +303 -0
  217. package/src/commands/app/Logs.ts +241 -0
  218. package/src/commands/app/Package.ts +39 -0
  219. package/src/commands/app/Prepare.ts +108 -0
  220. package/src/commands/app/Register.ts +41 -0
  221. package/src/commands/app/Validate.ts +13 -0
  222. package/src/commands/availability/List.ts +37 -0
  223. package/src/commands/directory/Info.ts +83 -0
  224. package/src/commands/directory/Install.ts +37 -0
  225. package/src/commands/directory/List.ts +96 -0
  226. package/src/commands/directory/ListFunctions.ts +60 -0
  227. package/src/commands/directory/ListGlobalFunctions.ts +54 -0
  228. package/src/commands/directory/ListInstalls.ts +73 -0
  229. package/src/commands/directory/Publish.ts +179 -0
  230. package/src/commands/directory/Status.ts +45 -0
  231. package/src/commands/directory/Uninstall.ts +32 -0
  232. package/src/commands/directory/Unpublish.ts +173 -0
  233. package/src/commands/directory/Uprade.ts +85 -0
  234. package/src/commands/env/GetEnvironment.ts +14 -0
  235. package/src/commands/env/SetEnvironment.ts +52 -0
  236. package/src/commands/jobs/List.ts +278 -0
  237. package/src/commands/jobs/RuntimeStatus.ts +49 -0
  238. package/src/commands/jobs/Terminate.ts +29 -0
  239. package/src/commands/jobs/Trigger.ts +41 -0
  240. package/src/commands/review/List.ts +76 -0
  241. package/src/commands/review/Open.ts +28 -0
  242. package/src/index.ts +15 -0
  243. package/src/lib/AppContext.ts +47 -0
  244. package/src/lib/AppPackager.ts +47 -0
  245. package/src/lib/AppUpdater.ts +177 -0
  246. package/src/lib/AppUploader.ts +39 -0
  247. package/src/lib/Config.ts +60 -0
  248. package/src/lib/EnvironmentalOutput.ts +18 -0
  249. package/src/lib/Moria.ts +66 -0
  250. package/src/lib/MoriaApi.ts +86 -0
  251. package/src/lib/Rivendell.ts +572 -0
  252. package/src/lib/RivendellApi.ts +99 -0
  253. package/src/lib/Shards.ts +37 -0
  254. package/src/lib/StringUtils.ts +4 -0
  255. package/src/lib/TeminalPassthru.ts +7 -0
  256. package/src/lib/TerminalConfirm.ts +27 -0
  257. package/src/lib/TerminalInput.ts +236 -0
  258. package/src/lib/TerminalMenu.ts +221 -0
  259. package/src/lib/TerminalOutput.ts +7 -0
  260. package/src/lib/TerminalSpinner.ts +76 -0
  261. package/src/lib/build.ts +36 -0
  262. package/src/lib/checkForUpdate.ts +63 -0
  263. package/src/lib/dev/app.ts +58 -0
  264. package/src/lib/dev/index.ts +1 -0
  265. package/src/lib/dev/logger.ts +77 -0
  266. package/src/lib/die.ts +10 -0
  267. package/src/lib/directoryExists.ts +5 -0
  268. package/src/lib/formatBuildState.ts +20 -0
  269. package/src/lib/formatError.ts +39 -0
  270. package/src/lib/formatJobStatus.ts +24 -0
  271. package/src/lib/formatReviewStatus.ts +27 -0
  272. package/src/lib/formatTimstamp.ts +21 -0
  273. package/src/lib/formatVersionState.ts +31 -0
  274. package/src/lib/gatherAppEnv.ts +75 -0
  275. package/src/lib/handleInterrupt.ts +13 -0
  276. package/src/lib/jobRuntime.ts +12 -0
  277. package/src/lib/parseDate.ts +21 -0
  278. package/src/lib/templating/TemplateRenderer.ts +65 -0
  279. package/src/lib/templating/fetchTemplatesManifest.ts +6 -0
  280. package/src/lib/templating/types.ts +30 -0
  281. package/src/test/setup.ts +2 -0
  282. package/src/types/columnify.d.ts +27 -0
  283. package/src/types/gitignore-parser.d.ts +11 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MoriaApi.js","sourceRoot":"","sources":["../../src/lib/MoriaApi.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,351 @@
1
+ import { AppContext } from './AppContext';
2
+ import { DotenvParseOutput } from 'dotenv';
3
+ export declare namespace Rivendell {
4
+ enum AppVersionState {
5
+ NEW = "NEW",
6
+ PUBLISHED = "PUBLISHED",
7
+ BUILD_FAILED = "BUILD_FAILED",
8
+ STARTING = "STARTING",
9
+ START_FAILED = "START_FAILED",
10
+ RUNNING = "RUNNING",
11
+ UPGRADING_RUNTIME = "UPGRADING_RUNTIME",
12
+ STOPPING = "STOPPING",
13
+ STOP_FAILED = "STOP_FAILED",
14
+ STOPPED = "STOPPED"
15
+ }
16
+ enum ReviewStatus {
17
+ NOT_STARTED = "NOT_STARTED",
18
+ IN_REVIEW = "IN_REVIEW",
19
+ APPROVED = "APPROVED",
20
+ NOT_REQUIRED = "NOT_REQUIRED"
21
+ }
22
+ enum BuildState {
23
+ NEW = "NEW",
24
+ QUEUED = "QUEUED",
25
+ RUNNING = "RUNNING",
26
+ FINISHED = "FINISHED"
27
+ }
28
+ enum BuildMode {
29
+ VALIDATE = "VALIDATE",
30
+ PUBLISH = "PUBLISH"
31
+ }
32
+ enum BuildStatus {
33
+ SUCCESS = "SUCCESS",
34
+ FAILURE = "FAILURE",
35
+ ERROR = "ERROR"
36
+ }
37
+ enum DeploymentStage {
38
+ TEST = "TEST",
39
+ PRODUCTION = "PRODUCTION"
40
+ }
41
+ enum JobStatus {
42
+ PENDING = "PENDING",
43
+ SCHEDULED = "SCHEDULED",
44
+ RUNNING = "RUNNING",
45
+ COMPLETE = "COMPLETE",
46
+ ERROR = "ERROR",
47
+ TERMINATED = "TERMINATED"
48
+ }
49
+ enum JobTriggerType {
50
+ IMMEDIATE = "IMMEDIATE",
51
+ RECURRING = "RECURRING"
52
+ }
53
+ interface AppVersionId {
54
+ appId: string;
55
+ version: string;
56
+ }
57
+ interface Build {
58
+ id: number;
59
+ appVersionId: AppVersionId;
60
+ mode: BuildMode;
61
+ state: BuildState;
62
+ status?: BuildStatus;
63
+ errors?: string[];
64
+ queuedAt?: string;
65
+ runningAt?: string;
66
+ finishedAt?: string;
67
+ dependencySet?: string;
68
+ }
69
+ interface App {
70
+ id: string;
71
+ name: string;
72
+ createdAt: string;
73
+ updatedAt: string;
74
+ }
75
+ interface AppVersion {
76
+ id: AppVersionId;
77
+ manifestJson: string;
78
+ packageUrl: string;
79
+ state: string;
80
+ reviewStatus?: string;
81
+ stage: string;
82
+ image: string;
83
+ createdAt: string;
84
+ updatedAt: string;
85
+ }
86
+ interface AppInstallation {
87
+ id: number;
88
+ appId: string;
89
+ version: string;
90
+ accountId: number;
91
+ trackerId: string;
92
+ createdAt: string;
93
+ updatedAt: string;
94
+ }
95
+ interface Job {
96
+ id: string;
97
+ accountId: number;
98
+ trackerId: string;
99
+ status: JobStatus;
100
+ definition: JobDefinition;
101
+ errors: string;
102
+ triggeredAt: string;
103
+ scheduledAt: string;
104
+ startedAt: string;
105
+ completedAt: string;
106
+ terminatedAt: string;
107
+ createdAt: string;
108
+ updatedAt: string;
109
+ }
110
+ interface JobRuntimeStatus {
111
+ status: string;
112
+ }
113
+ interface JobDefinition {
114
+ id: string;
115
+ appId: string;
116
+ version: string;
117
+ function: string;
118
+ parameters: string;
119
+ trigger: JobTriggerType;
120
+ }
121
+ interface Webhook {
122
+ id: string;
123
+ url: string;
124
+ attributes: WebhookAttributes;
125
+ createdAt: string;
126
+ updatedAt?: string;
127
+ deletedAt?: string;
128
+ }
129
+ interface WebhookAttributes {
130
+ appId: string;
131
+ appVersion: string;
132
+ appInstallId?: number;
133
+ taskName: string;
134
+ internal: boolean;
135
+ enabled: boolean;
136
+ }
137
+ interface AppVersionSearchCriteria {
138
+ appId?: string;
139
+ version?: string;
140
+ appName?: string;
141
+ states?: AppVersionState[];
142
+ reviewStatuses?: ReviewStatus[];
143
+ stages?: DeploymentStage[];
144
+ categories?: Set<string>;
145
+ sorts?: Sort[];
146
+ }
147
+ interface AppInstallationSearchCriteria {
148
+ appId?: string;
149
+ version?: string;
150
+ trackerIds?: string[];
151
+ sorts?: Sort[];
152
+ }
153
+ interface WebhookSearchCriteria {
154
+ appId?: string;
155
+ appInstallId?: number;
156
+ includeInternal?: boolean;
157
+ includeDisabled?: boolean;
158
+ }
159
+ interface JobSearchCriteria {
160
+ appId: string;
161
+ versions?: string[];
162
+ trackerIds?: string[];
163
+ states?: JobStatus[];
164
+ functions?: string[];
165
+ minDurationMillis?: number;
166
+ sort?: Sort[];
167
+ limit?: number;
168
+ start?: number;
169
+ end?: number;
170
+ }
171
+ interface AppReview {
172
+ url: string;
173
+ }
174
+ enum SortDirection {
175
+ ASC = "ASC",
176
+ DESC = "DESC"
177
+ }
178
+ interface Sort {
179
+ field: string;
180
+ direction?: SortDirection;
181
+ }
182
+ enum Audience {
183
+ USER = "USER",
184
+ DEVELOPER = "DEVELOPER",
185
+ ZAIUS = "ZAIUS"
186
+ }
187
+ interface AwsCredentials {
188
+ accessKeyId: string;
189
+ secretAccessKey: string;
190
+ sessionToken: string;
191
+ expiration: string;
192
+ }
193
+ interface Account {
194
+ id: number;
195
+ trackerId: string;
196
+ name: string;
197
+ }
198
+ interface DeveloperApp {
199
+ id: string;
200
+ }
201
+ interface Developer {
202
+ id: string;
203
+ email: string;
204
+ role: string;
205
+ vendor: string;
206
+ personal_apps: DeveloperApp[];
207
+ vendor_apps: DeveloperApp[];
208
+ }
209
+ interface Shard {
210
+ id: string;
211
+ description: string;
212
+ url: string;
213
+ live: boolean;
214
+ }
215
+ interface JwtResponse {
216
+ jwt: string;
217
+ }
218
+ interface JwtHeader {
219
+ kid: string;
220
+ typ: string;
221
+ alg: string;
222
+ }
223
+ interface JwtPayload {
224
+ aud: string;
225
+ exp: number;
226
+ iss: string;
227
+ sub: string;
228
+ }
229
+ interface Jwt {
230
+ token: string;
231
+ header: JwtHeader;
232
+ payload: JwtPayload;
233
+ }
234
+ function searchAccounts(term: string, shard: string): Promise<Account[]>;
235
+ function whoami(): Promise<Developer>;
236
+ /**
237
+ * Register a new App.
238
+ * @param appId
239
+ * @param name
240
+ */
241
+ function registerApp(appId: string, name: string, personalApp: boolean, shard: string): Promise<App>;
242
+ /**
243
+ * Fetch an App by identifier.
244
+ * @param appId
245
+ */
246
+ function fetchApp(appId: string, shard?: string): Promise<App>;
247
+ /**
248
+ * Get app version review url.
249
+ * @param appId
250
+ */
251
+ function getReviewUrl(appVersion: string): Promise<AppReview>;
252
+ /**
253
+ * Search for AppVersions using the supplied criteria.
254
+ * @param criteria
255
+ */
256
+ function searchAppVersions(criteria: AppVersionSearchCriteria, shard: string): Promise<AppVersion[]>;
257
+ /**
258
+ * Fetch an AppVersion by identifier.
259
+ * @param appContext
260
+ */
261
+ function fetchAppVersion(appContext: AppContext, shard: string): Promise<AppVersion>;
262
+ /**
263
+ * Register a new app version.
264
+ */
265
+ function registerAppVersion(appId: string, version: string, packageUrl: string, appEnvValues: DotenvParseOutput, usePreviousAppEnvValues: boolean, shard: string): Promise<AppVersion>;
266
+ /**
267
+ * Register a new app version.
268
+ */
269
+ function updateAppVersion(appId: string, version: string, packageUrl: string, appEnvValues: DotenvParseOutput, usePreviousAppEnvValues: boolean, shard: string): Promise<AppVersion>;
270
+ /**
271
+ * Review an app version.
272
+ */
273
+ function reviewAppVersion(appId: string, version: string): Promise<void>;
274
+ /**
275
+ * Search for AppVersions using the supplied criteria.
276
+ * @param criteria
277
+ */
278
+ function searchAppInstallations(criteria: AppInstallationSearchCriteria, shard: string): Promise<AppInstallation[]>;
279
+ /**
280
+ * Search for Webhooks using the supplied criteria.
281
+ * @param criteria
282
+ */
283
+ function searchWebhooks(criteria: WebhookSearchCriteria, shard: string): Promise<Webhook[]>;
284
+ /**
285
+ * Loads a single AppInstallation.
286
+ * @param appId
287
+ * @param trackerId
288
+ */
289
+ function fetchAppInstallation(appId: string, trackerId: string, shard?: string): Promise<AppInstallation>;
290
+ /**
291
+ * Trigger an installation.
292
+ */
293
+ function install(appId: string, version: string, trackerId: string, shard: string): Promise<AppInstallation>;
294
+ /**
295
+ * Trigger an uninstall.
296
+ */
297
+ function uninstall(appInstallationId: number, shard: string): Promise<void>;
298
+ /**
299
+ * Request an upgrade.
300
+ */
301
+ function upgrade(appInstallationId: number, appId: string, version: string, shard: string): Promise<void>;
302
+ /**
303
+ * Trigger a publish.
304
+ */
305
+ function publish(appId: string, version: string, shard: string): Promise<void>;
306
+ /**
307
+ * Trigger a unpublish.
308
+ */
309
+ function unpublish(appId: string, version: string, shard: string): Promise<void>;
310
+ /**
311
+ * Fetch a build by id.
312
+ */
313
+ function fetchBuild(id: number): Promise<Build>;
314
+ /**
315
+ * Trigger a build.
316
+ */
317
+ function build(appId: string, version: string): Promise<Build>;
318
+ /**
319
+ * Trigger a verification.
320
+ */
321
+ function verify(appId: string, version: string): Promise<Build>;
322
+ /**
323
+ * Fetch temp credentials to upload to s3.
324
+ */
325
+ function uploadCredentials(vendor: string, appId: string, version: string, checksum: string): Promise<AwsCredentials>;
326
+ /**
327
+ * List shards.
328
+ */
329
+ function shards(): Promise<Shard[]>;
330
+ /**
331
+ * Search Jobs.
332
+ */
333
+ function searchJobs(criteria: JobSearchCriteria, shard: string): Promise<Job[]>;
334
+ /**
335
+ * Terminate Jobs
336
+ */
337
+ function terminateJob(jobId: string, shard: string): Promise<void>;
338
+ /**
339
+ * Trigger a Job
340
+ */
341
+ function triggerJob(appId: string, jobName: string, trackerId: string, parameters: string, shard: string): Promise<Job>;
342
+ /**
343
+ * Fetch a Job
344
+ */
345
+ function fetchJob(jobId: string, shard: string): Promise<Job>;
346
+ /**
347
+ * Fetch a jobs runtimeStatus
348
+ */
349
+ function fetchJobRuntimeStatus(jobId: string, shard: string): Promise<JobRuntimeStatus>;
350
+ function jwt(shard: string): Promise<string>;
351
+ }
@@ -0,0 +1,328 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Rivendell = void 0;
4
+ const RivendellApi_1 = require("./RivendellApi");
5
+ var Rivendell;
6
+ (function (Rivendell) {
7
+ let AppVersionState;
8
+ (function (AppVersionState) {
9
+ AppVersionState["NEW"] = "NEW";
10
+ AppVersionState["PUBLISHED"] = "PUBLISHED";
11
+ AppVersionState["BUILD_FAILED"] = "BUILD_FAILED";
12
+ AppVersionState["STARTING"] = "STARTING";
13
+ AppVersionState["START_FAILED"] = "START_FAILED";
14
+ AppVersionState["RUNNING"] = "RUNNING";
15
+ AppVersionState["UPGRADING_RUNTIME"] = "UPGRADING_RUNTIME";
16
+ AppVersionState["STOPPING"] = "STOPPING";
17
+ AppVersionState["STOP_FAILED"] = "STOP_FAILED";
18
+ AppVersionState["STOPPED"] = "STOPPED";
19
+ })(AppVersionState = Rivendell.AppVersionState || (Rivendell.AppVersionState = {}));
20
+ let ReviewStatus;
21
+ (function (ReviewStatus) {
22
+ ReviewStatus["NOT_STARTED"] = "NOT_STARTED";
23
+ ReviewStatus["IN_REVIEW"] = "IN_REVIEW";
24
+ ReviewStatus["APPROVED"] = "APPROVED";
25
+ ReviewStatus["NOT_REQUIRED"] = "NOT_REQUIRED";
26
+ })(ReviewStatus = Rivendell.ReviewStatus || (Rivendell.ReviewStatus = {}));
27
+ let BuildState;
28
+ (function (BuildState) {
29
+ BuildState["NEW"] = "NEW";
30
+ BuildState["QUEUED"] = "QUEUED";
31
+ BuildState["RUNNING"] = "RUNNING";
32
+ BuildState["FINISHED"] = "FINISHED";
33
+ })(BuildState = Rivendell.BuildState || (Rivendell.BuildState = {}));
34
+ let BuildMode;
35
+ (function (BuildMode) {
36
+ BuildMode["VALIDATE"] = "VALIDATE";
37
+ BuildMode["PUBLISH"] = "PUBLISH";
38
+ })(BuildMode = Rivendell.BuildMode || (Rivendell.BuildMode = {}));
39
+ let BuildStatus;
40
+ (function (BuildStatus) {
41
+ BuildStatus["SUCCESS"] = "SUCCESS";
42
+ BuildStatus["FAILURE"] = "FAILURE";
43
+ BuildStatus["ERROR"] = "ERROR";
44
+ })(BuildStatus = Rivendell.BuildStatus || (Rivendell.BuildStatus = {}));
45
+ let DeploymentStage;
46
+ (function (DeploymentStage) {
47
+ DeploymentStage["TEST"] = "TEST";
48
+ DeploymentStage["PRODUCTION"] = "PRODUCTION";
49
+ })(DeploymentStage = Rivendell.DeploymentStage || (Rivendell.DeploymentStage = {}));
50
+ let JobStatus;
51
+ (function (JobStatus) {
52
+ JobStatus["PENDING"] = "PENDING";
53
+ JobStatus["SCHEDULED"] = "SCHEDULED";
54
+ JobStatus["RUNNING"] = "RUNNING";
55
+ JobStatus["COMPLETE"] = "COMPLETE";
56
+ JobStatus["ERROR"] = "ERROR";
57
+ JobStatus["TERMINATED"] = "TERMINATED";
58
+ })(JobStatus = Rivendell.JobStatus || (Rivendell.JobStatus = {}));
59
+ let JobTriggerType;
60
+ (function (JobTriggerType) {
61
+ JobTriggerType["IMMEDIATE"] = "IMMEDIATE";
62
+ JobTriggerType["RECURRING"] = "RECURRING";
63
+ })(JobTriggerType = Rivendell.JobTriggerType || (Rivendell.JobTriggerType = {}));
64
+ let SortDirection;
65
+ (function (SortDirection) {
66
+ SortDirection["ASC"] = "ASC";
67
+ SortDirection["DESC"] = "DESC";
68
+ })(SortDirection = Rivendell.SortDirection || (Rivendell.SortDirection = {}));
69
+ let Audience;
70
+ (function (Audience) {
71
+ Audience["USER"] = "USER";
72
+ Audience["DEVELOPER"] = "DEVELOPER";
73
+ Audience["ZAIUS"] = "ZAIUS";
74
+ })(Audience = Rivendell.Audience || (Rivendell.Audience = {}));
75
+ function path(shard, endpoint) {
76
+ return `${shard}/${endpoint}`.replace(/^\//, '');
77
+ }
78
+ async function searchAccounts(term, shard) {
79
+ const response = await RivendellApi_1.RivendellApi.get(path(shard, `accounts/search?term=${encodeURIComponent(term)}`));
80
+ return response.body;
81
+ }
82
+ Rivendell.searchAccounts = searchAccounts;
83
+ async function whoami() {
84
+ const response = await RivendellApi_1.RivendellApi.get('developers/me');
85
+ return response.body;
86
+ }
87
+ Rivendell.whoami = whoami;
88
+ /**
89
+ * Register a new App.
90
+ * @param appId
91
+ * @param name
92
+ */
93
+ async function registerApp(appId, name, personalApp, shard) {
94
+ const response = await RivendellApi_1.RivendellApi.post(path(shard, 'apps'), { appId, name, personalApp });
95
+ return response.body;
96
+ }
97
+ Rivendell.registerApp = registerApp;
98
+ /**
99
+ * Fetch an App by identifier.
100
+ * @param appId
101
+ */
102
+ async function fetchApp(appId, shard = '') {
103
+ const response = await RivendellApi_1.RivendellApi.get(path(shard, `apps/${appId}`));
104
+ return response.body;
105
+ }
106
+ Rivendell.fetchApp = fetchApp;
107
+ /**
108
+ * Get app version review url.
109
+ * @param appId
110
+ */
111
+ async function getReviewUrl(appVersion) {
112
+ const response = await RivendellApi_1.RivendellApi.get(`reviews/${appVersion}`);
113
+ return response.body;
114
+ }
115
+ Rivendell.getReviewUrl = getReviewUrl;
116
+ /**
117
+ * Search for AppVersions using the supplied criteria.
118
+ * @param criteria
119
+ */
120
+ async function searchAppVersions(criteria, shard) {
121
+ const response = await RivendellApi_1.RivendellApi.post(path(shard, 'versions/search'), criteria);
122
+ return response.body;
123
+ }
124
+ Rivendell.searchAppVersions = searchAppVersions;
125
+ /**
126
+ * Fetch an AppVersion by identifier.
127
+ * @param appContext
128
+ */
129
+ async function fetchAppVersion(appContext, shard) {
130
+ const response = await RivendellApi_1.RivendellApi.get(path(shard, `versions/${appContext.appId}@${appContext.version}`));
131
+ return response.body;
132
+ }
133
+ Rivendell.fetchAppVersion = fetchAppVersion;
134
+ /**
135
+ * Register a new app version.
136
+ */
137
+ async function registerAppVersion(appId, version, packageUrl, appEnvValues, usePreviousAppEnvValues, shard) {
138
+ const response = await RivendellApi_1.RivendellApi.post(path(shard, 'versions'), { appId, version, packageUrl, appEnvValues, usePreviousAppEnvValues });
139
+ return response.body;
140
+ }
141
+ Rivendell.registerAppVersion = registerAppVersion;
142
+ /**
143
+ * Register a new app version.
144
+ */
145
+ async function updateAppVersion(appId, version, packageUrl, appEnvValues, usePreviousAppEnvValues, shard) {
146
+ const response = await RivendellApi_1.RivendellApi.put(path(shard, `versions/${appId}@${version}`), { packageUrl, appEnvValues, usePreviousAppEnvValues });
147
+ return response.body;
148
+ }
149
+ Rivendell.updateAppVersion = updateAppVersion;
150
+ /**
151
+ * Review an app version.
152
+ */
153
+ async function reviewAppVersion(appId, version) {
154
+ const appVersionId = `${appId}@${version}`;
155
+ await RivendellApi_1.RivendellApi.post('reviews', appVersionId);
156
+ }
157
+ Rivendell.reviewAppVersion = reviewAppVersion;
158
+ /**
159
+ * Search for AppVersions using the supplied criteria.
160
+ * @param criteria
161
+ */
162
+ async function searchAppInstallations(criteria, shard) {
163
+ const response = await RivendellApi_1.RivendellApi.post(path(shard, 'installations/search'), criteria);
164
+ return response.body;
165
+ }
166
+ Rivendell.searchAppInstallations = searchAppInstallations;
167
+ /**
168
+ * Search for Webhooks using the supplied criteria.
169
+ * @param criteria
170
+ */
171
+ async function searchWebhooks(criteria, shard) {
172
+ const response = await RivendellApi_1.RivendellApi.post(path(shard, 'webhooks/search'), criteria);
173
+ return response.body;
174
+ }
175
+ Rivendell.searchWebhooks = searchWebhooks;
176
+ /**
177
+ * Loads a single AppInstallation.
178
+ * @param appId
179
+ * @param trackerId
180
+ */
181
+ async function fetchAppInstallation(appId, trackerId, shard = '') {
182
+ const response = await searchAppInstallations({ appId, trackerIds: [trackerId] }, shard);
183
+ if (response.length !== 1) {
184
+ throw new Error(`Installation of ${appId} not found for ${trackerId}`);
185
+ }
186
+ return response[0];
187
+ }
188
+ Rivendell.fetchAppInstallation = fetchAppInstallation;
189
+ /**
190
+ * Trigger an installation.
191
+ */
192
+ async function install(appId, version, trackerId, shard) {
193
+ const response = await RivendellApi_1.RivendellApi.post(path(shard, 'installations'), { appId, version, trackerId });
194
+ return response.body;
195
+ }
196
+ Rivendell.install = install;
197
+ /**
198
+ * Trigger an uninstall.
199
+ */
200
+ async function uninstall(appInstallationId, shard) {
201
+ await RivendellApi_1.RivendellApi.request('DELETE', path(shard, `installations/${appInstallationId}`));
202
+ }
203
+ Rivendell.uninstall = uninstall;
204
+ /**
205
+ * Request an upgrade.
206
+ */
207
+ async function upgrade(appInstallationId, appId, version, shard) {
208
+ await RivendellApi_1.RivendellApi.put(path(shard, `installations/${appInstallationId}`), { appId, version });
209
+ }
210
+ Rivendell.upgrade = upgrade;
211
+ /**
212
+ * Trigger a publish.
213
+ */
214
+ async function publish(appId, version, shard) {
215
+ await RivendellApi_1.RivendellApi.request('PATCH', path(shard, `versions/${appId}@${version}`), { state: AppVersionState.RUNNING });
216
+ }
217
+ Rivendell.publish = publish;
218
+ /**
219
+ * Trigger a unpublish.
220
+ */
221
+ async function unpublish(appId, version, shard) {
222
+ await RivendellApi_1.RivendellApi.request('PATCH', path(shard, `versions/${appId}@${version}`), { state: AppVersionState.STOPPED });
223
+ }
224
+ Rivendell.unpublish = unpublish;
225
+ /**
226
+ * Fetch a build by id.
227
+ */
228
+ async function fetchBuild(id) {
229
+ const response = await RivendellApi_1.RivendellApi.get(`builds/${id}`);
230
+ return response.body;
231
+ }
232
+ Rivendell.fetchBuild = fetchBuild;
233
+ /**
234
+ * Trigger a build.
235
+ */
236
+ async function build(appId, version) {
237
+ const response = await RivendellApi_1.RivendellApi.post('builds', { appId, version });
238
+ return response.body;
239
+ }
240
+ Rivendell.build = build;
241
+ /**
242
+ * Trigger a verification.
243
+ */
244
+ async function verify(appId, version) {
245
+ const response = await RivendellApi_1.RivendellApi.post('verifications', { appId, version });
246
+ return response.body;
247
+ }
248
+ Rivendell.verify = verify;
249
+ /**
250
+ * Fetch temp credentials to upload to s3.
251
+ */
252
+ async function uploadCredentials(vendor, appId, version, checksum) {
253
+ const response = await RivendellApi_1.RivendellApi.post('tokens', { vendor, appId, version, checksum });
254
+ return response.body;
255
+ }
256
+ Rivendell.uploadCredentials = uploadCredentials;
257
+ /**
258
+ * List shards.
259
+ */
260
+ async function shards() {
261
+ const response = await RivendellApi_1.RivendellApi.get('shards');
262
+ const me = await Rivendell.whoami();
263
+ return response.body.filter((s) => me.role === 'administrator' || s.live);
264
+ }
265
+ Rivendell.shards = shards;
266
+ /**
267
+ * Search Jobs.
268
+ */
269
+ async function searchJobs(criteria, shard) {
270
+ const response = await RivendellApi_1.RivendellApi.post(path(shard, 'jobs/search'), criteria);
271
+ return response.body;
272
+ }
273
+ Rivendell.searchJobs = searchJobs;
274
+ /**
275
+ * Terminate Jobs
276
+ */
277
+ async function terminateJob(jobId, shard) {
278
+ await RivendellApi_1.RivendellApi.delete_(path(shard, `jobs/${jobId}`));
279
+ }
280
+ Rivendell.terminateJob = terminateJob;
281
+ /**
282
+ * Trigger a Job
283
+ */
284
+ async function triggerJob(appId, jobName, trackerId, parameters, shard) {
285
+ const body = { appId, jobName, trackerId, parameters };
286
+ const response = await RivendellApi_1.RivendellApi.post(path(shard, 'jobs'), body);
287
+ return response.body;
288
+ }
289
+ Rivendell.triggerJob = triggerJob;
290
+ /**
291
+ * Fetch a Job
292
+ */
293
+ async function fetchJob(jobId, shard) {
294
+ const response = await RivendellApi_1.RivendellApi.get(path(shard, `jobs/${jobId}`));
295
+ return response.body;
296
+ }
297
+ Rivendell.fetchJob = fetchJob;
298
+ /**
299
+ * Fetch a jobs runtimeStatus
300
+ */
301
+ async function fetchJobRuntimeStatus(jobId, shard) {
302
+ const response = await RivendellApi_1.RivendellApi.get(path(shard, `jobs/${jobId}/runtimeStatus`));
303
+ return response.body;
304
+ }
305
+ Rivendell.fetchJobRuntimeStatus = fetchJobRuntimeStatus;
306
+ /**
307
+ * Get Moria JWT for this developer.
308
+ */
309
+ let cachedJwt;
310
+ async function jwt(shard) {
311
+ const now = new Date();
312
+ if (!cachedJwt || cachedJwt.payload.exp * 1000 - now.getTime() <= 60) {
313
+ const response = await RivendellApi_1.RivendellApi.get(path(shard, 'tokens/jwt'));
314
+ cachedJwt = parseJwt(response.body.jwt);
315
+ }
316
+ return cachedJwt.token;
317
+ }
318
+ Rivendell.jwt = jwt;
319
+ function parseJwt(token) {
320
+ const parts = token.split('.');
321
+ return {
322
+ token,
323
+ header: JSON.parse(Buffer.from(parts[0], 'base64').toString()),
324
+ payload: JSON.parse(Buffer.from(parts[1], 'base64').toString())
325
+ };
326
+ }
327
+ })(Rivendell = exports.Rivendell || (exports.Rivendell = {}));
328
+ //# sourceMappingURL=Rivendell.js.map