zephyr-agent 0.0.0-canary-20241116123955

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 (151) hide show
  1. package/LICENSE +39 -0
  2. package/README.md +1 -0
  3. package/dist/index.d.ts +20 -0
  4. package/dist/index.js +45 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/lib/actions/index.d.ts +5 -0
  7. package/dist/lib/actions/index.js +14 -0
  8. package/dist/lib/actions/index.js.map +1 -0
  9. package/dist/lib/actions/ze-enable-snapshot-on-edge.d.ts +8 -0
  10. package/dist/lib/actions/ze-enable-snapshot-on-edge.js +32 -0
  11. package/dist/lib/actions/ze-enable-snapshot-on-edge.js.map +1 -0
  12. package/dist/lib/actions/ze-enable-snapshot-on-pages.d.ts +10 -0
  13. package/dist/lib/actions/ze-enable-snapshot-on-pages.js +32 -0
  14. package/dist/lib/actions/ze-enable-snapshot-on-pages.js.map +1 -0
  15. package/dist/lib/actions/ze-upload-assets.d.ts +2 -0
  16. package/dist/lib/actions/ze-upload-assets.js +62 -0
  17. package/dist/lib/actions/ze-upload-assets.js.map +1 -0
  18. package/dist/lib/actions/ze-upload-build-stats.d.ts +3 -0
  19. package/dist/lib/actions/ze-upload-build-stats.js +32 -0
  20. package/dist/lib/actions/ze-upload-build-stats.js.map +1 -0
  21. package/dist/lib/actions/ze-upload-snapshot.d.ts +6 -0
  22. package/dist/lib/actions/ze-upload-snapshot.js +34 -0
  23. package/dist/lib/actions/ze-upload-snapshot.js.map +1 -0
  24. package/dist/lib/application-configuration/get-application-configuration.d.ts +14 -0
  25. package/dist/lib/application-configuration/get-application-configuration.js +83 -0
  26. package/dist/lib/application-configuration/get-application-configuration.js.map +1 -0
  27. package/dist/lib/auth/login.d.ts +14 -0
  28. package/dist/lib/auth/login.js +124 -0
  29. package/dist/lib/auth/login.js.map +1 -0
  30. package/dist/lib/auth/websocket.d.ts +12 -0
  31. package/dist/lib/auth/websocket.js +9 -0
  32. package/dist/lib/auth/websocket.js.map +1 -0
  33. package/dist/lib/constants/netlify.constants.d.ts +2 -0
  34. package/dist/lib/constants/netlify.constants.js +6 -0
  35. package/dist/lib/constants/netlify.constants.js.map +1 -0
  36. package/dist/lib/context-utils/ze-util-get-git-info.d.ts +7 -0
  37. package/dist/lib/context-utils/ze-util-get-git-info.js +100 -0
  38. package/dist/lib/context-utils/ze-util-get-git-info.js.map +1 -0
  39. package/dist/lib/context-utils/ze-util-read-package-json.d.ts +7 -0
  40. package/dist/lib/context-utils/ze-util-read-package-json.js +58 -0
  41. package/dist/lib/context-utils/ze-util-read-package-json.js.map +1 -0
  42. package/dist/lib/custom-errors/configuration-error.d.ts +3 -0
  43. package/dist/lib/custom-errors/configuration-error.js +18 -0
  44. package/dist/lib/custom-errors/configuration-error.js.map +1 -0
  45. package/dist/lib/custom-errors/could-not-get-build-id.d.ts +4 -0
  46. package/dist/lib/custom-errors/could-not-get-build-id.js +15 -0
  47. package/dist/lib/custom-errors/could-not-get-build-id.js.map +1 -0
  48. package/dist/lib/custom-errors/index.d.ts +5 -0
  49. package/dist/lib/custom-errors/index.js +14 -0
  50. package/dist/lib/custom-errors/index.js.map +1 -0
  51. package/dist/lib/custom-errors/package-json-not-found-error.d.ts +4 -0
  52. package/dist/lib/custom-errors/package-json-not-found-error.js +11 -0
  53. package/dist/lib/custom-errors/package-json-not-found-error.js.map +1 -0
  54. package/dist/lib/custom-errors/package-json-not-valid-error.d.ts +4 -0
  55. package/dist/lib/custom-errors/package-json-not-valid-error.js +11 -0
  56. package/dist/lib/custom-errors/package-json-not-valid-error.js.map +1 -0
  57. package/dist/lib/custom-errors/package-not-a-json-error.d.ts +4 -0
  58. package/dist/lib/custom-errors/package-not-a-json-error.js +11 -0
  59. package/dist/lib/custom-errors/package-not-a-json-error.js.map +1 -0
  60. package/dist/lib/custom-errors/snapshot-uploads.d.ts +7 -0
  61. package/dist/lib/custom-errors/snapshot-uploads.js +19 -0
  62. package/dist/lib/custom-errors/snapshot-uploads.js.map +1 -0
  63. package/dist/lib/dvcs/distributed-hash-control.d.ts +5 -0
  64. package/dist/lib/dvcs/distributed-hash-control.js +27 -0
  65. package/dist/lib/dvcs/distributed-hash-control.js.map +1 -0
  66. package/dist/lib/dvcs/get-cache-key.d.ts +1 -0
  67. package/dist/lib/dvcs/get-cache-key.js +14 -0
  68. package/dist/lib/dvcs/get-cache-key.js.map +1 -0
  69. package/dist/lib/dvcs/get-missing-assets.d.ts +9 -0
  70. package/dist/lib/dvcs/get-missing-assets.js +10 -0
  71. package/dist/lib/dvcs/get-missing-assets.js.map +1 -0
  72. package/dist/lib/hacks/resolve-index-html.d.ts +2 -0
  73. package/dist/lib/hacks/resolve-index-html.js +22 -0
  74. package/dist/lib/hacks/resolve-index-html.js.map +1 -0
  75. package/dist/lib/payload-builders/index.d.ts +3 -0
  76. package/dist/lib/payload-builders/index.js +7 -0
  77. package/dist/lib/payload-builders/index.js.map +1 -0
  78. package/dist/lib/payload-builders/ze-build-assets-map.d.ts +11 -0
  79. package/dist/lib/payload-builders/ze-build-assets-map.js +55 -0
  80. package/dist/lib/payload-builders/ze-build-assets-map.js.map +1 -0
  81. package/dist/lib/payload-builders/ze-build-snapshot.d.ts +7 -0
  82. package/dist/lib/payload-builders/ze-build-snapshot.js +39 -0
  83. package/dist/lib/payload-builders/ze-build-snapshot.js.map +1 -0
  84. package/dist/lib/payload-builders/ze-get-dash-data.d.ts +38 -0
  85. package/dist/lib/payload-builders/ze-get-dash-data.js +31 -0
  86. package/dist/lib/payload-builders/ze-get-dash-data.js.map +1 -0
  87. package/dist/lib/remote-logs/ze-log-event.d.ts +12 -0
  88. package/dist/lib/remote-logs/ze-log-event.js +87 -0
  89. package/dist/lib/remote-logs/ze-log-event.js.map +1 -0
  90. package/dist/lib/sync-utils/get-ze-build-asset.d.ts +6 -0
  91. package/dist/lib/sync-utils/get-ze-build-asset.js +21 -0
  92. package/dist/lib/sync-utils/get-ze-build-asset.js.map +1 -0
  93. package/dist/lib/upload/interfaces.d.ts +4 -0
  94. package/dist/lib/upload/interfaces.js +3 -0
  95. package/dist/lib/upload/interfaces.js.map +1 -0
  96. package/dist/lib/upload/strategies/cloudflare/enable-pages.d.ts +2 -0
  97. package/dist/lib/upload/strategies/cloudflare/enable-pages.js +13 -0
  98. package/dist/lib/upload/strategies/cloudflare/enable-pages.js.map +1 -0
  99. package/dist/lib/upload/strategies/cloudflare/index.d.ts +2 -0
  100. package/dist/lib/upload/strategies/cloudflare/index.js +8 -0
  101. package/dist/lib/upload/strategies/cloudflare/index.js.map +1 -0
  102. package/dist/lib/upload/strategies/cloudflare/upload-assets.d.ts +9 -0
  103. package/dist/lib/upload/strategies/cloudflare/upload-assets.js +18 -0
  104. package/dist/lib/upload/strategies/cloudflare/upload-assets.js.map +1 -0
  105. package/dist/lib/upload/strategies/cloudflare/upload-build-stats-and-enable-envs.d.ts +10 -0
  106. package/dist/lib/upload/strategies/cloudflare/upload-build-stats-and-enable-envs.js +11 -0
  107. package/dist/lib/upload/strategies/cloudflare/upload-build-stats-and-enable-envs.js.map +1 -0
  108. package/dist/lib/upload/strategies/cloudflare/upload.d.ts +9 -0
  109. package/dist/lib/upload/strategies/cloudflare/upload.js +25 -0
  110. package/dist/lib/upload/strategies/cloudflare/upload.js.map +1 -0
  111. package/dist/lib/upload/strategies/cloudflare/upsert-assets-to-files.d.ts +2 -0
  112. package/dist/lib/upload/strategies/cloudflare/upsert-assets-to-files.js +34 -0
  113. package/dist/lib/upload/strategies/cloudflare/upsert-assets-to-files.js.map +1 -0
  114. package/dist/lib/upload/strategies/cloudflare.strategy.d.ts +2 -0
  115. package/dist/lib/upload/strategies/cloudflare.strategy.js +29 -0
  116. package/dist/lib/upload/strategies/cloudflare.strategy.js.map +1 -0
  117. package/dist/lib/upload/strategies/fastly.strategy.d.ts +2 -0
  118. package/dist/lib/upload/strategies/fastly.strategy.js +45 -0
  119. package/dist/lib/upload/strategies/fastly.strategy.js.map +1 -0
  120. package/dist/lib/upload/strategies/index.d.ts +3 -0
  121. package/dist/lib/upload/strategies/index.js +7 -0
  122. package/dist/lib/upload/strategies/index.js.map +1 -0
  123. package/dist/lib/upload/strategies/netlify.strategy.d.ts +2 -0
  124. package/dist/lib/upload/strategies/netlify.strategy.js +45 -0
  125. package/dist/lib/upload/strategies/netlify.strategy.js.map +1 -0
  126. package/dist/lib/upload/upload-envs.d.ts +7 -0
  127. package/dist/lib/upload/upload-envs.js +35 -0
  128. package/dist/lib/upload/upload-envs.js.map +1 -0
  129. package/dist/lib/upload/upload-file.d.ts +6 -0
  130. package/dist/lib/upload/upload-file.js +42 -0
  131. package/dist/lib/upload/upload-file.js.map +1 -0
  132. package/dist/lib/upload/upload-snapshot.d.ts +5 -0
  133. package/dist/lib/upload/upload-snapshot.js +37 -0
  134. package/dist/lib/upload/upload-snapshot.js.map +1 -0
  135. package/dist/lib/upload/upload.d.ts +16 -0
  136. package/dist/lib/upload/upload.js +35 -0
  137. package/dist/lib/upload/upload.js.map +1 -0
  138. package/dist/lib/util/promise.d.ts +16 -0
  139. package/dist/lib/util/promise.js +34 -0
  140. package/dist/lib/util/promise.js.map +1 -0
  141. package/dist/lib/util/strip-ansi.d.ts +15 -0
  142. package/dist/lib/util/strip-ansi.js +28 -0
  143. package/dist/lib/util/strip-ansi.js.map +1 -0
  144. package/dist/lib/ze-api-requests/get-application-hash-list.d.ts +7 -0
  145. package/dist/lib/ze-api-requests/get-application-hash-list.js +25 -0
  146. package/dist/lib/ze-api-requests/get-application-hash-list.js.map +1 -0
  147. package/dist/lib/ze-api-requests/get-build-id.d.ts +1 -0
  148. package/dist/lib/ze-api-requests/get-build-id.js +29 -0
  149. package/dist/lib/ze-api-requests/get-build-id.js.map +1 -0
  150. package/dist/package.json +44 -0
  151. package/package.json +44 -0
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTokenStillValid = exports.checkAuth = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const jose = tslib_1.__importStar(require("jose"));
6
+ const zephyr_edge_contract_1 = require("zephyr-edge-contract");
7
+ const ze_log_event_1 = require("../remote-logs/ze-log-event");
8
+ const promise_1 = require("../util/promise");
9
+ const websocket_1 = require("./websocket");
10
+ /**
11
+ * Check if the user is already authenticated. If not, open a browser window to authenticate. Display a message to the console.
12
+ *
13
+ * @returns The token as a string.
14
+ */
15
+ async function checkAuth() {
16
+ const secret_token = (0, zephyr_edge_contract_1.getSecretToken)();
17
+ if (secret_token) {
18
+ return secret_token;
19
+ }
20
+ const token = await (0, zephyr_edge_contract_1.getToken)();
21
+ if (token) {
22
+ // Check if the token has a valid expiration date.
23
+ if (isTokenStillValid(token, 60)) {
24
+ (0, zephyr_edge_contract_1.ze_log)('You are already logged in');
25
+ return token;
26
+ }
27
+ await (0, zephyr_edge_contract_1.removeToken)();
28
+ }
29
+ // No valid token found; initiate authentication.
30
+ const newToken = await authenticateUser();
31
+ (0, zephyr_edge_contract_1.ze_log)('You are logged in');
32
+ return newToken;
33
+ }
34
+ exports.checkAuth = checkAuth;
35
+ /**
36
+ * Decides whether the token is still valid based on its expiration time.
37
+ *
38
+ * @param token The token to check.
39
+ * @param gap In seconds
40
+ * @returns Boolean indicating if the token is still valid.
41
+ */
42
+ function isTokenStillValid(token, gap = 0) {
43
+ // Attempts to decode the token
44
+ try {
45
+ const decodedToken = jose.decodeJwt(token);
46
+ if (decodedToken.exp) {
47
+ return new Date(decodedToken.exp * 1000) > new Date(Date.now() + gap * 1000);
48
+ }
49
+ // No expiration date found, invalid token.
50
+ return false;
51
+ }
52
+ catch (_a) {
53
+ // If the token is invalid, return false.
54
+ return false;
55
+ }
56
+ }
57
+ exports.isTokenStillValid = isTokenStillValid;
58
+ /** Opens the given URL in the default browser. */
59
+ async function openUrl(url) {
60
+ // Lazy loads `open` module
61
+ const openModule = (await eval(`import('open')`));
62
+ await openModule.default(url);
63
+ }
64
+ /** Generates a URL-safe random string to use as a session key. */
65
+ function generateSessionKey() {
66
+ return encodeURIComponent(Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15));
67
+ }
68
+ /** Tries to log in the user and get back the websocket reply containing the access token. */
69
+ async function getPersonalAccessTokenFromWebsocket() {
70
+ const sessionKey = generateSessionKey();
71
+ // Attempts to open the browser to authenticate the user.
72
+ const authUrl = await getAuthenticationURL(sessionKey);
73
+ try {
74
+ await openUrl(authUrl);
75
+ (0, ze_log_event_1.logFn)('debug', 'Opening browser for authentication...');
76
+ }
77
+ catch (error) {
78
+ (0, zephyr_edge_contract_1.ze_log)(error);
79
+ (0, ze_log_event_1.logFn)('debug', `Could not open browser to authenticate with ZephyrCloud. Please open the link below to authenticate:\n\n${(0, zephyr_edge_contract_1.white)(authUrl)}\n`);
80
+ }
81
+ return await waitForAccessToken(sessionKey);
82
+ }
83
+ /** Generates the URL to authenticate the user. */
84
+ async function getAuthenticationURL(state) {
85
+ const [ok, cause, data] = await zephyr_edge_contract_1.ZeHttpRequest.from({
86
+ path: zephyr_edge_contract_1.ze_api_gateway.auth_link,
87
+ base: (0, zephyr_edge_contract_1.ZE_API_ENDPOINT)(),
88
+ query: { state },
89
+ });
90
+ if (!ok) {
91
+ throw new zephyr_edge_contract_1.ZephyrError(zephyr_edge_contract_1.ZeErrors.ERR_AUTH_ERROR, { cause, message: 'Could not get authentication URL' });
92
+ }
93
+ return data;
94
+ }
95
+ /**
96
+ * Initiates user authentication and handles token storage.
97
+ *
98
+ * @returns The new token as a string.
99
+ */
100
+ async function authenticateUser() {
101
+ const token = await getPersonalAccessTokenFromWebsocket();
102
+ await (0, zephyr_edge_contract_1.saveToken)(token);
103
+ return token;
104
+ }
105
+ /** Waits for the access token to be received from the websocket. */
106
+ async function waitForAccessToken(sessionKey) {
107
+ const { promise, resolve, reject } = (0, promise_1.PromiseWithResolvers)();
108
+ const socket = (0, websocket_1.createSocket)((0, zephyr_edge_contract_1.ZEPHYR_API_ENDPOINT)());
109
+ try {
110
+ socket.once('access-token', resolve);
111
+ // Creating errors outside of the listener closure makes the stack trace point
112
+ // to waitForAccessToken fn instead of socket.io internals event emitter code.
113
+ socket.once('access-token-error', (cause) => reject(new zephyr_edge_contract_1.ZephyrError(zephyr_edge_contract_1.ZeErrors.ERR_AUTH_ERROR, { cause, message: 'Error getting access token' })));
114
+ socket.once('connect_error', (cause) => reject(new zephyr_edge_contract_1.ZephyrError(zephyr_edge_contract_1.ZeErrors.ERR_AUTH_ERROR, { message: 'Could not connect to socket.', cause })));
115
+ socket.emit('joinAccessTokenRoom', { state: sessionKey });
116
+ // The user has 60 seconds to log in through the browser.
117
+ setTimeout(reject, 60000, new zephyr_edge_contract_1.ZephyrError(zephyr_edge_contract_1.ZeErrors.ERR_AUTH_ERROR, { message: "Couldn't receive access token in 1 minute." }));
118
+ return await promise;
119
+ }
120
+ finally {
121
+ socket.close();
122
+ }
123
+ }
124
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/lib/auth/login.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,+DAa8B;AAC9B,8DAAoD;AACpD,6CAAuD;AACvD,2CAA2C;AAE3C;;;;GAIG;AACI,KAAK,UAAU,SAAS;IAC7B,MAAM,YAAY,GAAG,IAAA,qCAAc,GAAE,CAAC;IAEtC,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,IAAA,+BAAQ,GAAE,CAAC;IAE/B,IAAI,KAAK,EAAE,CAAC;QACV,kDAAkD;QAClD,IAAI,iBAAiB,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC;YACjC,IAAA,6BAAM,EAAC,2BAA2B,CAAC,CAAC;YACpC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,IAAA,kCAAW,GAAE,CAAC;IACtB,CAAC;IAED,iDAAiD;IACjD,MAAM,QAAQ,GAAG,MAAM,gBAAgB,EAAE,CAAC;IA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Y,EAAC,IAAA,0CAAmB,GAAE,CAAC,CAAC;IAEnD,IAAI,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QACrC,8EAA8E;QAC9E,8EAA8E;QAC9E,MAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE,CAC1C,MAAM,CAAC,IAAI,kCAAW,CAAC,+BAAQ,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC,CAAC,CACnG,CAAC;QACF,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE,CACrC,MAAM,CAAC,IAAI,kCAAW,CAAC,+BAAQ,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,8BAA8B,EAAE,KAAK,EAAE,CAAC,CAAC,CACrG,CAAC;QAEF,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;QAE1D,yDAAyD;QACzD,UAAU,CAAC,MAAM,EAAE,KAAM,EAAE,IAAI,kCAAW,CAAC,+BAAQ,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,4CAA4C,EAAE,CAAC,CAAC,CAAC;QAEhI,OAAO,MAAM,OAAO,CAAC;IACvB,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { type Socket } from 'socket.io-client';
2
+ interface ClientToServerEvents {
3
+ joinAccessTokenRoom: (props: {
4
+ state: string;
5
+ }) => void;
6
+ }
7
+ interface ServerToClientEvents {
8
+ 'access-token': (token: string) => void;
9
+ 'access-token-error': (msg: string) => void;
10
+ }
11
+ export declare function createSocket(endpoint: string): Socket<ServerToClientEvents, ClientToServerEvents>;
12
+ export {};
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSocket = void 0;
4
+ const socket_io_client_1 = require("socket.io-client");
5
+ function createSocket(endpoint) {
6
+ return (0, socket_io_client_1.io)(endpoint);
7
+ }
8
+ exports.createSocket = createSocket;
9
+ //# sourceMappingURL=websocket.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/lib/auth/websocket.ts"],"names":[],"mappings":";;;AAAA,uDAA+D;AAW/D,SAAgB,YAAY,CAAC,QAAgB;IAC3C,OAAO,IAAA,qBAAQ,EAAC,QAAQ,CAAC,CAAC;AAC5B,CAAC;AAFD,oCAEC"}
@@ -0,0 +1,2 @@
1
+ export declare const netlify_api_url = "https://api.netlify.com/api/v1";
2
+ export declare const jwt_secret_key = "JWT_SECRET";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.jwt_secret_key = exports.netlify_api_url = void 0;
4
+ exports.netlify_api_url = 'https://api.netlify.com/api/v1';
5
+ exports.jwt_secret_key = 'JWT_SECRET';
6
+ //# sourceMappingURL=netlify.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"netlify.constants.js","sourceRoot":"","sources":["../../../src/lib/constants/netlify.constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,gCAAgC,CAAC;AACnD,QAAA,cAAc,GAAG,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type ZephyrPluginOptions } from 'zephyr-edge-contract';
2
+ export interface GitInfo {
3
+ app: Pick<ZephyrPluginOptions['app'], 'org' | 'project'>;
4
+ git: ZephyrPluginOptions['git'];
5
+ }
6
+ /** Loads the git information from the current repository. */
7
+ export declare function getGitInfo(): Promise<GitInfo>;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getGitInfo = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const git_url_parse_1 = tslib_1.__importDefault(require("git-url-parse"));
6
+ const is_ci_1 = tslib_1.__importDefault(require("is-ci"));
7
+ const node_child_process_1 = tslib_1.__importDefault(require("node:child_process"));
8
+ const node_crypto_1 = require("node:crypto");
9
+ const node_util_1 = require("node:util");
10
+ const zephyr_edge_contract_1 = require("zephyr-edge-contract");
11
+ const exec = (0, node_util_1.promisify)(node_child_process_1.default.exec);
12
+ /** Loads the git information from the current repository. */
13
+ async function getGitInfo() {
14
+ const hasToken = (0, zephyr_edge_contract_1.hasSecretToken)();
15
+ const { name, email, remoteOrigin, branch, commit, stdout } = await loadGitInfo(hasToken);
16
+ if (!hasToken && (!name || !email)) {
17
+ throw new zephyr_edge_contract_1.ZephyrError(zephyr_edge_contract_1.ZeErrors.ERR_NO_GIT_USERNAME_EMAIL, {
18
+ data: { stdout },
19
+ });
20
+ }
21
+ const app = parseGitUrl(remoteOrigin, stdout);
22
+ const gitInfo = {
23
+ git: { name, email, branch, commit },
24
+ app,
25
+ };
26
+ (0, zephyr_edge_contract_1.ze_log)('Git Info Loaded', gitInfo);
27
+ return gitInfo;
28
+ }
29
+ exports.getGitInfo = getGitInfo;
30
+ /** Loads all data in a single command to avoid multiple executions. */
31
+ async function loadGitInfo(hasSecretToken) {
32
+ const automated = is_ci_1.default || hasSecretToken;
33
+ // ensures multi line output on errors doesn't break the parsing
34
+ const delimiter = (0, node_crypto_1.randomUUID)().repeat(2);
35
+ const command = [
36
+ // Inside CI environments, the last committer should be the actor
37
+ // and not the actual logged git user which sometimes might just be a bot
38
+ automated ? "git log -1 --pretty=format:'%an'" : 'git config user.name',
39
+ automated ? "git log -1 --pretty=format:'%ae'" : 'git config user.email',
40
+ // TODO: support remote names that are not 'origin'
41
+ 'git config --get remote.origin.url',
42
+ 'git rev-parse --abbrev-ref HEAD',
43
+ 'git rev-parse HEAD',
44
+ ].join(` && echo ${delimiter} && `);
45
+ try {
46
+ const { stdout } = await exec(command);
47
+ const [name, email, remoteOrigin, branch, commit] = stdout
48
+ .trim()
49
+ .split(delimiter)
50
+ .map((x) => x.trim());
51
+ return {
52
+ name,
53
+ email,
54
+ remoteOrigin,
55
+ branch,
56
+ commit,
57
+ stdout,
58
+ };
59
+ }
60
+ catch (cause) {
61
+ throw new zephyr_edge_contract_1.ZephyrError(zephyr_edge_contract_1.ZeErrors.ERR_NO_GIT_INFO, {
62
+ cause,
63
+ data: { command, delimiter },
64
+ message: cause.stderr || cause.message,
65
+ });
66
+ }
67
+ }
68
+ /**
69
+ * Parses the git url using the `git-url-parse` package.
70
+ *
71
+ * This package differentiate CI providers and handle a lot of small utilities for getting git info from `azure`, `aws` etc
72
+ */
73
+ function parseGitUrl(remoteOrigin, stdout) {
74
+ if (!remoteOrigin) {
75
+ throw new zephyr_edge_contract_1.ZephyrError(zephyr_edge_contract_1.ZeErrors.ERR_GIT_REMOTE_ORIGIN, {
76
+ data: { stdout },
77
+ });
78
+ }
79
+ let parsed;
80
+ try {
81
+ parsed = (0, git_url_parse_1.default)(remoteOrigin);
82
+ }
83
+ catch (cause) {
84
+ throw new zephyr_edge_contract_1.ZephyrError(zephyr_edge_contract_1.ZeErrors.ERR_NO_GIT_INFO, {
85
+ message: stdout,
86
+ cause,
87
+ data: { stdout },
88
+ });
89
+ }
90
+ if (!parsed.owner || !parsed.name) {
91
+ throw new zephyr_edge_contract_1.ZephyrError(zephyr_edge_contract_1.ZeErrors.ERR_GIT_REMOTE_ORIGIN, {
92
+ data: { stdout },
93
+ });
94
+ }
95
+ return {
96
+ org: parsed.owner.toLocaleLowerCase(),
97
+ project: parsed.name.toLocaleLowerCase(),
98
+ };
99
+ }
100
+ //# sourceMappingURL=ze-util-get-git-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ze-util-get-git-info.js","sourceRoot":"","sources":["../../../src/lib/context-utils/ze-util-get-git-info.ts"],"names":[],"mappings":";;;;AAAA,0EAAwC;AACxC,0DAAyB;AACzB,oFAAoC;AACpC,6CAAyC;AACzC,yCAAsC;AACtC,+DAA+G;AAE/G,MAAM,IAAI,GA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AAC,MAAM,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAClC,MAAM,IAAI,kCAAW,CAAC,+BAAQ,CAAC,qBAAqB,EAAE;YACpD,IAAI,EAAE,EAAE,MAAM,EAAE;SACjB,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,iBAAiB,EAAE;QACrC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE;KACzC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ interface PackageJson {
2
+ name: string;
3
+ version: string;
4
+ dependencies?: Record<string, string>;
5
+ }
6
+ export declare function getPackageJson(context: string | undefined): Promise<PackageJson>;
7
+ export {};
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPackageJson = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs = tslib_1.__importStar(require("node:fs"));
6
+ const node_util_1 = require("node:util");
7
+ const node_path_1 = require("node:path");
8
+ const zephyr_edge_contract_1 = require("zephyr-edge-contract");
9
+ const package_json_not_found_error_1 = require("../custom-errors/package-json-not-found-error");
10
+ const package_not_a_json_error_1 = require("../custom-errors/package-not-a-json-error");
11
+ const package_json_not_valid_error_1 = require("../custom-errors/package-json-not-valid-error");
12
+ const exists = (0, node_util_1.promisify)(fs.exists);
13
+ const readFile = (0, node_util_1.promisify)(fs.readFile);
14
+ const cache_prefix = 'package_json';
15
+ async function getPackageJson(context) {
16
+ let startingPath = context || process.cwd();
17
+ if (fs.statSync(startingPath).isFile()) {
18
+ startingPath = (0, node_path_1.resolve)(startingPath, '..');
19
+ }
20
+ const cache_key = `${cache_prefix}:${startingPath}`;
21
+ const cached = await zephyr_edge_contract_1._fs_cache.getCache(cache_key);
22
+ if (cached)
23
+ return JSON.parse(cached);
24
+ const res = await findClosestPackageJson(startingPath);
25
+ if (!res) {
26
+ throw new package_json_not_found_error_1.PackageJsonNotFoundError(context);
27
+ }
28
+ const { json, path } = res;
29
+ const parsed_package_json = (0, zephyr_edge_contract_1.safe_json_parse)(json);
30
+ if (!parsed_package_json) {
31
+ throw new package_not_a_json_error_1.PackageNotAJsonError(path);
32
+ }
33
+ if (!parsed_package_json.name || !parsed_package_json.version) {
34
+ throw new package_json_not_valid_error_1.PackageJsonNotValidError(path);
35
+ }
36
+ (0, zephyr_edge_contract_1.ze_log)('package json found', parsed_package_json);
37
+ await zephyr_edge_contract_1._fs_cache.saveCache(cache_key, JSON.stringify(parsed_package_json));
38
+ return parsed_package_json;
39
+ }
40
+ exports.getPackageJson = getPackageJson;
41
+ async function findClosestPackageJson(startPath) {
42
+ let dir = startPath;
43
+ do {
44
+ const packageJsonPath = (0, node_path_1.join)(dir, 'package.json');
45
+ if (await exists(packageJsonPath)) {
46
+ return {
47
+ path: packageJsonPath,
48
+ json: await readFile(packageJsonPath, 'utf8'),
49
+ };
50
+ }
51
+ const parentDir = (0, node_path_1.resolve)(dir, '..');
52
+ if (parentDir === dir) {
53
+ throw new package_json_not_found_error_1.PackageJsonNotFoundError(`${startPath}`);
54
+ }
55
+ dir = parentDir;
56
+ } while (startPath !== dir);
57
+ }
58
+ //# sourceMappingURL=ze-util-read-package-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ze-util-read-package-json.js","sourceRoot":"","sources":["../../../src/lib/context-utils/ze-util-read-package-json.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAC9B,yCAAsC;AACtC,yCAA0C;AAC1C,+DAA0E;AAG1E,gGAAyF;AACzF,wFAAiF;AACjF,gGAAyF;AAEzF,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,EAAE,CAAC,MAAM,CAAC,CAAC;AACpC,MAAM,QAAQ,GAAG,IAAA,qBAAS,EAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;AACxC,MAAM,YAAY,GAAG,cAAc,CAAC;AAQ7B,KAAK,UAAU,cAAc,CAAC,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IACrD,IAAI,GAAG,GAAG,SAAS,CAAC;IACpB,GAAG,CAAC;QACF,MAAM,eAAe,GAAG,IAAA,gBAAI,EAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QAClD,IAAI,MAAM,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC;YAClC,OAAO;gBACL,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,MAAM,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;aAC9C,CAAC;QACJ,CAAC;QAED,MAAM,SAAS,GAAG,IAAA,mBAAO,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACrC,IAAI,SAAS,KAAK,GAAG,EAAE,CAAC;YACtB,MAAM,IAAI,uDAAwB,CAAC,GAAG,SAAS,EAAE,CAAC,CAAC;QACrD,CAAC;QACD,GAAG,GAAG,SAAS,CAAC;IAClB,CAAC,QAAQ,SAAS,KAAK,GAAG,EAAE;AAC9B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare class ConfigurationError extends Error {
2
+ constructor(code: string, message: string, level?: 'normal' | 'critical');
3
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConfigurationError = void 0;
4
+ const zephyr_edge_contract_1 = require("zephyr-edge-contract");
5
+ class ConfigurationError extends Error {
6
+ // link to wherever documentation is
7
+ // docs usually locate at this address
8
+ constructor(code, message, level) {
9
+ super(`${zephyr_edge_contract_1.brightRedBgName} ${level === 'critical' ? `Critical error` : `Error`} [${code}]: ${message} \n ${code ? `See documentation on how to debug this error: https://docs.zephyr-cloud.io/errors/${code.toLowerCase()}` : ''}`);
10
+ this.name = 'ConfigurationError';
11
+ // looks weird right? but vite build logger prints only stack trace,
12
+ // so this is how we ended up with this.
13
+ this._stack = this.stack;
14
+ this.stack = this.message;
15
+ }
16
+ }
17
+ exports.ConfigurationError = ConfigurationError;
18
+ //# sourceMappingURL=configuration-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration-error.js","sourceRoot":"","sources":["../../../src/lib/custom-errors/configuration-error.ts"],"names":[],"mappings":";;;AAAA,+DAAuD;AAEvD,MAAa,kBAAmB,SAAQ,KAAK;IAC3C,qCAAqC;IACrC,sCAAsC;IACtC,YAAY,IAAY,EAAE,OAAe,EAAE,KAA6B;QACtE,KAAK,CACH,GAAG,sCAAe,IAAI,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO,KAAK,IAAI,MAAM,OAAO,OAAO,IAAI,CAAC,CAAC,CAAC,qFAAqF,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAC5N,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,oEAAoE;QACpE,wCAAwC;QACvC,IAA4B,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;QAClD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC;IAC5B,CAAC;CACF;AAbD,gDAaC"}
@@ -0,0 +1,4 @@
1
+ import { ConfigurationError } from './configuration-error';
2
+ export declare class CouldNotGetBuildIdError extends ConfigurationError {
3
+ constructor();
4
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CouldNotGetBuildIdError = void 0;
4
+ const configuration_error_1 = require("./configuration-error");
5
+ const noBuildIdErrMsg = `Could not get build id. Please make sure you have:
6
+ - a Zephyr account registered on https://app.zephyr-cloud.io
7
+ - git remote origin url is configured
8
+ - this repository has commit history`.trim();
9
+ class CouldNotGetBuildIdError extends configuration_error_1.ConfigurationError {
10
+ constructor() {
11
+ super(`ZE10019`, noBuildIdErrMsg);
12
+ }
13
+ }
14
+ exports.CouldNotGetBuildIdError = CouldNotGetBuildIdError;
15
+ //# sourceMappingURL=could-not-get-build-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"could-not-get-build-id.js","sourceRoot":"","sources":["../../../src/lib/custom-errors/could-not-get-build-id.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAE3D,MAAM,eAAe,GAAG;;;qCAGa,CAAC,IAAI,EAAE,CAAC;AAE7C,MAAa,uBAAwB,SAAQ,wCAAkB;IAC7D;QACE,KAAK,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;IACpC,CAAC;CACF;AAJD,0DAIC"}
@@ -0,0 +1,5 @@
1
+ export { ConfigurationError } from './configuration-error';
2
+ export { CouldNotGetBuildIdError } from './could-not-get-build-id';
3
+ export { PackageJsonNotFoundError } from './package-json-not-found-error';
4
+ export { PackageJsonNotValidError } from './package-json-not-valid-error';
5
+ export { PackageNotAJsonError } from './package-not-a-json-error';
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PackageNotAJsonError = exports.PackageJsonNotValidError = exports.PackageJsonNotFoundError = exports.CouldNotGetBuildIdError = exports.ConfigurationError = void 0;
4
+ var configuration_error_1 = require("./configuration-error");
5
+ Object.defineProperty(exports, "ConfigurationError", { enumerable: true, get: function () { return configuration_error_1.ConfigurationError; } });
6
+ var could_not_get_build_id_1 = require("./could-not-get-build-id");
7
+ Object.defineProperty(exports, "CouldNotGetBuildIdError", { enumerable: true, get: function () { return could_not_get_build_id_1.CouldNotGetBuildIdError; } });
8
+ var package_json_not_found_error_1 = require("./package-json-not-found-error");
9
+ Object.defineProperty(exports, "PackageJsonNotFoundError", { enumerable: true, get: function () { return package_json_not_found_error_1.PackageJsonNotFoundError; } });
10
+ var package_json_not_valid_error_1 = require("./package-json-not-valid-error");
11
+ Object.defineProperty(exports, "PackageJsonNotValidError", { enumerable: true, get: function () { return package_json_not_valid_error_1.PackageJsonNotValidError; } });
12
+ var package_not_a_json_error_1 = require("./package-not-a-json-error");
13
+ Object.defineProperty(exports, "PackageNotAJsonError", { enumerable: true, get: function () { return package_not_a_json_error_1.PackageNotAJsonError; } });
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/custom-errors/index.ts"],"names":[],"mappings":";;;AAAA,6DAA2D;AAAlD,yHAAA,kBAAkB,OAAA;AAC3B,mEAAmE;AAA1D,iIAAA,uBAAuB,OAAA;AAChC,+EAA0E;AAAjE,wIAAA,wBAAwB,OAAA;AACjC,+EAA0E;AAAjE,wIAAA,wBAAwB,OAAA;AACjC,uEAAkE;AAAzD,gIAAA,oBAAoB,OAAA"}
@@ -0,0 +1,4 @@
1
+ import { ConfigurationError } from './configuration-error';
2
+ export declare class PackageJsonNotFoundError extends ConfigurationError {
3
+ constructor(context: string | undefined);
4
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PackageJsonNotFoundError = void 0;
4
+ const configuration_error_1 = require("./configuration-error");
5
+ class PackageJsonNotFoundError extends configuration_error_1.ConfigurationError {
6
+ constructor(context) {
7
+ super(`ZE10010`, `package.json not found from '${context}'`);
8
+ }
9
+ }
10
+ exports.PackageJsonNotFoundError = PackageJsonNotFoundError;
11
+ //# sourceMappingURL=package-json-not-found-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-json-not-found-error.js","sourceRoot":"","sources":["../../../src/lib/custom-errors/package-json-not-found-error.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAE3D,MAAa,wBAAyB,SAAQ,wCAAkB;IAC9D,YAAY,OAA2B;QACrC,KAAK,CAAC,SAAS,EAAE,gCAAgC,OAAO,GAAG,CAAC,CAAC;IAC/D,CAAC;CACF;AAJD,4DAIC"}
@@ -0,0 +1,4 @@
1
+ import { ConfigurationError } from './configuration-error';
2
+ export declare class PackageJsonNotValidError extends ConfigurationError {
3
+ constructor(path: string | undefined);
4
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PackageJsonNotValidError = void 0;
4
+ const configuration_error_1 = require("./configuration-error");
5
+ class PackageJsonNotValidError extends configuration_error_1.ConfigurationError {
6
+ constructor(path) {
7
+ super(`ZE10013`, `package json in ('${path}') must have a 'name' and a 'version' properties`);
8
+ }
9
+ }
10
+ exports.PackageJsonNotValidError = PackageJsonNotValidError;
11
+ //# sourceMappingURL=package-json-not-valid-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-json-not-valid-error.js","sourceRoot":"","sources":["../../../src/lib/custom-errors/package-json-not-valid-error.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAE3D,MAAa,wBAAyB,SAAQ,wCAAkB;IAC9D,YAAY,IAAwB;QAClC,KAAK,CAAC,SAAS,EAAE,qBAAqB,IAAI,kDAAkD,CAAC,CAAC;IAChG,CAAC;CACF;AAJD,4DAIC"}
@@ -0,0 +1,4 @@
1
+ import { ConfigurationError } from './configuration-error';
2
+ export declare class PackageNotAJsonError extends ConfigurationError {
3
+ constructor(path: string | undefined);
4
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PackageNotAJsonError = void 0;
4
+ const configuration_error_1 = require("./configuration-error");
5
+ class PackageNotAJsonError extends configuration_error_1.ConfigurationError {
6
+ constructor(path) {
7
+ super(`ZE10011`, `package.json '${path}' is in valid json format.`);
8
+ }
9
+ }
10
+ exports.PackageNotAJsonError = PackageNotAJsonError;
11
+ //# sourceMappingURL=package-not-a-json-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-not-a-json-error.js","sourceRoot":"","sources":["../../../src/lib/custom-errors/package-not-a-json-error.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAE3D,MAAa,oBAAqB,SAAQ,wCAAkB;IAC1D,YAAY,IAAwB;QAClC,KAAK,CAAC,SAAS,EAAE,iBAAiB,IAAI,4BAA4B,CAAC,CAAC;IACtE,CAAC;CACF;AAJD,oDAIC"}
@@ -0,0 +1,7 @@
1
+ import { ConfigurationError } from './configuration-error';
2
+ export declare class SnapshotUploadFailureError extends ConfigurationError {
3
+ constructor();
4
+ }
5
+ export declare class SnapshotUploadNoResultError extends ConfigurationError {
6
+ constructor();
7
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SnapshotUploadNoResultError = exports.SnapshotUploadFailureError = void 0;
4
+ const configuration_error_1 = require("./configuration-error");
5
+ const snapshotUploadFailed = `Failed to upload snapshot.`.trim();
6
+ class SnapshotUploadFailureError extends configuration_error_1.ConfigurationError {
7
+ constructor() {
8
+ super(`ZE20018`, snapshotUploadFailed);
9
+ }
10
+ }
11
+ exports.SnapshotUploadFailureError = SnapshotUploadFailureError;
12
+ const snapshotUploadNoResult = `Snapshot upload gave no result, exiting...`;
13
+ class SnapshotUploadNoResultError extends configuration_error_1.ConfigurationError {
14
+ constructor() {
15
+ super(`ZE20019`, snapshotUploadNoResult);
16
+ }
17
+ }
18
+ exports.SnapshotUploadNoResultError = SnapshotUploadNoResultError;
19
+ //# sourceMappingURL=snapshot-uploads.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot-uploads.js","sourceRoot":"","sources":["../../../src/lib/custom-errors/snapshot-uploads.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAE3D,MAAM,oBAAoB,GAAG,4BAA4B,CAAC,IAAI,EAAE,CAAC;AAEjE,MAAa,0BAA2B,SAAQ,wCAAkB;IAChE;QACE,KAAK,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;IACzC,CAAC;CACF;AAJD,gEAIC;AAED,MAAM,sBAAsB,GAAG,4CAA4C,CAAC;AAE5E,MAAa,2BAA4B,SAAQ,wCAAkB;IACjE;QACE,KAAK,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;IAC3C,CAAC;CACF;AAJD,kEAIC"}
@@ -0,0 +1,5 @@
1
+ import { ZeUploadAssetsOptions } from 'zephyr-edge-contract';
2
+ export declare function get_hash_list(application_uid: string): Promise<{
3
+ hash_set: Set<string>;
4
+ }>;
5
+ export declare function update_hash_list(application_uid: string, assetsMap: ZeUploadAssetsOptions['assetsMap']): Promise<void>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.update_hash_list = exports.get_hash_list = void 0;
4
+ const zephyr_edge_contract_1 = require("zephyr-edge-contract");
5
+ const get_application_hash_list_1 = require("../ze-api-requests/get-application-hash-list");
6
+ const get_cache_key_1 = require("./get-cache-key");
7
+ async function get_hash_list(application_uid) {
8
+ const cacheKey = await (0, get_cache_key_1.getCacheKey)(application_uid);
9
+ const local_hash_list = await zephyr_edge_contract_1._hash_cache.getAppHashCache(cacheKey);
10
+ if (local_hash_list) {
11
+ return { hash_set: new Set(local_hash_list.hashes) };
12
+ }
13
+ const remote_hash_list = await (0, get_application_hash_list_1.getApplicationHashList)({ application_uid });
14
+ if (remote_hash_list) {
15
+ await zephyr_edge_contract_1._hash_cache.setAppHashCache(cacheKey, remote_hash_list);
16
+ return { hash_set: new Set(remote_hash_list.hashes) };
17
+ }
18
+ return { hash_set: new Set() };
19
+ }
20
+ exports.get_hash_list = get_hash_list;
21
+ async function update_hash_list(application_uid, assetsMap) {
22
+ const cacheKey = await (0, get_cache_key_1.getCacheKey)(application_uid);
23
+ const hashes = Object.values(assetsMap).map(({ hash }) => hash);
24
+ await zephyr_edge_contract_1._hash_cache.setAppHashCache(cacheKey, { hashes });
25
+ }
26
+ exports.update_hash_list = update_hash_list;
27
+ //# sourceMappingURL=distributed-hash-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distributed-hash-control.js","sourceRoot":"","sources":["../../../src/lib/dvcs/distributed-hash-control.ts"],"names":[],"mappings":";;;AAAA,+DAA0E;AAC1E,4FAAsF;AACtF,mDAA8C;AAEvC,KAAK,UAAU,aAAa,CAAC,eAAuB;IACzD,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAW,EAAC,eAAe,CAAC,CAAC;IACpD,MAAM,eAAe,GAAG,MAAM,kCAAW,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IACpE,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,EAAE,QAAQ,EAAE,IAAI,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;IACvD,CAAC;IACD,MAAM,gBAAgB,GAAG,MAAM,IAAA,kDAAsB,EAAC,EAAE,eAAe,EAAE,CAAC,CAAC;IAC3E,IAAI,gBAAgB,EAAE,CAAC;QACrB,MAAM,kCAAW,CAAC,eAAe,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QAC9D,OAAO,EAAE,QAAQ,EAAE,IAAI,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;IACxD,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;AACjC,CAAC;AAbD,sCAaC;AAEM,KAAK,UAAU,gBAAgB,CAAC,eAAuB,EAAE,SAA6C;IAC3G,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAW,EAAC,eAAe,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IAChE,MAAM,kCAAW,CAAC,eAAe,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AAC1D,CAAC;AAJD,4CAIC"}
@@ -0,0 +1 @@
1
+ export declare function getCacheKey(application_uid: string): Promise<string>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCacheKey = void 0;
4
+ const get_application_configuration_1 = require("../application-configuration/get-application-configuration");
5
+ async function getCacheKey(application_uid) {
6
+ var _a;
7
+ let edgeUrl = ((_a = (await (0, get_application_configuration_1.getApplicationConfiguration)({ application_uid }))) === null || _a === void 0 ? void 0 : _a.EDGE_URL) || '';
8
+ if (edgeUrl) {
9
+ edgeUrl = new URL(edgeUrl).host;
10
+ }
11
+ return `${application_uid}-${edgeUrl}`;
12
+ }
13
+ exports.getCacheKey = getCacheKey;
14
+ //# sourceMappingURL=get-cache-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-cache-key.js","sourceRoot":"","sources":["../../../src/lib/dvcs/get-cache-key.ts"],"names":[],"mappings":";;;AAAA,8GAAyG;AAElG,KAAK,UAAU,WAAW,CAAC,eAAuB;;IACvD,IAAI,OAAO,GAAG,CAAA,MAAA,CAAC,MAAM,IAAA,2DAA2B,EAAC,EAAE,eAAe,EAAE,CAAC,CAAC,0CAAE,QAAQ,KAAI,EAAE,CAAC;IACvF,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC;IAClC,CAAC;IAED,OAAO,GAAG,eAAe,IAAI,OAAO,EAAE,CAAC;AACzC,CAAC;AAPD,kCAOC"}
@@ -0,0 +1,9 @@
1
+ import { ZeBuildAssetsMap } from 'zephyr-edge-contract';
2
+ interface Params {
3
+ assetsMap: ZeBuildAssetsMap;
4
+ hash_set: {
5
+ hash_set: Set<string>;
6
+ };
7
+ }
8
+ export declare function get_missing_assets({ assetsMap, hash_set }: Params): import("zephyr-edge-contract").ZeBuildAsset[];
9
+ export {};