@antelopejs/dms-antelope-cloud 0.0.0-stage → 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 (224) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +447 -2
  3. package/dist/cloud-status.d.ts +13 -0
  4. package/dist/cloud-status.js +77 -0
  5. package/dist/config.d.ts +84 -0
  6. package/dist/config.js +104 -0
  7. package/dist/configured.d.ts +16 -0
  8. package/dist/configured.js +26 -0
  9. package/dist/connection/actions.d.ts +40 -0
  10. package/dist/connection/actions.js +120 -0
  11. package/dist/connection/announce.d.ts +8 -0
  12. package/dist/connection/announce.js +20 -0
  13. package/dist/connection/cloud.d.ts +60 -0
  14. package/dist/connection/cloud.js +87 -0
  15. package/dist/connection/content.d.ts +70 -0
  16. package/dist/connection/content.js +462 -0
  17. package/dist/connection/current.d.ts +26 -0
  18. package/dist/connection/current.js +28 -0
  19. package/dist/connection/device-flow.d.ts +16 -0
  20. package/dist/connection/device-flow.js +146 -0
  21. package/dist/connection/refusals.d.ts +51 -0
  22. package/dist/connection/refusals.js +85 -0
  23. package/dist/connection/repository.d.ts +28 -0
  24. package/dist/connection/repository.js +69 -0
  25. package/dist/connection/seal.d.ts +22 -0
  26. package/dist/connection/seal.js +47 -0
  27. package/dist/connection/store.d.ts +294 -0
  28. package/dist/connection/store.js +165 -0
  29. package/dist/connection/view.d.ts +39 -0
  30. package/dist/connection/view.js +39 -0
  31. package/dist/dashboard/actions.d.ts +40 -0
  32. package/dist/dashboard/actions.js +115 -0
  33. package/dist/dashboard/dockerfile.d.ts +34 -0
  34. package/dist/dashboard/dockerfile.js +71 -0
  35. package/dist/dashboard/service.d.ts +61 -0
  36. package/dist/dashboard/service.js +137 -0
  37. package/dist/dashboard/variables.d.ts +30 -0
  38. package/dist/dashboard/variables.js +34 -0
  39. package/dist/deployments/build-log.d.ts +39 -0
  40. package/dist/deployments/build-log.js +57 -0
  41. package/dist/deployments/cloud-steps.d.ts +77 -0
  42. package/dist/deployments/cloud-steps.js +132 -0
  43. package/dist/deployments/content.d.ts +61 -0
  44. package/dist/deployments/content.js +268 -0
  45. package/dist/deployments/deployment.d.ts +96 -0
  46. package/dist/deployments/deployment.js +3 -0
  47. package/dist/deployments/follow.d.ts +18 -0
  48. package/dist/deployments/follow.js +112 -0
  49. package/dist/deployments/ledger.d.ts +23 -0
  50. package/dist/deployments/ledger.js +359 -0
  51. package/dist/deployments/lifecycle.d.ts +123 -0
  52. package/dist/deployments/lifecycle.js +146 -0
  53. package/dist/deployments/live.d.ts +28 -0
  54. package/dist/deployments/live.js +54 -0
  55. package/dist/deployments/publish-read.d.ts +20 -0
  56. package/dist/deployments/publish-read.js +24 -0
  57. package/dist/deployments/refusals.d.ts +13 -0
  58. package/dist/deployments/refusals.js +35 -0
  59. package/dist/environments/actions.d.ts +86 -0
  60. package/dist/environments/actions.js +210 -0
  61. package/dist/environments/address.d.ts +60 -0
  62. package/dist/environments/address.js +149 -0
  63. package/dist/environments/content.d.ts +97 -0
  64. package/dist/environments/content.js +275 -0
  65. package/dist/environments/follower.d.ts +32 -0
  66. package/dist/environments/follower.js +114 -0
  67. package/dist/environments/pipeline.d.ts +58 -0
  68. package/dist/environments/pipeline.js +76 -0
  69. package/dist/environments/publish-targets.d.ts +18 -0
  70. package/dist/environments/publish-targets.js +55 -0
  71. package/dist/environments/roles.d.ts +73 -0
  72. package/dist/environments/roles.js +97 -0
  73. package/dist/frontend-module.d.ts +12 -0
  74. package/dist/frontend-module.js +25 -0
  75. package/dist/git/changed-files.d.ts +30 -0
  76. package/dist/git/changed-files.js +107 -0
  77. package/dist/git/changes.d.ts +89 -0
  78. package/dist/git/changes.js +162 -0
  79. package/dist/git/command.d.ts +51 -0
  80. package/dist/git/command.js +231 -0
  81. package/dist/git/promotion.d.ts +23 -0
  82. package/dist/git/promotion.js +46 -0
  83. package/dist/git/publish-input.d.ts +42 -0
  84. package/dist/git/publish-input.js +62 -0
  85. package/dist/git/publish-job.d.ts +82 -0
  86. package/dist/git/publish-job.js +99 -0
  87. package/dist/git/publish-steps.d.ts +90 -0
  88. package/dist/git/publish-steps.js +205 -0
  89. package/dist/git/publisher.d.ts +23 -0
  90. package/dist/git/publisher.js +206 -0
  91. package/dist/git/refs.d.ts +99 -0
  92. package/dist/git/refs.js +178 -0
  93. package/dist/git/refusal.d.ts +49 -0
  94. package/dist/git/refusal.js +70 -0
  95. package/dist/git/repository.d.ts +101 -0
  96. package/dist/git/repository.js +273 -0
  97. package/dist/git/versions.d.ts +99 -0
  98. package/dist/git/versions.js +174 -0
  99. package/dist/git/write-lock.d.ts +19 -0
  100. package/dist/git/write-lock.js +49 -0
  101. package/dist/index.d.ts +5 -0
  102. package/dist/index.js +59 -0
  103. package/dist/lifecycle.d.ts +8 -0
  104. package/dist/lifecycle.js +78 -0
  105. package/dist/logs/relay.d.ts +25 -0
  106. package/dist/logs/relay.js +138 -0
  107. package/dist/null-prototype.d.ts +7 -0
  108. package/dist/null-prototype.js +3 -0
  109. package/dist/overview/content.d.ts +40 -0
  110. package/dist/overview/content.js +172 -0
  111. package/dist/pages/changes.d.ts +32 -0
  112. package/dist/pages/changes.js +141 -0
  113. package/dist/pages/connection.d.ts +43 -0
  114. package/dist/pages/connection.js +295 -0
  115. package/dist/pages/deployment.d.ts +67 -0
  116. package/dist/pages/deployment.js +261 -0
  117. package/dist/pages/deployments.d.ts +46 -0
  118. package/dist/pages/deployments.js +266 -0
  119. package/dist/pages/environments.d.ts +34 -0
  120. package/dist/pages/environments.js +368 -0
  121. package/dist/pages/logs.d.ts +46 -0
  122. package/dist/pages/logs.js +140 -0
  123. package/dist/pages/navigation.d.ts +61 -0
  124. package/dist/pages/navigation.js +107 -0
  125. package/dist/pages/overview.d.ts +35 -0
  126. package/dist/pages/overview.js +201 -0
  127. package/dist/pages/project-guard.d.ts +32 -0
  128. package/dist/pages/project-guard.js +99 -0
  129. package/dist/pages/query.d.ts +6 -0
  130. package/dist/pages/query.js +14 -0
  131. package/dist/pages/resources.d.ts +37 -0
  132. package/dist/pages/resources.js +211 -0
  133. package/dist/pages/setup.d.ts +40 -0
  134. package/dist/pages/setup.js +271 -0
  135. package/dist/pages/slugs.d.ts +15 -0
  136. package/dist/pages/slugs.js +28 -0
  137. package/dist/pages/variables.d.ts +43 -0
  138. package/dist/pages/variables.js +327 -0
  139. package/dist/pages/version.d.ts +26 -0
  140. package/dist/pages/version.js +214 -0
  141. package/dist/pages/versions.d.ts +20 -0
  142. package/dist/pages/versions.js +115 -0
  143. package/dist/resources/apply.d.ts +15 -0
  144. package/dist/resources/apply.js +127 -0
  145. package/dist/resources/cards.d.ts +41 -0
  146. package/dist/resources/cards.js +211 -0
  147. package/dist/resources/connect.d.ts +66 -0
  148. package/dist/resources/connect.js +78 -0
  149. package/dist/resources/content.d.ts +26 -0
  150. package/dist/resources/content.js +158 -0
  151. package/dist/resources/format.d.ts +10 -0
  152. package/dist/resources/format.js +30 -0
  153. package/dist/resources/guard.d.ts +23 -0
  154. package/dist/resources/guard.js +60 -0
  155. package/dist/resources/modules.d.ts +23 -0
  156. package/dist/resources/modules.js +39 -0
  157. package/dist/resources/plan.d.ts +8 -0
  158. package/dist/resources/plan.js +93 -0
  159. package/dist/resources/read.d.ts +54 -0
  160. package/dist/resources/read.js +69 -0
  161. package/dist/resources/refusals.d.ts +15 -0
  162. package/dist/resources/refusals.js +33 -0
  163. package/dist/resources/routes.d.ts +32 -0
  164. package/dist/resources/routes.js +53 -0
  165. package/dist/setup/actions.d.ts +79 -0
  166. package/dist/setup/actions.js +188 -0
  167. package/dist/setup/apply.d.ts +37 -0
  168. package/dist/setup/apply.js +172 -0
  169. package/dist/setup/content.d.ts +50 -0
  170. package/dist/setup/content.js +440 -0
  171. package/dist/setup/rollout.d.ts +119 -0
  172. package/dist/setup/rollout.js +227 -0
  173. package/dist/setup/steps.d.ts +93 -0
  174. package/dist/setup/steps.js +95 -0
  175. package/dist/setup/storage.d.ts +29 -0
  176. package/dist/setup/storage.js +78 -0
  177. package/dist/setup/store.d.ts +214 -0
  178. package/dist/setup/store.js +174 -0
  179. package/dist/setup/volume.d.ts +31 -0
  180. package/dist/setup/volume.js +52 -0
  181. package/dist/slug.d.ts +7 -0
  182. package/dist/slug.js +26 -0
  183. package/dist/variables/actions.d.ts +76 -0
  184. package/dist/variables/actions.js +185 -0
  185. package/dist/variables/content.d.ts +69 -0
  186. package/dist/variables/content.js +310 -0
  187. package/dist/variables/decide.d.ts +27 -0
  188. package/dist/variables/decide.js +155 -0
  189. package/dist/variables/decided-dialog.d.ts +11 -0
  190. package/dist/variables/decided-dialog.js +129 -0
  191. package/dist/variables/decided.d.ts +80 -0
  192. package/dist/variables/decided.js +240 -0
  193. package/dist/variables/dialogs.d.ts +8 -0
  194. package/dist/variables/dialogs.js +219 -0
  195. package/dist/variables/model.d.ts +106 -0
  196. package/dist/variables/model.js +156 -0
  197. package/dist/variables/project-config.d.ts +117 -0
  198. package/dist/variables/project-config.js +248 -0
  199. package/dist/variables/read.d.ts +33 -0
  200. package/dist/variables/read.js +118 -0
  201. package/dist/web-url.d.ts +9 -0
  202. package/dist/web-url.js +19 -0
  203. package/frontend-vue/app/components/BuildLog.vue +99 -0
  204. package/frontend-vue/app/components/ChangedFiles.vue +165 -0
  205. package/frontend-vue/app/components/DashboardEnvironments.vue +102 -0
  206. package/frontend-vue/app/components/LogLine.vue +33 -0
  207. package/frontend-vue/app/components/LogViewer.vue +314 -0
  208. package/frontend-vue/app/components/PublishChipIcon.vue +39 -0
  209. package/frontend-vue/app/components/PublishForm.vue +505 -0
  210. package/frontend-vue/app/components/PublishPopover.vue +90 -0
  211. package/frontend-vue/app/components/PublishRoute.vue +222 -0
  212. package/frontend-vue/app/composables/usePublishSummary.ts +80 -0
  213. package/frontend-vue/app/plugins/publish-chip.client.ts +44 -0
  214. package/frontend-vue/app/types/publishing.ts +154 -0
  215. package/frontend-vue/app/utils/build-log.ts +96 -0
  216. package/frontend-vue/app/utils/changed-files.ts +142 -0
  217. package/frontend-vue/app/utils/log-line.ts +15 -0
  218. package/frontend-vue/app/utils/log-stream.ts +361 -0
  219. package/frontend-vue/app/utils/publish-state.ts +299 -0
  220. package/frontend-vue/dms.frontend.ts +27 -0
  221. package/frontend-vue/i18n/locales/antelope-cloud-en-GB.json +110 -0
  222. package/frontend-vue/package.json +38 -0
  223. package/frontend-vue/pnpm-lock.yaml +2697 -0
  224. package/package.json +115 -3
@@ -0,0 +1,99 @@
1
+ import { type ChangedFile } from "./changed-files";
2
+ import { type Release, type RepositorySnapshot } from "./repository";
3
+ /** An `env/<name>` branch: what AntelopeJS Cloud builds for that environment. */
4
+ export type Environment = {
5
+ /** The environment's name, `preview`. */
6
+ readonly name: string;
7
+ /** Its branch, `env/preview`. */
8
+ readonly branch: string;
9
+ /** The commit the branch points to on origin, else locally; `null` when it does not exist yet. */
10
+ readonly commit: string | null;
11
+ /** The version whose tagged commit is `commit`, if any. */
12
+ readonly version: number | null;
13
+ };
14
+ /** A version as its tag names it. */
15
+ export type VersionRef = {
16
+ readonly number: number;
17
+ readonly tag: string;
18
+ readonly name: string;
19
+ };
20
+ /** A published version, as the Versions page lists it. */
21
+ export type VersionSummary = VersionRef & {
22
+ /** The tagged commit. */
23
+ readonly commit: string;
24
+ /** The subject of the tagged commit. */
25
+ readonly message: string;
26
+ /** Who tagged the version. */
27
+ readonly author: {
28
+ readonly name: string;
29
+ readonly email: string;
30
+ };
31
+ /** When the version was tagged, ISO 8601. */
32
+ readonly publishedAt: string;
33
+ /** The environments whose branch points to `commit`. */
34
+ readonly environments: readonly string[];
35
+ };
36
+ /** A commit between two versions. */
37
+ type VersionCommit = {
38
+ readonly sha: string;
39
+ readonly subject: string;
40
+ readonly author: string;
41
+ /** The author date, ISO 8601. */
42
+ readonly date: string;
43
+ };
44
+ /** A published version, with what changed since the version before it. */
45
+ export type VersionDetail = VersionSummary & {
46
+ /** The tag message after its subject, `""` when there is none. */
47
+ readonly releaseNotes: string;
48
+ readonly previous: VersionRef | null;
49
+ /** The files changed since the previous version, or since the empty tree for the first one. */
50
+ readonly files: readonly ChangedFile[];
51
+ /** The commits since the previous version, newest first. */
52
+ readonly commits: readonly VersionCommit[];
53
+ };
54
+ /**
55
+ * Every environment branch of the repository, local or on origin, with the
56
+ * commit origin holds for it (else the local one) and the version there.
57
+ */
58
+ export declare function listEnvironments(snapshot: RepositorySnapshot): Environment[];
59
+ /**
60
+ * The environments named `names`, in that order: each as the repository
61
+ * holds its branch, or not created yet.
62
+ */
63
+ export declare function environmentsNamed(environments: readonly Environment[], names: readonly string[]): Environment[];
64
+ /**
65
+ * The environments a publish may move when only the repository says so:
66
+ * every environment branch but production, or Preview, not created yet, when
67
+ * there is none.
68
+ */
69
+ export declare function publishTargets(environments: readonly Environment[]): Environment[];
70
+ /** Whether an environment is production, which a project with an earlier stage only promotes to. */
71
+ export declare function isPromotedOnly(name: string): boolean;
72
+ /** The number, tag and name of a version. */
73
+ export declare function versionRef(release: Release): VersionRef;
74
+ /**
75
+ * The published versions, newest first: each local version whose tag origin
76
+ * holds as this repository has it. Without an answer from origin, every local
77
+ * version counts as published.
78
+ */
79
+ export declare function publishedReleases(snapshot: RepositorySnapshot): readonly Release[];
80
+ /** The number of the newest published version whose tagged commit is `commit`, else `null`. */
81
+ export declare function publishedVersionOf(snapshot: RepositorySnapshot, commit: string): number | null;
82
+ /** Every published version of the repository, newest first. */
83
+ export declare function listVersions(snapshot: RepositorySnapshot): VersionSummary[];
84
+ /** A published version found by its number, with the published version before it. */
85
+ export type VersionAt = {
86
+ readonly release: Release;
87
+ readonly summary: VersionSummary;
88
+ /** The published version with the next lower number, `null` for the first one. */
89
+ readonly previous: Release | null;
90
+ };
91
+ /** The published version with this number, or `null` when there is none. */
92
+ export declare function versionAt(snapshot: RepositorySnapshot, number: number): VersionAt | null;
93
+ /**
94
+ * A published version with its release notes, the published version before
95
+ * it, and the files and commits since that one, or `null` when no published
96
+ * version has its number.
97
+ */
98
+ export declare function readVersion(snapshot: RepositorySnapshot, number: number): Promise<VersionDetail | null>;
99
+ export {};
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listEnvironments = listEnvironments;
4
+ exports.environmentsNamed = environmentsNamed;
5
+ exports.publishTargets = publishTargets;
6
+ exports.isPromotedOnly = isPromotedOnly;
7
+ exports.versionRef = versionRef;
8
+ exports.publishedReleases = publishedReleases;
9
+ exports.publishedVersionOf = publishedVersionOf;
10
+ exports.listVersions = listVersions;
11
+ exports.versionAt = versionAt;
12
+ exports.readVersion = readVersion;
13
+ const changed_files_1 = require("./changed-files");
14
+ const command_1 = require("./command");
15
+ const refs_1 = require("./refs");
16
+ const repository_1 = require("./repository");
17
+ /** The environment a publish targets when the repository has none yet. */
18
+ const FIRST_ENVIRONMENT = "preview";
19
+ /** The environment that receives promoted versions only, never a publish. */
20
+ const PROMOTED_ONLY_ENVIRONMENT = "production";
21
+ /** Where an environment sits in the usual path of a version; others follow by name. */
22
+ const STAGES = ["preview", "staging", PROMOTED_ONLY_ENVIRONMENT];
23
+ const COMMIT_FIELDS = ["%H", "%s", "%an", "%aI"];
24
+ function stageRank(name) {
25
+ const rank = STAGES.indexOf(name);
26
+ return rank === -1 ? STAGES.length : rank;
27
+ }
28
+ function compareEnvironments(a, b) {
29
+ return stageRank(a) - stageRank(b) || a.localeCompare(b);
30
+ }
31
+ function originEnvironmentNames(snapshot) {
32
+ if (snapshot.origin.kind !== "reachable")
33
+ return [];
34
+ return [...snapshot.origin.refs.keys()].flatMap((ref) => {
35
+ const branch = (0, refs_1.branchOfRef)(ref);
36
+ const name = branch === null ? null : (0, refs_1.environmentOfBranch)(branch);
37
+ return name === null ? [] : [name];
38
+ });
39
+ }
40
+ /**
41
+ * Every environment branch of the repository, local or on origin, with the
42
+ * commit origin holds for it (else the local one) and the version there.
43
+ */
44
+ function listEnvironments(snapshot) {
45
+ const names = new Set([
46
+ ...snapshot.localEnvironments.keys(),
47
+ ...originEnvironmentNames(snapshot),
48
+ ]);
49
+ const published = publishedReleases(snapshot);
50
+ return [...names].sort(compareEnvironments).map((name) => {
51
+ const branch = (0, refs_1.environmentBranch)(name);
52
+ const commit = (0, repository_1.originObject)(snapshot.origin, (0, refs_1.branchRef)(branch)) ??
53
+ snapshot.localEnvironments.get(name) ??
54
+ null;
55
+ const release = published.find((entry) => entry.commit === commit);
56
+ return { name, branch, commit, version: release?.number ?? null };
57
+ });
58
+ }
59
+ /**
60
+ * The environments named `names`, in that order: each as the repository
61
+ * holds its branch, or not created yet.
62
+ */
63
+ function environmentsNamed(environments, names) {
64
+ return names.map((name) => environments.find((environment) => environment.name === name) ?? {
65
+ name,
66
+ branch: (0, refs_1.environmentBranch)(name),
67
+ commit: null,
68
+ version: null,
69
+ });
70
+ }
71
+ /**
72
+ * The environments a publish may move when only the repository says so:
73
+ * every environment branch but production, or Preview, not created yet, when
74
+ * there is none.
75
+ */
76
+ function publishTargets(environments) {
77
+ const targets = environments.filter(({ name }) => name !== PROMOTED_ONLY_ENVIRONMENT);
78
+ return targets.length > 0
79
+ ? targets
80
+ : environmentsNamed([], [FIRST_ENVIRONMENT]);
81
+ }
82
+ /** Whether an environment is production, which a project with an earlier stage only promotes to. */
83
+ function isPromotedOnly(name) {
84
+ return name === PROMOTED_ONLY_ENVIRONMENT;
85
+ }
86
+ /** The number, tag and name of a version. */
87
+ function versionRef(release) {
88
+ return { number: release.number, tag: release.tag, name: release.name };
89
+ }
90
+ function summarize(release, environments) {
91
+ return {
92
+ ...versionRef(release),
93
+ commit: release.commit,
94
+ message: release.message,
95
+ author: release.tagger,
96
+ publishedAt: release.taggedAt,
97
+ environments: environments
98
+ .filter(({ commit }) => commit === release.commit)
99
+ .map(({ name }) => name),
100
+ };
101
+ }
102
+ /**
103
+ * The published versions, newest first: each local version whose tag origin
104
+ * holds as this repository has it. Without an answer from origin, every local
105
+ * version counts as published.
106
+ */
107
+ function publishedReleases(snapshot) {
108
+ const { origin, releases } = snapshot;
109
+ if (origin.kind !== "reachable")
110
+ return releases;
111
+ return releases.filter((release) => (0, repository_1.originObject)(origin, (0, refs_1.tagRef)(release.tag)) === release.object);
112
+ }
113
+ /** The number of the newest published version whose tagged commit is `commit`, else `null`. */
114
+ function publishedVersionOf(snapshot, commit) {
115
+ return (publishedReleases(snapshot).find((release) => release.commit === commit)
116
+ ?.number ?? null);
117
+ }
118
+ /** Every published version of the repository, newest first. */
119
+ function listVersions(snapshot) {
120
+ const environments = listEnvironments(snapshot);
121
+ return publishedReleases(snapshot).map((release) => summarize(release, environments));
122
+ }
123
+ async function commitsBetween(path, previous, commit) {
124
+ const range = previous === null ? [commit] : [`${previous}..${commit}`];
125
+ const output = await (0, command_1.git)(path, [
126
+ "log",
127
+ `--format=${COMMIT_FIELDS.join("%x00")}`,
128
+ "-z",
129
+ ...range,
130
+ ]);
131
+ const fields = output.split("\0");
132
+ const commits = [];
133
+ for (let start = 0; start + COMMIT_FIELDS.length <= fields.length; start += COMMIT_FIELDS.length) {
134
+ const [sha = "", subject = "", author = "", date = ""] = fields.slice(start, start + COMMIT_FIELDS.length);
135
+ commits.push({ sha, subject, author, date });
136
+ }
137
+ return commits;
138
+ }
139
+ /** The published version with this number, or `null` when there is none. */
140
+ function versionAt(snapshot, number) {
141
+ const published = publishedReleases(snapshot);
142
+ const index = published.findIndex((release) => release.number === number);
143
+ const release = published[index];
144
+ if (!release)
145
+ return null;
146
+ return {
147
+ release,
148
+ summary: summarize(release, listEnvironments(snapshot)),
149
+ previous: published[index + 1] ?? null,
150
+ };
151
+ }
152
+ /**
153
+ * A published version with its release notes, the published version before
154
+ * it, and the files and commits since that one, or `null` when no published
155
+ * version has its number.
156
+ */
157
+ async function readVersion(snapshot, number) {
158
+ const found = versionAt(snapshot, number);
159
+ if (!found)
160
+ return null;
161
+ const { release, previous } = found;
162
+ const [files, commits] = await Promise.all([
163
+ (0, changed_files_1.filesBetween)(snapshot.path, previous?.commit ?? snapshot.emptyTree, release.commit),
164
+ commitsBetween(snapshot.path, previous?.commit ?? null, release.commit),
165
+ ]);
166
+ return {
167
+ ...found.summary,
168
+ releaseNotes: release.notes,
169
+ previous: previous ? versionRef(previous) : null,
170
+ files,
171
+ commits,
172
+ };
173
+ }
174
+ //# sourceMappingURL=versions.js.map
@@ -0,0 +1,19 @@
1
+ /** What writes the repository's refs and pushes them to origin. */
2
+ export type GitWriter = "publish" | "promotion";
3
+ /**
4
+ * Takes the repository's git writes for a publish, until {@link endPublish}
5
+ * gives them back. A publish does not begin while another one runs, nor
6
+ * while a promotion runs or waits for its turn.
7
+ *
8
+ * @returns What holds the writes instead, `null` once the publish holds them.
9
+ */
10
+ export declare function beginPublish(): GitWriter | null;
11
+ /** Gives back the git writes a publish took with {@link beginPublish}. */
12
+ export declare function endPublish(): void;
13
+ /** Whether a publish holds the repository's git writes. */
14
+ export declare function isPublishing(): boolean;
15
+ /**
16
+ * Runs `promotion` once every promotion asked for before it has ended, and
17
+ * keeps any publish from beginning until it ends.
18
+ */
19
+ export declare function inPromotionTurn<T>(promotion: () => Promise<T>): Promise<T>;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.beginPublish = beginPublish;
4
+ exports.endPublish = endPublish;
5
+ exports.isPublishing = isPublishing;
6
+ exports.inPromotionTurn = inPromotionTurn;
7
+ let publishing = false;
8
+ let promotions = 0;
9
+ let lastPromotion = Promise.resolve();
10
+ function ignore() { }
11
+ /**
12
+ * Takes the repository's git writes for a publish, until {@link endPublish}
13
+ * gives them back. A publish does not begin while another one runs, nor
14
+ * while a promotion runs or waits for its turn.
15
+ *
16
+ * @returns What holds the writes instead, `null` once the publish holds them.
17
+ */
18
+ function beginPublish() {
19
+ if (publishing)
20
+ return "publish";
21
+ if (promotions > 0)
22
+ return "promotion";
23
+ publishing = true;
24
+ return null;
25
+ }
26
+ /** Gives back the git writes a publish took with {@link beginPublish}. */
27
+ function endPublish() {
28
+ publishing = false;
29
+ }
30
+ /** Whether a publish holds the repository's git writes. */
31
+ function isPublishing() {
32
+ return publishing;
33
+ }
34
+ /**
35
+ * Runs `promotion` once every promotion asked for before it has ended, and
36
+ * keeps any publish from beginning until it ends.
37
+ */
38
+ async function inPromotionTurn(promotion) {
39
+ promotions += 1;
40
+ const turn = lastPromotion.then(promotion);
41
+ lastPromotion = turn.then(ignore, ignore);
42
+ try {
43
+ return await turn;
44
+ }
45
+ finally {
46
+ promotions -= 1;
47
+ }
48
+ }
49
+ //# sourceMappingURL=write-lock.js.map
@@ -0,0 +1,5 @@
1
+ import { type AntelopeCloudConfig } from "./config";
2
+ export type { AntelopeCloudConfig } from "./config";
3
+ export declare function construct(config?: AntelopeCloudConfig): Promise<void>;
4
+ export declare function start(): Promise<void>;
5
+ export declare function stop(): void;
package/dist/index.js ADDED
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.construct = construct;
37
+ exports.start = start;
38
+ exports.stop = stop;
39
+ const logging_1 = require("@antelopejs/interface-core/logging");
40
+ const config_1 = require("./config");
41
+ const configured_1 = require("./configured");
42
+ const LOG_CHANNEL = "antelope-cloud";
43
+ let lifecycle;
44
+ async function construct(config = {}) {
45
+ if (!(0, config_1.configureCloudModule)(config)) {
46
+ lifecycle = undefined;
47
+ new logging_1.Logging.Channel(LOG_CHANNEL).Info(configured_1.NOT_CONFIGURED_NOTICE);
48
+ return;
49
+ }
50
+ lifecycle = await Promise.resolve().then(() => __importStar(require("./lifecycle")));
51
+ await lifecycle.registerPages();
52
+ }
53
+ async function start() {
54
+ await lifecycle?.startModule();
55
+ }
56
+ function stop() {
57
+ lifecycle?.stopModule();
58
+ }
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The lifecycle of the configured module. `index.ts` loads this file only
3
+ * once the project gave the module its `secretKey`: importing it declares the
4
+ * module's table, and its pages declare their routes.
5
+ */
6
+ export declare function registerPages(): Promise<void>;
7
+ export declare function startModule(): Promise<void>;
8
+ export declare function stopModule(): void;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.registerPages = registerPages;
37
+ exports.startModule = startModule;
38
+ exports.stopModule = stopModule;
39
+ const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
40
+ const page_1 = require("@antelopejs/interface-dms/page");
41
+ const config_1 = require("./config");
42
+ const device_flow_1 = require("./connection/device-flow");
43
+ const store_1 = require("./connection/store");
44
+ const follow_1 = require("./deployments/follow");
45
+ const follower_1 = require("./environments/follower");
46
+ const frontend_module_1 = require("./frontend-module");
47
+ /**
48
+ * The lifecycle of the configured module. `index.ts` loads this file only
49
+ * once the project gave the module its `secretKey`: importing it declares the
50
+ * module's table, and its pages declare their routes.
51
+ */
52
+ async function registerPages() {
53
+ await Promise.resolve().then(() => __importStar(require("./pages/navigation")));
54
+ await Promise.resolve().then(() => __importStar(require("./pages/connection")));
55
+ await Promise.resolve().then(() => __importStar(require("./pages/changes")));
56
+ await Promise.resolve().then(() => __importStar(require("./pages/versions")));
57
+ await Promise.resolve().then(() => __importStar(require("./pages/version")));
58
+ await Promise.resolve().then(() => __importStar(require("./pages/resources")));
59
+ await Promise.resolve().then(() => __importStar(require("./pages/variables")));
60
+ await Promise.resolve().then(() => __importStar(require("./pages/deployments")));
61
+ await Promise.resolve().then(() => __importStar(require("./pages/deployment")));
62
+ await Promise.resolve().then(() => __importStar(require("./pages/logs")));
63
+ await Promise.resolve().then(() => __importStar(require("./pages/environments")));
64
+ await Promise.resolve().then(() => __importStar(require("./pages/overview")));
65
+ await Promise.resolve().then(() => __importStar(require("./pages/setup")));
66
+ }
67
+ async function startModule() {
68
+ await (0, interface_database_decorators_1.RegisterSchema)(store_1.SCHEMA_NAME);
69
+ if (!(0, config_1.cloudSettings)().managed)
70
+ await (0, device_flow_1.resumeDeviceFlows)();
71
+ await (0, page_1.AddFrontendModule)((0, frontend_module_1.frontendRegistration)());
72
+ }
73
+ function stopModule() {
74
+ (0, device_flow_1.stopDeviceFlows)();
75
+ (0, follow_1.stopFollowing)();
76
+ (0, follower_1.stopFollowingPromotions)();
77
+ }
78
+ //# sourceMappingURL=lifecycle.js.map
@@ -0,0 +1,25 @@
1
+ import type { PassThrough } from "node:stream";
2
+ import type { ActiveConnection } from "../connection/current";
3
+ /** What one relay serves. The service was checked to be the project's before it opened. */
4
+ export interface LogRelay {
5
+ readonly connection: ActiveConnection;
6
+ readonly projectId: string;
7
+ readonly environmentId: string;
8
+ readonly serviceId: string;
9
+ /** The cursor of the last line the browser received: the relay sends the lines after it. */
10
+ readonly after: string | undefined;
11
+ readonly out: PassThrough;
12
+ /** Aborts when the browser goes away. */
13
+ readonly closed: AbortSignal;
14
+ }
15
+ /**
16
+ * Streams one service's logs to `out` as {@link LogFrame}s, after the cursor
17
+ * the browser sent: the Cloud cursor passes through as each line's SSE id,
18
+ * and back to the Cloud as `Last-Event-ID`.
19
+ * It sends `live` (or `sleeping`, when every replica is scaled to zero) once
20
+ * the Cloud accepts the read, then the lines, then ends `out`: after a
21
+ * closing status, or with none when the stream dropped, which the browser
22
+ * reads as a cue to reconnect. The browser leaving aborts the Cloud read.
23
+ * Never throws.
24
+ */
25
+ export declare function relayLogs(relay: LogRelay): Promise<void>;
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.relayLogs = relayLogs;
4
+ const cloud_sdk_1 = require("@antelopejs/cloud-sdk");
5
+ const zod_1 = require("zod");
6
+ const cloud_1 = require("../connection/cloud");
7
+ const logLineSchema = zod_1.z.object({
8
+ at: zod_1.z.string(),
9
+ level: zod_1.z.string(),
10
+ message: zod_1.z.string(),
11
+ instance: zod_1.z.string().nullable(),
12
+ });
13
+ /** A comment frame this often keeps idle proxies from closing the response. */
14
+ const KEEPALIVE_MS = 15_000;
15
+ const BUSY_RETRY_MS = 1_000;
16
+ /** The longest wait a busy answer may ask of the viewer, whatever AntelopeJS Cloud says. */
17
+ const MAX_BUSY_RETRY_MS = 60_000;
18
+ const MS_PER_SECOND = 1000;
19
+ const HTTP_TOO_MANY_REQUESTS = 429;
20
+ const CLOSING_EVENTS = new Map([
21
+ ["end", "ended"],
22
+ ["not_deployed", "not-deployed"],
23
+ ]);
24
+ function sseFrame(frame) {
25
+ if (frame.kind === "line") {
26
+ return `event: line\nid: ${frame.cursor}\ndata: ${JSON.stringify(frame.line)}\n\n`;
27
+ }
28
+ const retry = frame.retryMs === undefined ? "" : `retry: ${frame.retryMs}\n`;
29
+ const data = { status: frame.status, retryMs: frame.retryMs ?? null };
30
+ return `event: status\n${retry}data: ${JSON.stringify(data)}\n\n`;
31
+ }
32
+ function busyFrame(retryAfterS) {
33
+ return {
34
+ kind: "status",
35
+ status: "busy",
36
+ retryMs: retryAfterS === undefined
37
+ ? BUSY_RETRY_MS
38
+ : Math.min(retryAfterS * MS_PER_SECOND, MAX_BUSY_RETRY_MS),
39
+ };
40
+ }
41
+ async function isSleeping(relay) {
42
+ const health = await (0, cloud_1.readCloud)(relay.connection, (api) => api.environments.health(relay.projectId, relay.environmentId));
43
+ if (health.kind !== "ok")
44
+ return false;
45
+ const service = health.value.services.find(({ serviceId }) => serviceId === relay.serviceId);
46
+ return service?.runtime?.phase === "sleeping";
47
+ }
48
+ async function forward(events, write) {
49
+ for await (const event of events) {
50
+ const closing = CLOSING_EVENTS.get(event.event);
51
+ if (closing)
52
+ return { kind: "status", status: closing };
53
+ if (event.event === "error")
54
+ return null;
55
+ const line = logLineSchema.safeParse(event.data);
56
+ if (event.event === "log" && line.success && event.id !== undefined) {
57
+ write({ kind: "line", cursor: event.id, line: line.data });
58
+ }
59
+ }
60
+ return null;
61
+ }
62
+ /**
63
+ * `write`, plus a `live` status before the first line a sleeping service
64
+ * prints at or after `since`: the lines it printed before still arrive while
65
+ * it sleeps, and a newer one means it woke.
66
+ */
67
+ function wakingWrite(opened, since, write) {
68
+ let sleeping = opened.kind === "status" && opened.status === "sleeping";
69
+ return (frame) => {
70
+ if (sleeping &&
71
+ frame.kind === "line" &&
72
+ Date.parse(frame.line.at) >= since) {
73
+ sleeping = false;
74
+ write({ kind: "status", status: "live" });
75
+ }
76
+ write(frame);
77
+ };
78
+ }
79
+ async function streamLogs(api, relay, opened, write) {
80
+ try {
81
+ return await forward(api.logs(relay.serviceId, {
82
+ follow: true,
83
+ lastEventId: relay.after,
84
+ onOpen: () => write(opened),
85
+ }), write);
86
+ }
87
+ catch (error) {
88
+ if (error instanceof cloud_sdk_1.CloudApiError &&
89
+ error.status === HTTP_TOO_MANY_REQUESTS) {
90
+ return busyFrame(error.retryAfterS);
91
+ }
92
+ throw error;
93
+ }
94
+ }
95
+ const READ_ENDS = {
96
+ revoked: { kind: "status", status: "refused" },
97
+ missing: { kind: "status", status: "not-deployed" },
98
+ forbidden: { kind: "status", status: "refused" },
99
+ unreachable: null,
100
+ };
101
+ /**
102
+ * Streams one service's logs to `out` as {@link LogFrame}s, after the cursor
103
+ * the browser sent: the Cloud cursor passes through as each line's SSE id,
104
+ * and back to the Cloud as `Last-Event-ID`.
105
+ * It sends `live` (or `sleeping`, when every replica is scaled to zero) once
106
+ * the Cloud accepts the read, then the lines, then ends `out`: after a
107
+ * closing status, or with none when the stream dropped, which the browser
108
+ * reads as a cue to reconnect. The browser leaving aborts the Cloud read.
109
+ * Never throws.
110
+ */
111
+ async function relayLogs(relay) {
112
+ const { out, closed } = relay;
113
+ const write = (frame) => {
114
+ if (!closed.aborted)
115
+ out.write(sseFrame(frame));
116
+ };
117
+ const keepalive = setInterval(() => {
118
+ if (!closed.aborted)
119
+ out.write(": keep-alive\n\n");
120
+ }, KEEPALIVE_MS);
121
+ try {
122
+ const since = Date.now();
123
+ const opened = {
124
+ kind: "status",
125
+ status: (await isSleeping(relay)) ? "sleeping" : "live",
126
+ };
127
+ const relayed = wakingWrite(opened, since, write);
128
+ const read = await (0, cloud_1.readCloud)(relay.connection, (api) => streamLogs(api, relay, opened, relayed), { signal: closed });
129
+ const end = read.kind === "ok" ? read.value : READ_ENDS[read.kind];
130
+ if (end)
131
+ write(end);
132
+ }
133
+ finally {
134
+ clearInterval(keepalive);
135
+ out.end();
136
+ }
137
+ }
138
+ //# sourceMappingURL=relay.js.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A lookup table written as `{ __proto__: null, ... }`. A computed read answers only the
3
+ * table's own keys, never a key inherited from `Object.prototype` such as `constructor`.
4
+ */
5
+ export type NullPrototype<T> = T & {
6
+ readonly __proto__: null;
7
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=null-prototype.js.map