@vtex/api 6.48.0 → 6.48.1-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.
- package/gen/manifest.schema +2 -3
- package/lib/HttpClient/GraphQLClient.d.ts +1 -1
- package/lib/HttpClient/GraphQLClient.js +1 -0
- package/lib/HttpClient/HttpClient.d.ts +4 -3
- package/lib/HttpClient/HttpClient.js +15 -14
- package/lib/HttpClient/agents.d.ts +5 -2
- package/lib/HttpClient/agents.js +23 -4
- package/lib/HttpClient/index.js +22 -10
- package/lib/HttpClient/middlewares/cache.d.ts +1 -1
- package/lib/HttpClient/middlewares/cache.js +48 -42
- package/lib/HttpClient/middlewares/cancellationToken.d.ts +1 -1
- package/lib/HttpClient/middlewares/cancellationToken.js +3 -1
- package/lib/HttpClient/middlewares/inflight.d.ts +1 -1
- package/lib/HttpClient/middlewares/inflight.js +7 -3
- package/lib/HttpClient/middlewares/memoization.d.ts +1 -1
- package/lib/HttpClient/middlewares/memoization.js +10 -8
- package/lib/HttpClient/middlewares/metrics.js +13 -7
- package/lib/HttpClient/middlewares/notFound.d.ts +1 -1
- package/lib/HttpClient/middlewares/notFound.js +5 -2
- package/lib/HttpClient/middlewares/recorder.js +7 -1
- package/lib/HttpClient/middlewares/request/HttpAgentSingleton.js +2 -1
- package/lib/HttpClient/middlewares/request/index.d.ts +1 -1
- package/lib/HttpClient/middlewares/request/index.js +13 -9
- package/lib/HttpClient/middlewares/request/setupAxios/index.js +6 -4
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.js +7 -5
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.js +4 -3
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.js +9 -6
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.js +10 -7
- package/lib/HttpClient/middlewares/tracing.js +16 -10
- package/lib/HttpClient/typings.d.ts +3 -3
- package/lib/HttpClient/typings.js +1 -0
- package/lib/caches/DiskCache.d.ts +1 -1
- package/lib/caches/DiskCache.js +3 -2
- package/lib/caches/LRUCache.d.ts +3 -3
- package/lib/caches/LRUCache.js +1 -0
- package/lib/caches/LRUDiskCache.d.ts +2 -2
- package/lib/caches/LRUDiskCache.js +3 -2
- package/lib/caches/MultilayeredCache.d.ts +2 -2
- package/lib/caches/MultilayeredCache.js +8 -7
- package/lib/caches/index.js +20 -7
- package/lib/caches/typings.d.ts +5 -5
- package/lib/clients/IOClient.d.ts +1 -1
- package/lib/clients/IOClient.js +1 -0
- package/lib/clients/IOClients.d.ts +1 -1
- package/lib/clients/IOClients.js +1 -0
- package/lib/clients/IOGraphQLClient.js +1 -0
- package/lib/clients/apps/AppClient.js +2 -1
- package/lib/clients/apps/AppGraphQLClient.js +2 -1
- package/lib/clients/apps/Billing.d.ts +1 -1
- package/lib/clients/apps/Billing.js +1 -0
- package/lib/clients/apps/Builder.d.ts +7 -7
- package/lib/clients/apps/Builder.js +2 -1
- package/lib/clients/apps/MessagesGraphQL.d.ts +1 -1
- package/lib/clients/apps/MessagesGraphQL.js +4 -3
- package/lib/clients/apps/Settings.js +4 -3
- package/lib/clients/apps/catalogGraphQL/brand.js +1 -0
- package/lib/clients/apps/catalogGraphQL/category.js +1 -0
- package/lib/clients/apps/catalogGraphQL/index.d.ts +4 -4
- package/lib/clients/apps/catalogGraphQL/index.js +5 -4
- package/lib/clients/apps/catalogGraphQL/product.js +1 -0
- package/lib/clients/apps/catalogGraphQL/sku.js +1 -0
- package/lib/clients/apps/index.js +21 -10
- package/lib/clients/external/ExternalClient.js +1 -0
- package/lib/clients/external/ID.d.ts +4 -4
- package/lib/clients/external/ID.js +1 -0
- package/lib/clients/external/Masterdata.js +1 -0
- package/lib/clients/external/PaymentProvider.d.ts +2 -2
- package/lib/clients/external/PaymentProvider.js +1 -0
- package/lib/clients/external/index.js +18 -7
- package/lib/clients/index.js +22 -10
- package/lib/clients/infra/Apps.d.ts +32 -27
- package/lib/clients/infra/Apps.js +19 -16
- package/lib/clients/infra/Assets.d.ts +6 -5
- package/lib/clients/infra/Assets.js +12 -11
- package/lib/clients/infra/BillingMetrics.d.ts +1 -1
- package/lib/clients/infra/BillingMetrics.js +1 -0
- package/lib/clients/infra/Events.d.ts +1 -1
- package/lib/clients/infra/Events.js +2 -1
- package/lib/clients/infra/Housekeeper.d.ts +3 -3
- package/lib/clients/infra/Housekeeper.js +1 -0
- package/lib/clients/infra/InfraClient.js +1 -0
- package/lib/clients/infra/Registry.d.ts +23 -17
- package/lib/clients/infra/Registry.js +5 -3
- package/lib/clients/infra/Router.d.ts +8 -8
- package/lib/clients/infra/Router.js +1 -0
- package/lib/clients/infra/Sphinx.d.ts +2 -2
- package/lib/clients/infra/Sphinx.js +1 -0
- package/lib/clients/infra/VBase.d.ts +15 -14
- package/lib/clients/infra/VBase.js +4 -3
- package/lib/clients/infra/Workspaces.d.ts +7 -7
- package/lib/clients/infra/Workspaces.js +1 -0
- package/lib/clients/infra/index.js +25 -14
- package/lib/clients/janus/JanusClient.d.ts +1 -1
- package/lib/clients/janus/JanusClient.js +1 -0
- package/lib/clients/janus/LicenseManager.js +2 -1
- package/lib/clients/janus/Segment.d.ts +3 -3
- package/lib/clients/janus/Segment.js +3 -2
- package/lib/clients/janus/Session.d.ts +2 -2
- package/lib/clients/janus/Session.js +1 -0
- package/lib/clients/janus/Tenant.d.ts +1 -1
- package/lib/clients/janus/Tenant.js +1 -0
- package/lib/clients/janus/index.js +19 -8
- package/lib/constants.d.ts +1 -1
- package/lib/constants.js +2 -1
- package/lib/errors/AuthenticationError.js +1 -0
- package/lib/errors/ForbiddenError.js +1 -0
- package/lib/errors/NotFoundError.js +1 -0
- package/lib/errors/RequestCancelledError.js +1 -0
- package/lib/errors/ResolverError.js +2 -1
- package/lib/errors/ResolverWarning.js +1 -0
- package/lib/errors/TooManyRequestsError.js +1 -0
- package/lib/errors/UserInputError.js +1 -0
- package/lib/errors/index.js +22 -11
- package/lib/index.js +31 -18
- package/lib/metrics/MetricsAccumulator.d.ts +2 -2
- package/lib/metrics/MetricsAccumulator.js +10 -9
- package/lib/responses.d.ts +4 -4
- package/lib/service/index.js +11 -6
- package/lib/service/loaders.js +9 -6
- package/lib/service/logger/console.js +8 -4
- package/lib/service/logger/index.js +16 -5
- package/lib/service/logger/logger.js +3 -2
- package/lib/service/logger/metricsLogger.js +11 -10
- package/lib/service/master.js +8 -6
- package/lib/service/metrics/requestMetricsMiddleware.d.ts +1 -1
- package/lib/service/metrics/requestMetricsMiddleware.js +15 -13
- package/lib/service/tracing/TracerSingleton.js +10 -9
- package/lib/service/tracing/metrics/MetricNames.js +13 -12
- package/lib/service/tracing/metrics/instruments.js +15 -7
- package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.js +6 -5
- package/lib/service/tracing/tracingMiddlewares.d.ts +3 -3
- package/lib/service/tracing/tracingMiddlewares.js +25 -15
- package/lib/service/worker/index.js +25 -23
- package/lib/service/worker/listeners.js +3 -1
- package/lib/service/worker/runtime/Service.js +2 -1
- package/lib/service/worker/runtime/builtIn/handlers.d.ts +3 -3
- package/lib/service/worker/runtime/builtIn/handlers.js +7 -3
- package/lib/service/worker/runtime/builtIn/middlewares.d.ts +2 -2
- package/lib/service/worker/runtime/builtIn/middlewares.js +6 -3
- package/lib/service/worker/runtime/events/index.d.ts +2 -2
- package/lib/service/worker/runtime/events/index.js +12 -10
- package/lib/service/worker/runtime/events/middlewares/body.js +6 -2
- package/lib/service/worker/runtime/events/middlewares/context.js +2 -1
- package/lib/service/worker/runtime/events/router.d.ts +2 -2
- package/lib/service/worker/runtime/events/router.js +4 -2
- package/lib/service/worker/runtime/graphql/index.js +9 -7
- package/lib/service/worker/runtime/graphql/middlewares/context.js +1 -0
- package/lib/service/worker/runtime/graphql/middlewares/error.js +9 -5
- package/lib/service/worker/runtime/graphql/middlewares/query.d.ts +2 -1
- package/lib/service/worker/runtime/graphql/middlewares/query.js +8 -6
- package/lib/service/worker/runtime/graphql/middlewares/response.js +2 -1
- package/lib/service/worker/runtime/graphql/middlewares/run.d.ts +2 -2
- package/lib/service/worker/runtime/graphql/middlewares/run.js +4 -2
- package/lib/service/worker/runtime/graphql/middlewares/updateSchema.d.ts +2 -1
- package/lib/service/worker/runtime/graphql/middlewares/updateSchema.js +5 -3
- package/lib/service/worker/runtime/graphql/middlewares/upload.js +2 -1
- package/lib/service/worker/runtime/graphql/schema/index.d.ts +1 -1
- package/lib/service/worker/runtime/graphql/schema/index.js +9 -7
- package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.d.ts +2 -2
- package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.js +5 -3
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Auth.js +2 -1
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/CacheControl.js +1 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.js +2 -1
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Metric.js +1 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Sanitize.js +1 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.js +2 -1
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/SmartCacheDirective.js +1 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.js +3 -2
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslateTo.js +3 -2
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.js +3 -2
- package/lib/service/worker/runtime/graphql/schema/typeDefs/index.d.ts +2 -1
- package/lib/service/worker/runtime/graphql/schema/typeDefs/index.js +3 -1
- package/lib/service/worker/runtime/graphql/schema/typeDefs/ioUpload.js +1 -0
- package/lib/service/worker/runtime/graphql/schema/typeDefs/sanitizedString.js +3 -2
- package/lib/service/worker/runtime/graphql/typings.d.ts +3 -3
- package/lib/service/worker/runtime/graphql/utils/cacheControl.d.ts +2 -1
- package/lib/service/worker/runtime/graphql/utils/cacheControl.js +3 -1
- package/lib/service/worker/runtime/graphql/utils/error.d.ts +2 -1
- package/lib/service/worker/runtime/graphql/utils/error.js +11 -9
- package/lib/service/worker/runtime/graphql/utils/pathname.js +4 -2
- package/lib/service/worker/runtime/graphql/utils/translations.d.ts +1 -1
- package/lib/service/worker/runtime/graphql/utils/translations.js +8 -4
- package/lib/service/worker/runtime/http/index.d.ts +3 -3
- package/lib/service/worker/runtime/http/index.js +23 -20
- package/lib/service/worker/runtime/http/middlewares/authTokens.js +1 -0
- package/lib/service/worker/runtime/http/middlewares/cancellationToken.js +1 -0
- package/lib/service/worker/runtime/http/middlewares/clients.js +1 -0
- package/lib/service/worker/runtime/http/middlewares/context.js +8 -5
- package/lib/service/worker/runtime/http/middlewares/error.js +10 -6
- package/lib/service/worker/runtime/http/middlewares/rateLimit.js +2 -1
- package/lib/service/worker/runtime/http/middlewares/requestStats.js +1 -0
- package/lib/service/worker/runtime/http/middlewares/setCookie.js +6 -5
- package/lib/service/worker/runtime/http/middlewares/settings.d.ts +1 -1
- package/lib/service/worker/runtime/http/middlewares/settings.js +14 -9
- package/lib/service/worker/runtime/http/middlewares/timings.js +4 -3
- package/lib/service/worker/runtime/http/middlewares/vary.js +1 -0
- package/lib/service/worker/runtime/http/router.d.ts +1 -1
- package/lib/service/worker/runtime/http/router.js +4 -2
- package/lib/service/worker/runtime/http/routes.js +9 -5
- package/lib/service/worker/runtime/method.d.ts +2 -2
- package/lib/service/worker/runtime/method.js +2 -1
- package/lib/service/worker/runtime/statusTrack.d.ts +2 -2
- package/lib/service/worker/runtime/statusTrack.js +11 -5
- package/lib/service/worker/runtime/typings.d.ts +10 -10
- package/lib/service/worker/runtime/utils/compose.d.ts +3 -3
- package/lib/service/worker/runtime/utils/compose.js +5 -2
- package/lib/service/worker/runtime/utils/context.d.ts +4 -1
- package/lib/service/worker/runtime/utils/context.js +6 -4
- package/lib/service/worker/runtime/utils/diff.js +1 -0
- package/lib/service/worker/runtime/utils/recorder.js +2 -1
- package/lib/service/worker/runtime/utils/toArray.js +3 -1
- package/lib/service/worker/runtime/utils/tokenBucket.js +1 -0
- package/lib/tracing/Tags.js +2 -1
- package/lib/tracing/UserLandTracer.js +4 -2
- package/lib/tracing/errorReporting/ErrorReport.js +14 -13
- package/lib/tracing/index.js +10 -9
- package/lib/tracing/spanReference/SpanReferenceTypes.js +1 -0
- package/lib/tracing/spanReference/createSpanReference.js +1 -0
- package/lib/tracing/utils.js +6 -4
- package/lib/utils/MineWinsConflictsResolver.d.ts +4 -4
- package/lib/utils/MineWinsConflictsResolver.js +11 -10
- package/lib/utils/app.js +40 -23
- package/lib/utils/appsStaleIfError.d.ts +1 -0
- package/lib/utils/appsStaleIfError.js +33 -12
- package/lib/utils/billingOptions.js +3 -1
- package/lib/utils/binding.js +5 -2
- package/lib/utils/cancel.js +1 -0
- package/lib/utils/conflicts.mock.js +1 -0
- package/lib/utils/domain.js +2 -1
- package/lib/utils/error.js +6 -4
- package/lib/utils/index.js +23 -12
- package/lib/utils/json.js +1 -0
- package/lib/utils/log.js +4 -2
- package/lib/utils/message.js +9 -5
- package/lib/utils/renameBy.js +3 -1
- package/lib/utils/retry.js +10 -7
- package/lib/utils/status.js +3 -1
- package/lib/utils/tenant.js +5 -2
- package/lib/utils/throwOnGraphQLErrors.js +1 -0
- package/lib/utils/time.d.ts +3 -5
- package/lib/utils/time.js +24 -14
- package/package.json +4 -4
- package/CHANGELOG.md +0 -1858
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Apps = void 0;
|
|
6
7
|
const archiver_1 = __importDefault(require("archiver"));
|
|
7
8
|
const tar_fs_1 = require("tar-fs");
|
|
8
9
|
const zlib_1 = require("zlib");
|
|
@@ -36,7 +37,7 @@ const createRoutes = ({ account, workspace }) => {
|
|
|
36
37
|
};
|
|
37
38
|
return routes;
|
|
38
39
|
};
|
|
39
|
-
const getVendorAndName = ({ id }) => utils_1.removeVersionFromAppId(id);
|
|
40
|
+
const getVendorAndName = ({ id }) => (0, utils_1.removeVersionFromAppId)(id);
|
|
40
41
|
const notFound = (e) => {
|
|
41
42
|
if (e.response && e.response.status === 404) {
|
|
42
43
|
return {};
|
|
@@ -70,6 +71,9 @@ const workspaceFields = [
|
|
|
70
71
|
'version',
|
|
71
72
|
].join(',');
|
|
72
73
|
class Apps extends InfraClient_1.InfraClient {
|
|
74
|
+
get routes() {
|
|
75
|
+
return this._routes;
|
|
76
|
+
}
|
|
73
77
|
constructor(context, options) {
|
|
74
78
|
super('apps@0.x', context, options, true);
|
|
75
79
|
this.installApp = (descriptor, tracingConfig) => {
|
|
@@ -117,7 +121,7 @@ class Apps extends InfraClient_1.InfraClient {
|
|
|
117
121
|
if (indexOfManifest === -1) {
|
|
118
122
|
throw new Error('No manifest.json file found in files.');
|
|
119
123
|
}
|
|
120
|
-
const zip = archiver_1.default('zip', { zlib });
|
|
124
|
+
const zip = (0, archiver_1.default)('zip', { zlib });
|
|
121
125
|
// Throw stream errors so they reject the promise chain.
|
|
122
126
|
zip.on('error', (e) => {
|
|
123
127
|
throw e;
|
|
@@ -139,6 +143,8 @@ class Apps extends InfraClient_1.InfraClient {
|
|
|
139
143
|
return response;
|
|
140
144
|
}
|
|
141
145
|
catch (e) {
|
|
146
|
+
// Typing cast for compatibility with error handling in TS versions > 4.0
|
|
147
|
+
// Source: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-0.html#unknown-on-catch-clause-bindings
|
|
142
148
|
e.bundleSize = zip.pointer();
|
|
143
149
|
throw e;
|
|
144
150
|
}
|
|
@@ -152,7 +158,7 @@ class Apps extends InfraClient_1.InfraClient {
|
|
|
152
158
|
.filter(change => !change.content)
|
|
153
159
|
.map(change => change.path)
|
|
154
160
|
.join(':');
|
|
155
|
-
const zip = archiver_1.default('zip', { zlib });
|
|
161
|
+
const zip = (0, archiver_1.default)('zip', { zlib });
|
|
156
162
|
// Throw stream errors so they reject the promise chain.
|
|
157
163
|
zip.on('error', (e) => {
|
|
158
164
|
throw e;
|
|
@@ -219,7 +225,7 @@ class Apps extends InfraClient_1.InfraClient {
|
|
|
219
225
|
});
|
|
220
226
|
};
|
|
221
227
|
this.listAppFiles = (app, { prefix, nextMarker } = {}, tracingConfig) => {
|
|
222
|
-
const locator = utils_1.parseAppId(app);
|
|
228
|
+
const locator = (0, utils_1.parseAppId)(app);
|
|
223
229
|
const linked = !!locator.build;
|
|
224
230
|
const params = {
|
|
225
231
|
marker: nextMarker,
|
|
@@ -251,11 +257,11 @@ class Apps extends InfraClient_1.InfraClient {
|
|
|
251
257
|
};
|
|
252
258
|
this.getAppFile = (app, path, staleIfError, tracingConfig) => {
|
|
253
259
|
const { logger } = this.context;
|
|
254
|
-
const locator = utils_1.parseAppId(app);
|
|
260
|
+
const locator = (0, utils_1.parseAppId)(app);
|
|
255
261
|
const linked = !!locator.build;
|
|
256
262
|
const inflightKey = HttpClient_1.inflightURL;
|
|
257
263
|
if (staleIfError && this.memoryCache) {
|
|
258
|
-
appsStaleIfError_1.saveVersion(app, this.memoryCache);
|
|
264
|
+
(0, appsStaleIfError_1.saveVersion)(app, this.memoryCache);
|
|
259
265
|
}
|
|
260
266
|
const metric = linked ? 'apps-get-file' : 'registry-get-file';
|
|
261
267
|
try {
|
|
@@ -272,13 +278,13 @@ class Apps extends InfraClient_1.InfraClient {
|
|
|
272
278
|
catch (error) {
|
|
273
279
|
logger.error({ error, message: 'getAppFile failed', app, path });
|
|
274
280
|
if (staleIfError && this.memoryCache) {
|
|
275
|
-
return appsStaleIfError_1.getFallbackFile(app, path, this.memoryCache, this);
|
|
281
|
+
return (0, appsStaleIfError_1.getFallbackFile)(app, path, this.memoryCache, this);
|
|
276
282
|
}
|
|
277
283
|
throw error;
|
|
278
284
|
}
|
|
279
285
|
};
|
|
280
286
|
this.getAppJSON = (app, path, nullIfNotFound, tracingConfig) => {
|
|
281
|
-
const locator = utils_1.parseAppId(app);
|
|
287
|
+
const locator = (0, utils_1.parseAppId)(app);
|
|
282
288
|
const linked = !!locator.build;
|
|
283
289
|
const inflightKey = HttpClient_1.inflightURL;
|
|
284
290
|
const metric = linked ? 'apps-get-json' : 'registry-get-json';
|
|
@@ -308,7 +314,7 @@ class Apps extends InfraClient_1.InfraClient {
|
|
|
308
314
|
});
|
|
309
315
|
};
|
|
310
316
|
this.getAppFileStream = (app, path, tracingConfig) => {
|
|
311
|
-
const locator = utils_1.parseAppId(app);
|
|
317
|
+
const locator = (0, utils_1.parseAppId)(app);
|
|
312
318
|
const metric = locator.build ? 'apps-get-file-s' : 'registry-get-file-s';
|
|
313
319
|
return this.http.getStream(this.routes.File(locator, path), {
|
|
314
320
|
metric,
|
|
@@ -352,7 +358,7 @@ class Apps extends InfraClient_1.InfraClient {
|
|
|
352
358
|
});
|
|
353
359
|
};
|
|
354
360
|
this.getAppBundle = (app, bundlePath, generatePackageJson, tracingConfig) => {
|
|
355
|
-
const locator = utils_1.parseAppId(app);
|
|
361
|
+
const locator = (0, utils_1.parseAppId)(app);
|
|
356
362
|
const params = generatePackageJson && { _packageJSONEngine: 'npm', _packageJSONFilter: 'vtex.render-builder@x' };
|
|
357
363
|
const metric = locator.build ? 'apps-get-bundle' : 'registry-get-bundle';
|
|
358
364
|
return this.http.getStream(this.routes.AppBundle(locator, bundlePath), {
|
|
@@ -371,15 +377,15 @@ class Apps extends InfraClient_1.InfraClient {
|
|
|
371
377
|
this.unpackAppBundle = (app, bundlePath, unpackPath, generatePackageJson, tracingConfig) => {
|
|
372
378
|
return this.getAppBundle(app, bundlePath, generatePackageJson, tracingConfig)
|
|
373
379
|
.then(stream => stream
|
|
374
|
-
.pipe(zlib_1.createGunzip())
|
|
375
|
-
.pipe(tar_fs_1.extract(unpackPath)));
|
|
380
|
+
.pipe((0, zlib_1.createGunzip)())
|
|
381
|
+
.pipe((0, tar_fs_1.extract)(unpackPath)));
|
|
376
382
|
};
|
|
377
383
|
this.getAppsMetaInfos = async (filter, staleWhileRevalidate = true, tracingConfig) => {
|
|
378
384
|
var _a;
|
|
379
385
|
const { account, production, recorder, workspace, logger } = this.context;
|
|
380
386
|
const metric = 'get-apps-meta';
|
|
381
387
|
const inflightKey = HttpClient_1.inflightURL;
|
|
382
|
-
const key = appsStaleIfError_1.getMetaInfoKey(account, workspace);
|
|
388
|
+
const key = (0, appsStaleIfError_1.getMetaInfoKey)(account, workspace);
|
|
383
389
|
const cachedResponse = production && staleWhileRevalidate
|
|
384
390
|
? await ((_a = this.diskCache) === null || _a === void 0 ? void 0 : _a.get(key))
|
|
385
391
|
: undefined;
|
|
@@ -501,8 +507,5 @@ class Apps extends InfraClient_1.InfraClient {
|
|
|
501
507
|
this.memoryCache = options && options.memoryCache;
|
|
502
508
|
this._routes = createRoutes(context);
|
|
503
509
|
}
|
|
504
|
-
get routes() {
|
|
505
|
-
return this._routes;
|
|
506
|
-
}
|
|
507
510
|
}
|
|
508
511
|
exports.Apps = Apps;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { Readable } from 'stream';
|
|
3
4
|
import { AppMetaInfo } from '../..';
|
|
4
5
|
import { InstanceOptions, RequestTracingConfig } from '../../HttpClient';
|
|
@@ -20,14 +21,14 @@ export declare class Assets extends InfraClient {
|
|
|
20
21
|
headers: any;
|
|
21
22
|
}>;
|
|
22
23
|
getFilteredDependencies(apps: string | string[], dependencies: AppMetaInfo[]): AppMetaInfo[];
|
|
23
|
-
getAppBundleByVendor: (app: string, bundlePath: string, generatePackageJson: boolean, tracingConfig?: RequestTracingConfig
|
|
24
|
-
protected getAppJSONByAccount: <T extends object | null>(app: string, path: string, nullIfNotFound?: boolean
|
|
25
|
-
protected getAppJSONByVendor: <T extends object | null>(app: string, path: string, nullIfNotFound?: boolean
|
|
26
|
-
protected getAppFileByAccount: (app: string, path: string, nullIfNotFound?: boolean
|
|
24
|
+
getAppBundleByVendor: (app: string, bundlePath: string, generatePackageJson: boolean, tracingConfig?: RequestTracingConfig) => Promise<Readable>;
|
|
25
|
+
protected getAppJSONByAccount: <T extends object | null>(app: string, path: string, nullIfNotFound?: boolean, tracingConfig?: RequestTracingConfig) => Promise<T>;
|
|
26
|
+
protected getAppJSONByVendor: <T extends object | null>(app: string, path: string, nullIfNotFound?: boolean, tracingConfig?: RequestTracingConfig) => Promise<T>;
|
|
27
|
+
protected getAppFileByAccount: (app: string, path: string, nullIfNotFound?: boolean, tracingConfig?: RequestTracingConfig) => Promise<{
|
|
27
28
|
data: Buffer;
|
|
28
29
|
headers: any;
|
|
29
30
|
}>;
|
|
30
|
-
protected getAppFileByVendor: (app: string, path: string, nullIfNotFound?: boolean
|
|
31
|
+
protected getAppFileByVendor: (app: string, path: string, nullIfNotFound?: boolean, tracingConfig?: RequestTracingConfig) => Promise<{
|
|
31
32
|
data: Buffer;
|
|
32
33
|
headers: any;
|
|
33
34
|
}>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Assets = void 0;
|
|
3
4
|
const ramda_1 = require("ramda");
|
|
4
5
|
const HttpClient_1 = require("../../HttpClient");
|
|
5
6
|
const utils_1 = require("../../utils");
|
|
@@ -21,7 +22,7 @@ const dependsOnApp = (appsAtMajor) => (a) => {
|
|
|
21
22
|
};
|
|
22
23
|
const useBuildJson = (app, appVendorName) => {
|
|
23
24
|
const buildFeatures = app._buildFeatures;
|
|
24
|
-
return buildFeatures && buildFeatures[appVendorName] && ramda_1.contains('build.json', buildFeatures[appVendorName]);
|
|
25
|
+
return buildFeatures && buildFeatures[appVendorName] && (0, ramda_1.contains)('build.json', buildFeatures[appVendorName]);
|
|
25
26
|
};
|
|
26
27
|
const appOrRegistry = (workspace, { name, version, build }) => build
|
|
27
28
|
? `${workspace}/apps/${name}@${version}+${build}`
|
|
@@ -34,7 +35,7 @@ class Assets extends InfraClient_1.InfraClient {
|
|
|
34
35
|
constructor(context, options) {
|
|
35
36
|
super('apps@0.x', context, options, true);
|
|
36
37
|
this.getAppBundleByVendor = (app, bundlePath, generatePackageJson, tracingConfig) => {
|
|
37
|
-
const locator = utils_1.parseAppId(app);
|
|
38
|
+
const locator = (0, utils_1.parseAppId)(app);
|
|
38
39
|
const params = generatePackageJson && { _packageJSONEngine: 'npm', _packageJSONFilter: 'vtex.render-builder@x' };
|
|
39
40
|
const metric = locator.build ? 'apps-get-bundle' : 'registry-get-bundle';
|
|
40
41
|
return this.http.getStream(this.routes.Bundle(this.context.account, locator, bundlePath), {
|
|
@@ -51,7 +52,7 @@ class Assets extends InfraClient_1.InfraClient {
|
|
|
51
52
|
});
|
|
52
53
|
};
|
|
53
54
|
this.getAppJSONByAccount = (app, path, nullIfNotFound, tracingConfig) => {
|
|
54
|
-
const locator = utils_1.parseAppId(app);
|
|
55
|
+
const locator = (0, utils_1.parseAppId)(app);
|
|
55
56
|
const inflightKey = HttpClient_1.inflightURL;
|
|
56
57
|
const metric = 'assets-get-json-by-account';
|
|
57
58
|
return this.http.get(this.routes.Files(this.context.account, locator, path), {
|
|
@@ -66,7 +67,7 @@ class Assets extends InfraClient_1.InfraClient {
|
|
|
66
67
|
});
|
|
67
68
|
};
|
|
68
69
|
this.getAppJSONByVendor = (app, path, nullIfNotFound, tracingConfig) => {
|
|
69
|
-
const locator = utils_1.parseAppId(app);
|
|
70
|
+
const locator = (0, utils_1.parseAppId)(app);
|
|
70
71
|
const vendor = locator.name.split('.')[0];
|
|
71
72
|
const inflightKey = HttpClient_1.inflightURL;
|
|
72
73
|
const metric = 'assets-get-json-by-vendor';
|
|
@@ -82,7 +83,7 @@ class Assets extends InfraClient_1.InfraClient {
|
|
|
82
83
|
});
|
|
83
84
|
};
|
|
84
85
|
this.getAppFileByAccount = (app, path, nullIfNotFound, tracingConfig) => {
|
|
85
|
-
const locator = utils_1.parseAppId(app);
|
|
86
|
+
const locator = (0, utils_1.parseAppId)(app);
|
|
86
87
|
const inflightKey = HttpClient_1.inflightURL;
|
|
87
88
|
const metric = 'assets-get-file-by-account';
|
|
88
89
|
return this.http.getBuffer(this.routes.Files(this.context.account, locator, path), {
|
|
@@ -97,7 +98,7 @@ class Assets extends InfraClient_1.InfraClient {
|
|
|
97
98
|
});
|
|
98
99
|
};
|
|
99
100
|
this.getAppFileByVendor = (app, path, nullIfNotFound, tracingConfig) => {
|
|
100
|
-
const locator = utils_1.parseAppId(app);
|
|
101
|
+
const locator = (0, utils_1.parseAppId)(app);
|
|
101
102
|
const vendor = locator.name.split('.')[0];
|
|
102
103
|
const inflightKey = HttpClient_1.inflightURL;
|
|
103
104
|
const metric = 'assets-get-file-by-vendor';
|
|
@@ -128,7 +129,7 @@ class Assets extends InfraClient_1.InfraClient {
|
|
|
128
129
|
async getBuildJSONForApp(app, appVendorName, pick = [], tracingConfig) {
|
|
129
130
|
const pickArray = Array.isArray(pick) ? pick : [pick];
|
|
130
131
|
const buildJson = await this.getJSON(app.id, `dist/${appVendorName}/build.json`, undefined, tracingConfig);
|
|
131
|
-
const result = !ramda_1.isEmpty(pickArray) ? ramda_1.pick(pickArray, buildJson) : buildJson;
|
|
132
|
+
const result = !(0, ramda_1.isEmpty)(pickArray) ? (0, ramda_1.pick)(pickArray, buildJson) : buildJson;
|
|
132
133
|
result.declarer = app.id;
|
|
133
134
|
return result;
|
|
134
135
|
}
|
|
@@ -136,12 +137,12 @@ class Assets extends InfraClient_1.InfraClient {
|
|
|
136
137
|
// If there's no support for build.json, then fetch individual files and zip them into an {[file]: content} object.
|
|
137
138
|
const filesArray = Array.isArray(files) ? files : [files];
|
|
138
139
|
const fetched = await Promise.all(filesArray.map(file => this.getJSON(app.id, file, true, tracingConfig)));
|
|
139
|
-
const result = ramda_1.zipObj(filesArray, fetched);
|
|
140
|
+
const result = (0, ramda_1.zipObj)(filesArray, fetched);
|
|
140
141
|
result.declarer = app.id;
|
|
141
142
|
return result;
|
|
142
143
|
}
|
|
143
144
|
async getJSON(appId, file, nullIfNotFound, tracingConfig) {
|
|
144
|
-
const locator = utils_1.parseAppId(appId);
|
|
145
|
+
const locator = (0, utils_1.parseAppId)(appId);
|
|
145
146
|
const linked = !!locator.build;
|
|
146
147
|
if (linked) {
|
|
147
148
|
return this.getAppJSONByAccount(appId, file, nullIfNotFound, tracingConfig);
|
|
@@ -149,7 +150,7 @@ class Assets extends InfraClient_1.InfraClient {
|
|
|
149
150
|
return this.getAppJSONByVendor(appId, file, nullIfNotFound, tracingConfig);
|
|
150
151
|
}
|
|
151
152
|
async getFile(appId, file, nullIfNotFound, tracingConfig) {
|
|
152
|
-
const locator = utils_1.parseAppId(appId);
|
|
153
|
+
const locator = (0, utils_1.parseAppId)(appId);
|
|
153
154
|
const linked = !!locator.build;
|
|
154
155
|
if (linked) {
|
|
155
156
|
return this.getAppFileByAccount(appId, file, nullIfNotFound, tracingConfig);
|
|
@@ -159,7 +160,7 @@ class Assets extends InfraClient_1.InfraClient {
|
|
|
159
160
|
getFilteredDependencies(apps, dependencies) {
|
|
160
161
|
const appsAtMajor = typeof (apps) === 'string' ? [apps] : apps;
|
|
161
162
|
const depends = dependsOnApp(appsAtMajor);
|
|
162
|
-
return ramda_1.filter(depends, dependencies);
|
|
163
|
+
return (0, ramda_1.filter)(depends, dependencies);
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
166
|
exports.Assets = Assets;
|
|
@@ -3,7 +3,7 @@ import { IOContext } from '../../service/worker/runtime/typings';
|
|
|
3
3
|
import { InfraClient } from './InfraClient';
|
|
4
4
|
export declare class BillingMetrics extends InfraClient {
|
|
5
5
|
constructor(context: IOContext, options?: InstanceOptions);
|
|
6
|
-
sendMetric: (metric: BillingMetric, tracingConfig?: RequestTracingConfig
|
|
6
|
+
sendMetric: (metric: BillingMetric, tracingConfig?: RequestTracingConfig) => Promise<BillingMetric>;
|
|
7
7
|
}
|
|
8
8
|
export interface BillingMetric {
|
|
9
9
|
value: number;
|
|
@@ -3,7 +3,7 @@ import { IOContext } from '../../service/worker/runtime/typings';
|
|
|
3
3
|
import { InfraClient } from './InfraClient';
|
|
4
4
|
export declare class Events extends InfraClient {
|
|
5
5
|
constructor({ recorder, ...context }: IOContext, options?: InstanceOptions);
|
|
6
|
-
sendEvent: (appIdOrResource: string | ResourceVRN, route: string, message?: any, tracingConfig?: RequestTracingConfig
|
|
6
|
+
sendEvent: (appIdOrResource: string | ResourceVRN, route: string, message?: any, tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
7
7
|
private resourceFor;
|
|
8
8
|
}
|
|
9
9
|
export interface ResourceVRN {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Events = void 0;
|
|
3
4
|
const util_1 = require("util");
|
|
4
5
|
const InfraClient_1 = require("./InfraClient");
|
|
5
6
|
const ANY_APP = '';
|
|
6
7
|
const eventRoute = (route) => `/events/${route}`;
|
|
7
|
-
const isResourceVRN = (appIdOrResource) => util_1.isObject(appIdOrResource) && !util_1.isNullOrUndefined(appIdOrResource.service);
|
|
8
|
+
const isResourceVRN = (appIdOrResource) => (0, util_1.isObject)(appIdOrResource) && !(0, util_1.isNullOrUndefined)(appIdOrResource.service);
|
|
8
9
|
class Events extends InfraClient_1.InfraClient {
|
|
9
10
|
constructor({ recorder, ...context }, options) {
|
|
10
11
|
super('courier@0.x', context, options);
|
|
@@ -4,7 +4,7 @@ import { IOContext } from '../../service/worker/runtime/typings';
|
|
|
4
4
|
import { InfraClient } from './InfraClient';
|
|
5
5
|
export declare class Housekeeper extends InfraClient {
|
|
6
6
|
constructor(context: IOContext, options?: InstanceOptions);
|
|
7
|
-
apply: (data: HousekeeperStatesAndUpdates, tracingConfig?: RequestTracingConfig
|
|
8
|
-
perform: (tracingConfig?: RequestTracingConfig
|
|
9
|
-
resolve: (tracingConfig?: RequestTracingConfig
|
|
7
|
+
apply: (data: HousekeeperStatesAndUpdates, tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
8
|
+
perform: (tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
9
|
+
resolve: (tracingConfig?: RequestTracingConfig) => Promise<HousekeeperStatesAndUpdates>;
|
|
10
10
|
}
|
|
@@ -1,32 +1,38 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
2
4
|
import { IncomingMessage } from 'http';
|
|
3
5
|
import { Readable, Writable } from 'stream';
|
|
4
6
|
import { ZlibOptions } from 'zlib';
|
|
5
7
|
import { InstanceOptions, RequestTracingConfig } from '../../HttpClient';
|
|
6
|
-
import {
|
|
8
|
+
import { AppFilesList, AppManifest, AppState } from '../../responses';
|
|
7
9
|
import { IOContext } from '../../service/worker/runtime/typings';
|
|
8
10
|
import { InfraClient } from './InfraClient';
|
|
9
11
|
export declare class Registry extends InfraClient {
|
|
10
12
|
constructor(context: IOContext, options?: InstanceOptions);
|
|
11
|
-
getAppState: (app: string, version: string, tracingConfig?: RequestTracingConfig
|
|
12
|
-
publishApp: (files: File[], tag?: string
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
getAppState: (app: string, version: string, tracingConfig?: RequestTracingConfig) => Promise<AppState>;
|
|
14
|
+
publishApp: (files: File[], tag?: string, { zlib }?: ZipOptions, tracingConfig?: RequestTracingConfig) => Promise<import("../../responses").AppBundleResponse & {
|
|
15
|
+
bundleSize?: number | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
publishAppRc: (files: File[], tag?: string, { zlib }?: ZipOptions, tracingConfig?: RequestTracingConfig) => Promise<import("../../responses").AppBundleResponse & {
|
|
18
|
+
bundleSize?: number | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
listApps: (tracingConfig?: RequestTracingConfig) => Promise<RegistryAppsList>;
|
|
21
|
+
listVersionsByApp: (app: string, tracingConfig?: RequestTracingConfig) => Promise<RegistryAppVersionsList>;
|
|
22
|
+
deprecateApp: (app: string, version: string, tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
23
|
+
undeprecateApp: (app: string, version: string, tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
24
|
+
validateApp: (app: string, version: string, tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
25
|
+
getAppManifest: (app: string, version: string, opts?: AppsManifestOptions, tracingConfig?: RequestTracingConfig) => Promise<AppManifest>;
|
|
26
|
+
listAppFiles: (app: string, version: string, opts?: ListAppFilesOptions, tracingConfig?: RequestTracingConfig) => Promise<AppFilesList>;
|
|
27
|
+
getAppFile: (app: string, version: string, path: string, tracingConfig?: RequestTracingConfig) => Promise<{
|
|
22
28
|
data: Buffer;
|
|
23
29
|
headers: any;
|
|
24
30
|
}>;
|
|
25
|
-
getAppJSON: <T extends object | null>(app: string, version: string, path: string, nullIfNotFound?: boolean
|
|
26
|
-
getAppFileStream: (app: string, version: string, path: string, tracingConfig?: RequestTracingConfig
|
|
27
|
-
getAppBundle: (app: string, version: string, bundlePath: string, generatePackageJson: boolean, tracingConfig?: RequestTracingConfig
|
|
28
|
-
unpackAppBundle: (app: string, version: string, bundlePath: string, unpackPath: string, generatePackageJson: boolean, tracingConfig?: RequestTracingConfig
|
|
29
|
-
resolveDependenciesWithManifest: (manifest: AppManifest, filter?: string, tracingConfig?: RequestTracingConfig
|
|
31
|
+
getAppJSON: <T extends object | null>(app: string, version: string, path: string, nullIfNotFound?: boolean, tracingConfig?: RequestTracingConfig) => Promise<T>;
|
|
32
|
+
getAppFileStream: (app: string, version: string, path: string, tracingConfig?: RequestTracingConfig) => Promise<IncomingMessage>;
|
|
33
|
+
getAppBundle: (app: string, version: string, bundlePath: string, generatePackageJson: boolean, tracingConfig?: RequestTracingConfig) => Promise<Readable>;
|
|
34
|
+
unpackAppBundle: (app: string, version: string, bundlePath: string, unpackPath: string, generatePackageJson: boolean, tracingConfig?: RequestTracingConfig) => Promise<Writable>;
|
|
35
|
+
resolveDependenciesWithManifest: (manifest: AppManifest, filter?: string, tracingConfig?: RequestTracingConfig) => Promise<Record<string, string[]>>;
|
|
30
36
|
private publish;
|
|
31
37
|
}
|
|
32
38
|
interface ZipOptions {
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Registry = void 0;
|
|
6
7
|
const archiver_1 = __importDefault(require("archiver"));
|
|
7
8
|
const tar_fs_1 = require("tar-fs");
|
|
8
9
|
const zlib_1 = require("zlib");
|
|
@@ -156,8 +157,8 @@ class Registry extends InfraClient_1.InfraClient {
|
|
|
156
157
|
this.unpackAppBundle = (app, version, bundlePath, unpackPath, generatePackageJson, tracingConfig) => {
|
|
157
158
|
return this.getAppBundle(app, version, bundlePath, generatePackageJson, tracingConfig)
|
|
158
159
|
.then(stream => stream
|
|
159
|
-
.pipe(zlib_1.createGunzip())
|
|
160
|
-
.pipe(tar_fs_1.extract(unpackPath)));
|
|
160
|
+
.pipe((0, zlib_1.createGunzip)())
|
|
161
|
+
.pipe((0, tar_fs_1.extract)(unpackPath)));
|
|
161
162
|
};
|
|
162
163
|
this.resolveDependenciesWithManifest = (manifest, filter = '', tracingConfig) => {
|
|
163
164
|
const params = { filter };
|
|
@@ -175,7 +176,7 @@ class Registry extends InfraClient_1.InfraClient {
|
|
|
175
176
|
if (indexOfManifest === -1) {
|
|
176
177
|
throw new Error('No manifest.json file found in files.');
|
|
177
178
|
}
|
|
178
|
-
const zip = archiver_1.default('zip', { zlib });
|
|
179
|
+
const zip = (0, archiver_1.default)('zip', { zlib });
|
|
179
180
|
// Throw stream errors so they reject the promise chain.
|
|
180
181
|
zip.on('error', (e) => {
|
|
181
182
|
throw e;
|
|
@@ -198,6 +199,7 @@ class Registry extends InfraClient_1.InfraClient {
|
|
|
198
199
|
return response;
|
|
199
200
|
}
|
|
200
201
|
catch (e) {
|
|
202
|
+
// See Apps.ts `link` method for more information on this cast
|
|
201
203
|
e.bundleSize = zip.pointer();
|
|
202
204
|
throw e;
|
|
203
205
|
}
|
|
@@ -3,13 +3,13 @@ import { IOContext } from '../../service/worker/runtime/typings';
|
|
|
3
3
|
import { InfraClient } from './InfraClient';
|
|
4
4
|
export declare class Router extends InfraClient {
|
|
5
5
|
constructor(ioContext: IOContext, opts?: InstanceOptions);
|
|
6
|
-
listAvailableIoVersions: (tracingConfig?: RequestTracingConfig
|
|
7
|
-
getInstalledIoVersion: (tracingConfig?: RequestTracingConfig
|
|
8
|
-
installIo: (version: string, tracingConfig?: RequestTracingConfig
|
|
9
|
-
listAvailableServices: (tracingConfig?: RequestTracingConfig
|
|
10
|
-
getAvailableVersions: (name: string, tracingConfig?: RequestTracingConfig
|
|
11
|
-
listInstalledServices: (tracingConfig?: RequestTracingConfig
|
|
12
|
-
installService: (name: string, version: string, tracingConfig?: RequestTracingConfig
|
|
6
|
+
listAvailableIoVersions: (tracingConfig?: RequestTracingConfig) => Promise<AvaiableIO[]>;
|
|
7
|
+
getInstalledIoVersion: (tracingConfig?: RequestTracingConfig) => Promise<AvaiableIO>;
|
|
8
|
+
installIo: (version: string, tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
9
|
+
listAvailableServices: (tracingConfig?: RequestTracingConfig) => Promise<AvailableServices>;
|
|
10
|
+
getAvailableVersions: (name: string, tracingConfig?: RequestTracingConfig) => Promise<AvailableServiceVersions>;
|
|
11
|
+
listInstalledServices: (tracingConfig?: RequestTracingConfig) => Promise<InstalledService[]>;
|
|
12
|
+
installService: (name: string, version: string, tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
13
13
|
}
|
|
14
14
|
export interface AvaiableIO {
|
|
15
15
|
version: string;
|
|
@@ -18,7 +18,7 @@ export interface AvaiableIO {
|
|
|
18
18
|
[service: string]: string;
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
export
|
|
21
|
+
export type InstalledIO = AvaiableIO;
|
|
22
22
|
export interface AvailableServiceVersions {
|
|
23
23
|
versions: {
|
|
24
24
|
[region: string]: string[];
|
|
@@ -3,8 +3,8 @@ import { IOContext } from '../../service/worker/runtime/typings';
|
|
|
3
3
|
import { InfraClient } from './InfraClient';
|
|
4
4
|
export declare class Sphinx extends InfraClient {
|
|
5
5
|
constructor(ioContext: IOContext, opts?: InstanceOptions);
|
|
6
|
-
validatePolicies: (policies: PolicyRequest[], tracingConfig?: RequestTracingConfig
|
|
7
|
-
isAdmin: (email: string, tracingConfig?: RequestTracingConfig
|
|
6
|
+
validatePolicies: (policies: PolicyRequest[], tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
7
|
+
isAdmin: (email: string, tracingConfig?: RequestTracingConfig) => Promise<boolean>;
|
|
8
8
|
}
|
|
9
9
|
export interface PolicyRequest {
|
|
10
10
|
name: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { IncomingMessage } from 'http';
|
|
3
4
|
import { Readable } from 'stream';
|
|
4
5
|
import { Logger } from './../../service/logger/logger';
|
|
@@ -8,23 +9,23 @@ import { IOContext } from '../../service/worker/runtime/typings';
|
|
|
8
9
|
import { InfraClient } from './InfraClient';
|
|
9
10
|
export declare class VBase extends InfraClient {
|
|
10
11
|
constructor(context: IOContext, options?: InstanceOptions);
|
|
11
|
-
getBucket: (bucket: string, tracingConfig?: RequestTracingConfig
|
|
12
|
-
resetBucket: (bucket: string, tracingConfig?: RequestTracingConfig
|
|
13
|
-
listFiles: (bucket: string, opts?: string | VBaseOptions
|
|
14
|
-
getFile: (bucket: string, path: string, tracingConfig?: RequestTracingConfig
|
|
12
|
+
getBucket: (bucket: string, tracingConfig?: RequestTracingConfig) => Promise<BucketMetadata>;
|
|
13
|
+
resetBucket: (bucket: string, tracingConfig?: RequestTracingConfig) => Promise<IOResponse<void>>;
|
|
14
|
+
listFiles: (bucket: string, opts?: string | VBaseOptions, tracingConfig?: RequestTracingConfig) => Promise<BucketFileList>;
|
|
15
|
+
getFile: (bucket: string, path: string, tracingConfig?: RequestTracingConfig) => Promise<{
|
|
15
16
|
data: Buffer;
|
|
16
17
|
headers: any;
|
|
17
18
|
}>;
|
|
18
|
-
getJSON: <T>(bucket: string, path: string, nullIfNotFound?: boolean
|
|
19
|
-
getRawJSON: <T>(bucket: string, path: string, nullIfNotFound?: boolean
|
|
20
|
-
getFileStream: (bucket: string, path: string, tracingConfig?: RequestTracingConfig
|
|
21
|
-
saveFile: (bucket: string, path: string, stream: Readable, gzip?: boolean, ttl?: number
|
|
22
|
-
getFileMetadata: (bucket: string, path: string, tracingConfig?: RequestTracingConfig
|
|
23
|
-
saveJSON: <T>(bucket: string, path: string, data: T, tracingConfig?: RequestTracingConfig
|
|
24
|
-
saveZippedContent: (bucket: string, path: string, stream: Readable, tracingConfig?: RequestTracingConfig
|
|
25
|
-
deleteFile: (bucket: string, path: string, tracingConfig?: RequestTracingConfig
|
|
26
|
-
getConflicts: <T>(bucket: string, tracingConfig?: RequestTracingConfig
|
|
27
|
-
resolveConflict: <T>(bucket: string, path: string, content: any, tracingConfig?: RequestTracingConfig
|
|
19
|
+
getJSON: <T>(bucket: string, path: string, nullIfNotFound?: boolean, conflictsResolver?: ConflictsResolver<T> | undefined, tracingConfig?: RequestTracingConfig) => Promise<T>;
|
|
20
|
+
getRawJSON: <T>(bucket: string, path: string, nullIfNotFound?: boolean, conflictsResolver?: ConflictsResolver<T> | undefined, tracingConfig?: RequestTracingConfig) => Promise<IOResponse<T>>;
|
|
21
|
+
getFileStream: (bucket: string, path: string, tracingConfig?: RequestTracingConfig) => Promise<IncomingMessage>;
|
|
22
|
+
saveFile: (bucket: string, path: string, stream: Readable, gzip?: boolean, ttl?: number, tracingConfig?: RequestTracingConfig, ifMatch?: string) => Promise<void>;
|
|
23
|
+
getFileMetadata: (bucket: string, path: string, tracingConfig?: RequestTracingConfig) => Promise<IOResponse<void>>;
|
|
24
|
+
saveJSON: <T>(bucket: string, path: string, data: T, tracingConfig?: RequestTracingConfig, ifMatch?: string) => Promise<VBaseSaveResponse>;
|
|
25
|
+
saveZippedContent: (bucket: string, path: string, stream: Readable, tracingConfig?: RequestTracingConfig, ifMatch?: string) => Promise<void>;
|
|
26
|
+
deleteFile: (bucket: string, path: string, tracingConfig?: RequestTracingConfig, ifMatch?: string) => Promise<IOResponse<void>>;
|
|
27
|
+
getConflicts: <T>(bucket: string, tracingConfig?: RequestTracingConfig) => Promise<T>;
|
|
28
|
+
resolveConflict: <T>(bucket: string, path: string, content: any, tracingConfig?: RequestTracingConfig) => Promise<T>;
|
|
28
29
|
private saveContent;
|
|
29
30
|
}
|
|
30
31
|
export interface BucketFileList {
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.VBase = void 0;
|
|
6
7
|
const mime_types_1 = __importDefault(require("mime-types"));
|
|
7
8
|
const path_1 = require("path");
|
|
8
9
|
const zlib_1 = require("zlib");
|
|
@@ -138,7 +139,7 @@ class VBase extends InfraClient_1.InfraClient {
|
|
|
138
139
|
return this.saveContent(bucket, path, stream, { unzip: true }, tracingConfig, ifMatch);
|
|
139
140
|
};
|
|
140
141
|
this.deleteFile = (bucket, path, tracingConfig, ifMatch) => {
|
|
141
|
-
const headers = ifMatch ? { 'If-Match': ifMatch } :
|
|
142
|
+
const headers = ifMatch ? { 'If-Match': ifMatch } : {};
|
|
142
143
|
const metric = 'vbase-delete-file';
|
|
143
144
|
return this.http.delete(routes.File(bucket, path), { headers, metric, tracing: {
|
|
144
145
|
requestSpanNameSuffix: metric,
|
|
@@ -171,10 +172,10 @@ class VBase extends InfraClient_1.InfraClient {
|
|
|
171
172
|
const params = opts.unzip ? { unzip: opts.unzip } : {};
|
|
172
173
|
const headers = {};
|
|
173
174
|
let finalStream = stream;
|
|
174
|
-
headers['Content-Type'] = mime_types_1.default.contentType(path_1.basename(path)) || 'application/octet-stream';
|
|
175
|
+
headers['Content-Type'] = mime_types_1.default.contentType((0, path_1.basename)(path)) || 'application/octet-stream';
|
|
175
176
|
if (opts.gzip) {
|
|
176
177
|
headers['Content-Encoding'] = 'gzip';
|
|
177
|
-
finalStream = stream.pipe(zlib_1.createGzip());
|
|
178
|
+
finalStream = stream.pipe((0, zlib_1.createGzip)());
|
|
178
179
|
}
|
|
179
180
|
if (opts.ttl && Number.isInteger(opts.ttl)) {
|
|
180
181
|
headers['X-VTEX-TTL'] = opts.ttl;
|
|
@@ -3,13 +3,13 @@ import { IOContext } from '../../service/worker/runtime/typings';
|
|
|
3
3
|
import { InfraClient } from './InfraClient';
|
|
4
4
|
export declare class Workspaces extends InfraClient {
|
|
5
5
|
constructor(context: IOContext, options?: InstanceOptions);
|
|
6
|
-
list: (account: string, tracingConfig?: RequestTracingConfig
|
|
7
|
-
get: (account: string, workspace: string, tracingConfig?: RequestTracingConfig
|
|
8
|
-
set: (account: string, workspace: string, metadata: Partial<WorkspaceMetadata>, tracingConfig?: RequestTracingConfig
|
|
9
|
-
create: (account: string, workspace: string, production: boolean, tracingConfig?: RequestTracingConfig
|
|
10
|
-
delete: (account: string, workspace: string, tracingConfig?: RequestTracingConfig
|
|
11
|
-
reset: (account: string, workspace: string, metadata?: Partial<WorkspaceMetadata>, tracingConfig?: RequestTracingConfig
|
|
12
|
-
promote: (account: string, workspace: string, tracingConfig?: RequestTracingConfig
|
|
6
|
+
list: (account: string, tracingConfig?: RequestTracingConfig) => Promise<WorkspaceMetadata[]>;
|
|
7
|
+
get: (account: string, workspace: string, tracingConfig?: RequestTracingConfig) => Promise<WorkspaceMetadata>;
|
|
8
|
+
set: (account: string, workspace: string, metadata: Partial<WorkspaceMetadata>, tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
9
|
+
create: (account: string, workspace: string, production: boolean, tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
10
|
+
delete: (account: string, workspace: string, tracingConfig?: RequestTracingConfig) => Promise<import("../../HttpClient").IOResponse<void>>;
|
|
11
|
+
reset: (account: string, workspace: string, metadata?: Partial<WorkspaceMetadata>, tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
12
|
+
promote: (account: string, workspace: string, tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
13
13
|
}
|
|
14
14
|
export interface WorkspaceMetadata {
|
|
15
15
|
name: string;
|