@viewdo/dxp-story-cli
Version:
DXP Story Management CLI
118 lines • 5.24 kB
JavaScript
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConventionService = void 0;
const typedi_1 = require("typedi");
let ConventionService = class ConventionService {
constructor(namespace) {
this.productionNamespaces = ["default", "master", "archer", "master-archer", "main"];
this.namespaces = ["local", "develop", "stage", ...this.productionNamespaces];
// API Docs Client IDs
this.interactiveClientIdMap = {
local: 'tzC5wJLlL4XhXbZPrJ201lWLQlRcdHZ6',
develop: 'RCOKkYVjfO544jZU2k4xu54USNqSDhAt',
stage: 'NFkL57Yx5zNINSuq5o48DB45jPRgjbBu',
main: 'iEZfphUPUUZrvZmJqwXKkl3QqLG4xlIV',
'main-legacy': 'w5COP2A83MCytQQk2a4B19Zdpw0PWwyv',
};
// Story CLI Client IDs
this.clientIdMap = {
local: 'krwxbZM4rhMARUM2ejznBLGEdCdJf7CE',
develop: 'joXWn0ArbFz4PGByO4pkTZceWublrf4c',
stage: '9fsPw14SsP9eH16ggwT3r4tGb1OfxV3E',
main: '7Ehmrnv9Su5EFQiHmi7d54Mm4JUbAZy6',
'main-legacy': '3vrUA8XjImLdkGkMG4dGXuWVhyVvToV9',
};
// Story CLI
this.clientSecretMap = {
local: process.env.AUTH0_STORY_CLI_CLIENT_SECRET_LOCAL,
develop: process.env.AUTH0_STORY_CLI_CLIENT_SECRET_DEVELOP,
stage: process.env.AUTH0_STORY_CLI_CLIENT_SECRET_STAGE,
main: process.env.AUTH0_STORY_CLI_CLIENT_SECRET_MAIN,
'main-legacy': process.env.AUTH0_STORY_CLI_CLIENT_SECRET_MAIN_LEGACY,
};
this.dxpAccessTokenMap = {
local: process.env.DXP_ACCESS_TOKEN_LOCAL,
develop: process.env.DXP_ACCESS_TOKEN_DEVELOP,
stage: process.env.DXP_ACCESS_TOKEN_STAGE,
main: process.env.DXP_ACCESS_TOKEN_MAIN,
'main-legacy': process.env.DXP_ACCESS_TOKEN_MAIN_LEGACY,
};
// When PREVENT_AUTH_FALLBACK is 1, prevent retrieving token directly from Auth0 if cached token from platform is not available
this.preventAuthFallback = process.env.PREVENT_AUTH_FALLBACK || '';
this.bucket = "viewdo-static";
this.bucket_vanity_url = "https://static.view.do";
this.assets_folder = "assets";
this.stripo_api_ver = "v1";
if (namespace)
this._namespace = namespace;
}
getApiURL(api_type) {
return `https://dxp-api.${this.namespace === 'main' ? 'archer' : this.namespace}.viewdo.run/v4/${api_type}`;
}
get namespace() {
return this._namespace || process.env.NAMESPACE || "develop";
}
get isProduction() {
return this.productionNamespaces.includes(this.namespace);
}
get auth_api_url() {
return this.getApiURL("auth");
}
get admin_api_url() {
return this.getApiURL("admin");
}
get services_api_url() {
return this.getApiURL("services");
}
get xapi_api_url() {
return `https://dxp-xapi.${this.namespace === 'main' ? 'archer' : this.namespace}.viewdo.run/v4`;
}
get stripo_api_url() {
return `https://my.stripo.email/emailgeneration/${this.stripo_api_ver}`;
}
get auth_filename() {
return `auth.${this.namespace}.yml`;
}
get auth0_api_url() {
if (process.env.AUTH0_URL)
return process.env.AUTH0_URL;
if (this.namespace == 'main-legacy')
return "https://viewdo-master.us.auth0.com";
if (this.namespace == 'main')
return "https://master-archer.us.auth0.com";
return (`https://viewdo-${this.namespace}.us.auth0.com`);
}
get auth0_audience() {
return (process.env.AUTH0_AUDIENCE ||
(this.isProduction ? "https://api.view.do" : "https://api.viewdo.run"));
}
get auth0_client_id() {
return (process.env.AUTH0_CLIENT_ID ||
this.clientIdMap[this.namespace]);
}
get auth0_client_secret() {
return (process.env.AUTH0_CLIENT_SECRET ||
this.clientSecretMap[this.namespace]);
}
get auth0_client_id_interactive() {
return this.interactiveClientIdMap[this.namespace];
}
get dxp_access_token() {
return this.dxpAccessTokenMap[this.namespace];
}
};
exports.ConventionService = ConventionService;
exports.ConventionService = ConventionService = __decorate([
(0, typedi_1.Service)(),
__metadata("design:paramtypes", [String])
], ConventionService);
//# sourceMappingURL=ConventionService.js.map