diff --git a/action.yml b/action.yml
index a169e76..52fd782 100644
--- a/action.yml
+++ b/action.yml
@@ -44,6 +44,9 @@ inputs:
polling-submission-id:
description: 'The Id of the active submission being processed'
required: false
+ only-on-ready:
+ description: 'Only interact with the API when the module is ready to take on new submissions'
+ required: false
outputs:
draft-submission:
description: 'The existing draft of the product specified'
@@ -53,4 +56,4 @@ outputs:
description: 'The Id of the active submission being processed'
runs:
using: 'node16'
- main: 'dist/index.js'
\ No newline at end of file
+ main: 'dist/index.js'
diff --git a/dist/index.js b/dist/index.js
index 3db4e85..7a18c42 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -5,119 +5,129 @@
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
-
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
-}) : function(o, v) {
- o["default"] = v;
-});
-var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
-};
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-Object.defineProperty(exports, "__esModule", ({ value: true }));
-const core = __importStar(__nccwpck_require__(186));
-const store_apis_1 = __nccwpck_require__(605);
-(function main() {
- return __awaiter(this, void 0, void 0, function* () {
- const storeApis = new store_apis_1.StoreApis();
- try {
- const command = core.getInput("command");
- switch (command) {
- case "configure": {
- storeApis.productId = core.getInput("product-id");
- storeApis.sellerId = core.getInput("seller-id");
- storeApis.tenantId = core.getInput("tenant-id");
- storeApis.clientId = core.getInput("client-id");
- storeApis.clientSecret = core.getInput("client-secret");
- yield storeApis.InitAsync();
- core.exportVariable(`${store_apis_1.EnvVariablePrefix}product_id`, storeApis.productId);
- core.exportVariable(`${store_apis_1.EnvVariablePrefix}seller_id`, storeApis.sellerId);
- core.exportVariable(`${store_apis_1.EnvVariablePrefix}tenant_id`, storeApis.tenantId);
- core.exportVariable(`${store_apis_1.EnvVariablePrefix}client_id`, storeApis.clientId);
- core.exportVariable(`${store_apis_1.EnvVariablePrefix}client_secret`, storeApis.clientSecret);
- core.exportVariable(`${store_apis_1.EnvVariablePrefix}access_token`, storeApis.accessToken);
- core.setSecret(storeApis.productId);
- core.setSecret(storeApis.sellerId);
- core.setSecret(storeApis.tenantId);
- core.setSecret(storeApis.clientId);
- core.setSecret(storeApis.clientSecret);
- core.setSecret(storeApis.accessToken);
- break;
- }
- case "get": {
- const moduleName = core.getInput("module-name");
- const listingLanguage = core.getInput("listing-language");
- const draftSubmission = yield storeApis.GetExistingDraft(moduleName, listingLanguage);
- core.setOutput("draft-submission", draftSubmission);
- break;
- }
- case "update": {
- const updatedMetadataString = core.getInput("metadata-update");
- const updatedProductString = core.getInput("product-update");
- if (!updatedMetadataString && !updatedProductString) {
- core.setFailed(`Nothing to update. Both product-update and metadata-update are null.`);
- return;
- }
- if (updatedMetadataString) {
- const updateSubmissionMetadata = yield storeApis.UpdateSubmissionMetadata(updatedMetadataString);
- console.log(updateSubmissionMetadata);
- }
- if (updatedProductString) {
- const updateSubmissionData = yield storeApis.UpdateProductPackages(updatedProductString);
- console.log(updateSubmissionData);
- }
- break;
- }
- case "poll": {
- const pollingSubmissionId = core.getInput("polling-submission-id");
- if (!pollingSubmissionId) {
- core.setFailed(`polling-submission-id parameter cannot be empty.`);
- return;
- }
- const publishingStatus = yield storeApis.PollSubmissionStatus(pollingSubmissionId);
- core.setOutput("submission-status", publishingStatus);
- break;
- }
- case "publish": {
- const submissionId = yield storeApis.PublishSubmission();
- core.setOutput("polling-submission-id", submissionId);
- break;
- }
- default: {
- core.setFailed(`Unknown command - ("${command}").`);
- break;
- }
- }
- }
- catch (error) {
- core.setFailed(error);
- }
- });
-})();
+
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+};
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+const core = __importStar(__nccwpck_require__(186));
+const store_apis_1 = __nccwpck_require__(605);
+(function main() {
+ return __awaiter(this, void 0, void 0, function* () {
+ const storeApis = new store_apis_1.StoreApis();
+ try {
+ const command = core.getInput("command");
+ switch (command) {
+ case "configure": {
+ storeApis.productId = core.getInput("product-id");
+ storeApis.sellerId = core.getInput("seller-id");
+ storeApis.tenantId = core.getInput("tenant-id");
+ storeApis.clientId = core.getInput("client-id");
+ storeApis.clientSecret = core.getInput("client-secret");
+ storeApis.onlyOnReady = core.getBooleanInput("only-on-ready");
+ yield storeApis.InitAsync();
+ core.exportVariable(`${store_apis_1.EnvVariablePrefix}product_id`, storeApis.productId);
+ core.exportVariable(`${store_apis_1.EnvVariablePrefix}seller_id`, storeApis.sellerId);
+ core.exportVariable(`${store_apis_1.EnvVariablePrefix}tenant_id`, storeApis.tenantId);
+ core.exportVariable(`${store_apis_1.EnvVariablePrefix}client_id`, storeApis.clientId);
+ core.exportVariable(`${store_apis_1.EnvVariablePrefix}client_secret`, storeApis.clientSecret);
+ core.exportVariable(`${store_apis_1.EnvVariablePrefix}access_token`, storeApis.accessToken);
+ core.exportVariable(`${store_apis_1.EnvVariablePrefix}only-on-ready`, storeApis.onlyOnReady);
+ core.setSecret(storeApis.productId);
+ core.setSecret(storeApis.sellerId);
+ core.setSecret(storeApis.tenantId);
+ core.setSecret(storeApis.clientId);
+ core.setSecret(storeApis.clientSecret);
+ core.setSecret(storeApis.accessToken);
+ break;
+ }
+ case "get": {
+ const moduleName = core.getInput("module-name");
+ const listingLanguage = core.getInput("listing-language");
+ const draftSubmission = yield storeApis.GetExistingDraft(moduleName, listingLanguage);
+ core.setOutput("draft-submission", draftSubmission);
+ break;
+ }
+ case "update": {
+ if (!(yield storeApis.IsReady())) {
+ core.notice(`Only on ready is set and module is not ready, skipping.`);
+ return;
+ }
+ const updatedMetadataString = core.getInput("metadata-update");
+ const updatedProductString = core.getInput("product-update");
+ if (!updatedMetadataString && !updatedProductString) {
+ core.setFailed(`Nothing to update. Both product-update and metadata-update are null.`);
+ return;
+ }
+ if (updatedMetadataString) {
+ const updateSubmissionMetadata = yield storeApis.UpdateSubmissionMetadata(updatedMetadataString);
+ console.log(updateSubmissionMetadata);
+ }
+ if (updatedProductString) {
+ const updateSubmissionData = yield storeApis.UpdateProductPackages(updatedProductString);
+ console.log(updateSubmissionData);
+ }
+ break;
+ }
+ case "poll": {
+ const pollingSubmissionId = core.getInput("polling-submission-id");
+ if (!pollingSubmissionId) {
+ core.setFailed(`polling-submission-id parameter cannot be empty.`);
+ return;
+ }
+ const publishingStatus = yield storeApis.PollSubmissionStatus(pollingSubmissionId);
+ core.setOutput("submission-status", publishingStatus);
+ break;
+ }
+ case "publish": {
+ if (!(yield storeApis.IsReady())) {
+ core.notice(`Only on ready is set and module is not ready, skipping`);
+ return;
+ }
+ const submissionId = yield storeApis.PublishSubmission();
+ core.setOutput("polling-submission-id", submissionId);
+ break;
+ }
+ default: {
+ core.setFailed(`Unknown command - ("${command}").`);
+ break;
+ }
+ }
+ }
+ catch (error) {
+ core.setFailed(error);
+ }
+ });
+})();
//# sourceMappingURL=github_action.js.map
/***/ }),
@@ -126,667 +136,684 @@ const store_apis_1 = __nccwpck_require__(605);
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
-
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
-}) : function(o, v) {
- o["default"] = v;
-});
-var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
-};
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-Object.defineProperty(exports, "__esModule", ({ value: true }));
-exports.StoreApis = exports.EnvVariablePrefix = void 0;
-const https = __importStar(__nccwpck_require__(687));
-exports.EnvVariablePrefix = "MICROSOFT_STORE_ACTION_";
-class ResponseWrapper {
- constructor() {
- Object.defineProperty(this, "responseData", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "isSuccess", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "errors", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class ErrorResponse {
- constructor() {
- Object.defineProperty(this, "statusCode", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "message", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class Error {
- constructor() {
- Object.defineProperty(this, "code", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "message", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "target", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class SubmissionResponse {
- constructor() {
- Object.defineProperty(this, "pollingUrl", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "submissionId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "ongoingSubmissionId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-var PublishingStatus;
-(function (PublishingStatus) {
- PublishingStatus["INPROGRESS"] = "INPROGRESS";
- PublishingStatus["PUBLISHED"] = "PUBLISHED";
- PublishingStatus["FAILED"] = "FAILED";
- PublishingStatus["UNKNOWN"] = "UNKNOWN";
-})(PublishingStatus || (PublishingStatus = {}));
-class ModuleStatus {
- constructor() {
- Object.defineProperty(this, "isReady", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "ongoingSubmissionId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class SubmissionStatus {
- constructor() {
- Object.defineProperty(this, "publishingStatus", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "hasFailed", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class ListingAssetsResponse {
- constructor() {
- Object.defineProperty(this, "listingAssets", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class ImageSize {
- constructor() {
- Object.defineProperty(this, "width", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "height", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class ListingAsset {
- constructor() {
- Object.defineProperty(this, "language", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "storeLogos", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "screenshots", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class Screenshot {
- constructor() {
- Object.defineProperty(this, "id", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "assetUrl", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "imageSize", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class StoreLogo {
- constructor() {
- Object.defineProperty(this, "id", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "assetUrl", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "imageSize", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class StoreApis {
- constructor() {
- Object.defineProperty(this, "accessToken", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "productId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "sellerId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "tenantId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "clientId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "clientSecret", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- this.LoadState();
- }
- Delay(ms) {
- return new Promise((resolve) => setTimeout(resolve, ms));
- }
- GetAccessToken() {
- return __awaiter(this, void 0, void 0, function* () {
- const requestParameters = {
- grant_type: "client_credentials",
- client_id: this.clientId,
- client_secret: this.clientSecret,
- scope: StoreApis.scope,
- };
- const formBody = [];
- for (const property in requestParameters) {
- const encodedKey = encodeURIComponent(property);
- const encodedValue = encodeURIComponent(requestParameters[property]);
- formBody.push(encodedKey + "=" + encodedValue);
- }
- const dataString = formBody.join("\r\n&");
- const options = {
- host: StoreApis.microsoftOnlineLoginHost,
- path: `/${this.tenantId}${StoreApis.authOAuth2TokenSuffix}`,
- method: "POST",
- headers: {
- "Content-Type": "application/x-www-form-urlencoded",
- "Content-Length": dataString.length,
- },
- };
- return new Promise((resolve, reject) => {
- const req = https.request(options, (res) => {
- let responseString = "";
- res.on("data", (data) => {
- responseString += data;
- });
- res.on("end", function () {
- const responseObject = JSON.parse(responseString);
- if (responseObject.error)
- reject(responseObject);
- else
- resolve(responseObject.access_token);
- });
- });
- req.on("error", (e) => {
- console.error(e);
- reject(e);
- });
- req.write(dataString);
- req.end();
- });
- });
- }
- GetCurrentDraftSubmissionPackagesData() {
- return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/packages`);
- }
- GetCurrentDraftSubmissionMetadata(moduleName, listingLanguages) {
- return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/metadata/${moduleName}?languages=${listingLanguages}`);
- }
- UpdateCurrentDraftSubmissionMetadata(submissionMetadata) {
- return this.CreateStoreHttpRequest(JSON.stringify(submissionMetadata), "PUT", `/submission/v1/product/${this.productId}/metadata`);
- }
- UpdateStoreSubmissionPackages(submission) {
- return __awaiter(this, void 0, void 0, function* () {
- return this.CreateStoreHttpRequest(JSON.stringify(submission), "PUT", `/submission/v1/product/${this.productId}/packages`);
- });
- }
- CommitUpdateStoreSubmissionPackages() {
- return __awaiter(this, void 0, void 0, function* () {
- return this.CreateStoreHttpRequest("", "POST", `/submission/v1/product/${this.productId}/packages/commit`);
- });
- }
- GetModuleStatus() {
- return __awaiter(this, void 0, void 0, function* () {
- return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/status`);
- });
- }
- GetSubmissionStatus(submissionId) {
- return __awaiter(this, void 0, void 0, function* () {
- return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/submission/${submissionId}/status`);
- });
- }
- SubmitSubmission() {
- return __awaiter(this, void 0, void 0, function* () {
- return this.CreateStoreHttpRequest("", "POST", `/submission/v1/product/${this.productId}/submit`);
- });
- }
- GetCurrentDraftListingAssets(listingLanguages) {
- return __awaiter(this, void 0, void 0, function* () {
- return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/listings/assets?languages=${listingLanguages}`);
- });
- }
- CreateStoreHttpRequest(requestParameters, method, path) {
- return __awaiter(this, void 0, void 0, function* () {
- const options = {
- host: StoreApis.storeApiUrl,
- path: path,
- method: method,
- headers: {
- "Content-Type": "application/json",
- "Content-Length": requestParameters.length,
- Authorization: "Bearer " + this.accessToken,
- "X-Seller-Account-Id": this.sellerId,
- },
- };
- return new Promise((resolve, reject) => {
- const req = https.request(options, (res) => {
- if (res.statusCode == 404) {
- const error = new ResponseWrapper();
- error.isSuccess = false;
- error.errors = [];
- error.errors[0] = new Error();
- error.errors[0].message = "Not found";
- reject(error);
- return;
- }
- let responseString = "";
- res.on("data", (data) => {
- responseString += data;
- });
- res.on("end", function () {
- const responseObject = JSON.parse(responseString);
- resolve(responseObject);
- });
- });
- req.on("error", (e) => {
- console.error(e);
- reject(e);
- });
- req.write(requestParameters);
- req.end();
- });
- });
- }
- PollModuleStatus() {
- return __awaiter(this, void 0, void 0, function* () {
- let status = new ModuleStatus();
- status.isReady = false;
- while (!status.isReady) {
- const moduleStatus = yield this.GetModuleStatus();
- console.log(JSON.stringify(moduleStatus));
- status = moduleStatus.responseData;
- if (!moduleStatus.isSuccess) {
- const errorResponse = moduleStatus;
- if (errorResponse.statusCode == 401) {
- console.log(`Access token expired. Requesting new one. (message='${errorResponse.message}')`);
- yield this.InitAsync();
- status = new ModuleStatus();
- status.isReady = false;
- continue;
- }
- console.log("Error");
- break;
- }
- if (status.isReady) {
- console.log("Success!");
- return true;
- }
- else {
- if (moduleStatus.errors &&
- moduleStatus.errors.length > 0 &&
- moduleStatus.errors.find((e) => e.target != "packages" || e.code == "packageuploaderror")) {
- console.log(moduleStatus.errors);
- return false;
- }
- }
- console.log("Waiting 10 seconds.");
- yield this.Delay(10000);
- }
- return false;
- });
- }
- InitAsync() {
- return __awaiter(this, void 0, void 0, function* () {
- this.accessToken = yield this.GetAccessToken();
- });
- }
- GetExistingDraft(moduleName, listingLanguage) {
- return __awaiter(this, void 0, void 0, function* () {
- return new Promise((resolve, reject) => {
- if (moduleName &&
- moduleName.toLowerCase() != "availability" &&
- moduleName.toLowerCase() != "listings" &&
- moduleName.toLowerCase() != "properties") {
- reject("Module name must be 'availability', 'listings' or 'properties'");
- return;
- }
- (moduleName
- ? this.GetCurrentDraftSubmissionMetadata(moduleName, listingLanguage)
- : this.GetCurrentDraftSubmissionPackagesData())
- .then((currentDraftResponse) => {
- if (!currentDraftResponse.isSuccess) {
- reject(`Failed to get the existing draft. - ${JSON.stringify(currentDraftResponse, null, 2)}`);
- }
- else {
- resolve(JSON.stringify(currentDraftResponse.responseData));
- }
- })
- .catch((error) => {
- reject(`Failed to get the existing draft. - ${error.errors}`);
- });
- });
- });
- }
- PollSubmissionStatus(pollingSubmissionId) {
- return __awaiter(this, void 0, void 0, function* () {
- let status = new SubmissionStatus();
- status.hasFailed = false;
- // eslint-disable-next-line no-async-promise-executor
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
- while (!status.hasFailed) {
- const submissionStatus = yield this.GetSubmissionStatus(pollingSubmissionId);
- console.log(JSON.stringify(submissionStatus));
- status = submissionStatus.responseData;
- if (!submissionStatus.isSuccess || status.hasFailed) {
- const errorResponse = submissionStatus;
- if (errorResponse.statusCode == 401) {
- console.log(`Access token expired. Requesting new one. (message='${errorResponse.message}')`);
- yield this.InitAsync();
- status = new SubmissionStatus();
- status.hasFailed = false;
- continue;
- }
- console.log("Error");
- reject("Error");
- return;
- }
- if (status.publishingStatus == PublishingStatus.PUBLISHED ||
- status.publishingStatus == PublishingStatus.FAILED) {
- console.log(`PublishingStatus = ${status.publishingStatus}`);
- resolve(status.publishingStatus);
- return;
- }
- console.log("Waiting 10 seconds.");
- yield this.Delay(10000);
- }
- }));
- });
- }
- UpdateSubmissionMetadata(submissionMetadataString) {
- return __awaiter(this, void 0, void 0, function* () {
- if (!(yield this.PollModuleStatus())) {
- // Wait until all modules are in the ready state
- return Promise.reject("Failed to poll module status.");
- }
- const submissionMetadata = JSON.parse(submissionMetadataString);
- console.log(submissionMetadata);
- const updateSubmissionData = yield this.UpdateCurrentDraftSubmissionMetadata(submissionMetadata);
- console.log(JSON.stringify(updateSubmissionData));
- if (!updateSubmissionData.isSuccess) {
- return Promise.reject(`Failed to update submission metadata - ${JSON.stringify(updateSubmissionData.errors)}`);
- }
- if (!(yield this.PollModuleStatus())) {
- // Wait until all modules are in the ready state
- return Promise.reject("Failed to poll module status.");
- }
- return updateSubmissionData;
- });
- }
- UpdateProductPackages(updatedProductString) {
- return __awaiter(this, void 0, void 0, function* () {
- if (!(yield this.PollModuleStatus())) {
- // Wait until all modules are in the ready state
- return Promise.reject("Failed to poll module status.");
- }
- const updatedProductPackages = JSON.parse(updatedProductString);
- console.log(updatedProductPackages);
- const updateSubmissionData = yield this.UpdateStoreSubmissionPackages(updatedProductPackages);
- console.log(JSON.stringify(updateSubmissionData));
- if (!updateSubmissionData.isSuccess) {
- return Promise.reject(`Failed to update submission - ${JSON.stringify(updateSubmissionData.errors)}`);
- }
- console.log("Committing package changes...");
- const commitResult = yield this.CommitUpdateStoreSubmissionPackages();
- if (!commitResult.isSuccess) {
- return Promise.reject(`Failed to commit the updated submission - ${JSON.stringify(commitResult.errors)}`);
- }
- console.log(JSON.stringify(commitResult));
- if (!(yield this.PollModuleStatus())) {
- // Wait until all modules are in the ready state
- return Promise.reject("Failed to poll module status.");
- }
- return updateSubmissionData;
- });
- }
- PublishSubmission() {
- return __awaiter(this, void 0, void 0, function* () {
- const commitResult = yield this.CommitUpdateStoreSubmissionPackages();
- if (!commitResult.isSuccess) {
- return Promise.reject(`Failed to commit the updated submission - ${JSON.stringify(commitResult.errors)}`);
- }
- console.log(JSON.stringify(commitResult));
- if (!(yield this.PollModuleStatus())) {
- // Wait until all modules are in the ready state
- return Promise.reject("Failed to poll module status.");
- }
- let submissionId = null;
- const submitSubmissionResponse = yield this.SubmitSubmission();
- console.log(JSON.stringify(submitSubmissionResponse));
- if (submitSubmissionResponse.isSuccess) {
- if (submitSubmissionResponse.responseData.submissionId != null &&
- submitSubmissionResponse.responseData.submissionId.length > 0) {
- submissionId = submitSubmissionResponse.responseData.submissionId;
- }
- else if (submitSubmissionResponse.responseData.ongoingSubmissionId != null &&
- submitSubmissionResponse.responseData.ongoingSubmissionId.length > 0) {
- submissionId =
- submitSubmissionResponse.responseData.ongoingSubmissionId;
- }
- }
- return new Promise((resolve, reject) => {
- if (submissionId == null) {
- console.log("Failed to get submission ID");
- reject("Failed to get submission ID");
- }
- else {
- resolve(submissionId);
- }
- });
- });
- }
- GetExistingDraftListingAssets(listingLanguage) {
- return __awaiter(this, void 0, void 0, function* () {
- return new Promise((resolve, reject) => {
- this.GetCurrentDraftListingAssets(listingLanguage)
- .then((draftListingAssetsResponse) => {
- if (!draftListingAssetsResponse.isSuccess) {
- reject(`Failed to get the existing draft listing assets. - ${JSON.stringify(draftListingAssetsResponse, null, 2)}`);
- }
- else {
- resolve(JSON.stringify(draftListingAssetsResponse.responseData));
- }
- })
- .catch((error) => {
- reject(`Failed to get the existing draft listing assets. - ${error.errors}`);
- });
- });
- });
- }
- LoadState() {
- var _a, _b, _c, _d, _e, _f;
- this.productId = (_a = process.env[`${exports.EnvVariablePrefix}product_id`]) !== null && _a !== void 0 ? _a : "";
- this.sellerId = (_b = process.env[`${exports.EnvVariablePrefix}seller_id`]) !== null && _b !== void 0 ? _b : "";
- this.tenantId = (_c = process.env[`${exports.EnvVariablePrefix}tenant_id`]) !== null && _c !== void 0 ? _c : "";
- this.clientId = (_d = process.env[`${exports.EnvVariablePrefix}client_id`]) !== null && _d !== void 0 ? _d : "";
- this.clientSecret = (_e = process.env[`${exports.EnvVariablePrefix}client_secret`]) !== null && _e !== void 0 ? _e : "";
- this.accessToken = (_f = process.env[`${exports.EnvVariablePrefix}access_token`]) !== null && _f !== void 0 ? _f : "";
- }
-}
-exports.StoreApis = StoreApis;
-Object.defineProperty(StoreApis, "microsoftOnlineLoginHost", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: "login.microsoftonline.com"
-});
-Object.defineProperty(StoreApis, "authOAuth2TokenSuffix", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: "/oauth2/v2.0/token"
-});
-Object.defineProperty(StoreApis, "scope", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: "https://api.store.microsoft.com/.default"
-});
-Object.defineProperty(StoreApis, "storeApiUrl", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: "api.store.microsoft.com"
-});
+
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+};
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+exports.StoreApis = exports.EnvVariablePrefix = void 0;
+const https = __importStar(__nccwpck_require__(687));
+exports.EnvVariablePrefix = "MICROSOFT_STORE_ACTION_";
+class ResponseWrapper {
+ constructor() {
+ Object.defineProperty(this, "responseData", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "isSuccess", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "errors", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class ErrorResponse {
+ constructor() {
+ Object.defineProperty(this, "statusCode", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "message", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class Error {
+ constructor() {
+ Object.defineProperty(this, "code", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "message", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "target", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class SubmissionResponse {
+ constructor() {
+ Object.defineProperty(this, "pollingUrl", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "submissionId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "ongoingSubmissionId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+var PublishingStatus;
+(function (PublishingStatus) {
+ PublishingStatus["INPROGRESS"] = "INPROGRESS";
+ PublishingStatus["PUBLISHED"] = "PUBLISHED";
+ PublishingStatus["FAILED"] = "FAILED";
+ PublishingStatus["UNKNOWN"] = "UNKNOWN";
+})(PublishingStatus || (PublishingStatus = {}));
+class ModuleStatus {
+ constructor() {
+ Object.defineProperty(this, "isReady", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "ongoingSubmissionId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class SubmissionStatus {
+ constructor() {
+ Object.defineProperty(this, "publishingStatus", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "hasFailed", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class ListingAssetsResponse {
+ constructor() {
+ Object.defineProperty(this, "listingAssets", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class ImageSize {
+ constructor() {
+ Object.defineProperty(this, "width", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "height", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class ListingAsset {
+ constructor() {
+ Object.defineProperty(this, "language", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "storeLogos", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "screenshots", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class Screenshot {
+ constructor() {
+ Object.defineProperty(this, "id", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "assetUrl", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "imageSize", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class StoreLogo {
+ constructor() {
+ Object.defineProperty(this, "id", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "assetUrl", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "imageSize", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class StoreApis {
+ constructor() {
+ Object.defineProperty(this, "accessToken", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "productId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "sellerId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "tenantId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "clientId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "clientSecret", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "onlyOnReady", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ this.LoadState();
+ }
+ Delay(ms) {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+ }
+ GetAccessToken() {
+ return __awaiter(this, void 0, void 0, function* () {
+ const requestParameters = {
+ grant_type: "client_credentials",
+ client_id: this.clientId,
+ client_secret: this.clientSecret,
+ scope: StoreApis.scope,
+ };
+ const formBody = [];
+ for (const property in requestParameters) {
+ const encodedKey = encodeURIComponent(property);
+ const encodedValue = encodeURIComponent(requestParameters[property]);
+ formBody.push(encodedKey + "=" + encodedValue);
+ }
+ const dataString = formBody.join("\r\n&");
+ const options = {
+ host: StoreApis.microsoftOnlineLoginHost,
+ path: `/${this.tenantId}${StoreApis.authOAuth2TokenSuffix}`,
+ method: "POST",
+ headers: {
+ "Content-Type": "application/x-www-form-urlencoded",
+ "Content-Length": dataString.length,
+ },
+ };
+ return new Promise((resolve, reject) => {
+ const req = https.request(options, (res) => {
+ let responseString = "";
+ res.on("data", (data) => {
+ responseString += data;
+ });
+ res.on("end", function () {
+ const responseObject = JSON.parse(responseString);
+ if (responseObject.error)
+ reject(responseObject);
+ else
+ resolve(responseObject.access_token);
+ });
+ });
+ req.on("error", (e) => {
+ console.error(e);
+ reject(e);
+ });
+ req.write(dataString);
+ req.end();
+ });
+ });
+ }
+ GetCurrentDraftSubmissionPackagesData() {
+ return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/packages`);
+ }
+ GetCurrentDraftSubmissionMetadata(moduleName, listingLanguages) {
+ return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/metadata/${moduleName}?languages=${listingLanguages}`);
+ }
+ UpdateCurrentDraftSubmissionMetadata(submissionMetadata) {
+ return this.CreateStoreHttpRequest(JSON.stringify(submissionMetadata), "PUT", `/submission/v1/product/${this.productId}/metadata`);
+ }
+ UpdateStoreSubmissionPackages(submission) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.CreateStoreHttpRequest(JSON.stringify(submission), "PUT", `/submission/v1/product/${this.productId}/packages`);
+ });
+ }
+ CommitUpdateStoreSubmissionPackages() {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.CreateStoreHttpRequest("", "POST", `/submission/v1/product/${this.productId}/packages/commit`);
+ });
+ }
+ GetModuleStatus() {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/status`);
+ });
+ }
+ GetSubmissionStatus(submissionId) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/submission/${submissionId}/status`);
+ });
+ }
+ SubmitSubmission() {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.CreateStoreHttpRequest("", "POST", `/submission/v1/product/${this.productId}/submit`);
+ });
+ }
+ GetCurrentDraftListingAssets(listingLanguages) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/listings/assets?languages=${listingLanguages}`);
+ });
+ }
+ CreateStoreHttpRequest(requestParameters, method, path) {
+ return __awaiter(this, void 0, void 0, function* () {
+ const options = {
+ host: StoreApis.storeApiUrl,
+ path: path,
+ method: method,
+ headers: {
+ "Content-Type": "application/json",
+ "Content-Length": requestParameters.length,
+ Authorization: "Bearer " + this.accessToken,
+ "X-Seller-Account-Id": this.sellerId,
+ },
+ };
+ return new Promise((resolve, reject) => {
+ const req = https.request(options, (res) => {
+ if (res.statusCode == 404) {
+ const error = new ResponseWrapper();
+ error.isSuccess = false;
+ error.errors = [];
+ error.errors[0] = new Error();
+ error.errors[0].message = "Not found";
+ reject(error);
+ return;
+ }
+ let responseString = "";
+ res.on("data", (data) => {
+ responseString += data;
+ });
+ res.on("end", function () {
+ const responseObject = JSON.parse(responseString);
+ resolve(responseObject);
+ });
+ });
+ req.on("error", (e) => {
+ console.error(e);
+ reject(e);
+ });
+ req.write(requestParameters);
+ req.end();
+ });
+ });
+ }
+ PollModuleStatus() {
+ return __awaiter(this, void 0, void 0, function* () {
+ let status = new ModuleStatus();
+ status.isReady = false;
+ while (!status.isReady) {
+ const moduleStatus = yield this.GetModuleStatus();
+ console.log(JSON.stringify(moduleStatus));
+ status = moduleStatus.responseData;
+ if (!moduleStatus.isSuccess) {
+ const errorResponse = moduleStatus;
+ if (errorResponse.statusCode == 401) {
+ console.log(`Access token expired. Requesting new one. (message='${errorResponse.message}')`);
+ yield this.InitAsync();
+ status = new ModuleStatus();
+ status.isReady = false;
+ continue;
+ }
+ console.log("Error");
+ break;
+ }
+ if (status.isReady) {
+ console.log("Success!");
+ return true;
+ }
+ else {
+ if (moduleStatus.errors &&
+ moduleStatus.errors.length > 0 &&
+ moduleStatus.errors.find((e) => e.target != "packages" || e.code == "packageuploaderror")) {
+ console.log(moduleStatus.errors);
+ return false;
+ }
+ }
+ console.log("Waiting 10 seconds.");
+ yield this.Delay(10000);
+ }
+ return false;
+ });
+ }
+ InitAsync() {
+ return __awaiter(this, void 0, void 0, function* () {
+ this.accessToken = yield this.GetAccessToken();
+ });
+ }
+ IsReady() {
+ return __awaiter(this, void 0, void 0, function* () {
+ if (!this.onlyOnReady) {
+ return true;
+ }
+ const moduleStatus = yield this.GetModuleStatus();
+ return moduleStatus.responseData.isReady;
+ });
+ }
+ GetExistingDraft(moduleName, listingLanguage) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return new Promise((resolve, reject) => {
+ if (moduleName &&
+ moduleName.toLowerCase() != "availability" &&
+ moduleName.toLowerCase() != "listings" &&
+ moduleName.toLowerCase() != "properties") {
+ reject("Module name must be 'availability', 'listings' or 'properties'");
+ return;
+ }
+ (moduleName
+ ? this.GetCurrentDraftSubmissionMetadata(moduleName, listingLanguage)
+ : this.GetCurrentDraftSubmissionPackagesData())
+ .then((currentDraftResponse) => {
+ if (!currentDraftResponse.isSuccess) {
+ reject(`Failed to get the existing draft. - ${JSON.stringify(currentDraftResponse, null, 2)}`);
+ }
+ else {
+ resolve(JSON.stringify(currentDraftResponse.responseData));
+ }
+ })
+ .catch((error) => {
+ reject(`Failed to get the existing draft. - ${error.errors}`);
+ });
+ });
+ });
+ }
+ PollSubmissionStatus(pollingSubmissionId) {
+ return __awaiter(this, void 0, void 0, function* () {
+ let status = new SubmissionStatus();
+ status.hasFailed = false;
+ // eslint-disable-next-line no-async-promise-executor
+ return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
+ while (!status.hasFailed) {
+ const submissionStatus = yield this.GetSubmissionStatus(pollingSubmissionId);
+ console.log(JSON.stringify(submissionStatus));
+ status = submissionStatus.responseData;
+ if (!submissionStatus.isSuccess || status.hasFailed) {
+ const errorResponse = submissionStatus;
+ if (errorResponse.statusCode == 401) {
+ console.log(`Access token expired. Requesting new one. (message='${errorResponse.message}')`);
+ yield this.InitAsync();
+ status = new SubmissionStatus();
+ status.hasFailed = false;
+ continue;
+ }
+ console.log("Error");
+ reject("Error");
+ return;
+ }
+ if (status.publishingStatus == PublishingStatus.PUBLISHED ||
+ status.publishingStatus == PublishingStatus.FAILED) {
+ console.log(`PublishingStatus = ${status.publishingStatus}`);
+ resolve(status.publishingStatus);
+ return;
+ }
+ console.log("Waiting 10 seconds.");
+ yield this.Delay(10000);
+ }
+ }));
+ });
+ }
+ UpdateSubmissionMetadata(submissionMetadataString) {
+ return __awaiter(this, void 0, void 0, function* () {
+ if (!(yield this.PollModuleStatus())) {
+ // Wait until all modules are in the ready state
+ return Promise.reject("Failed to poll module status.");
+ }
+ const submissionMetadata = JSON.parse(submissionMetadataString);
+ console.log(submissionMetadata);
+ const updateSubmissionData = yield this.UpdateCurrentDraftSubmissionMetadata(submissionMetadata);
+ console.log(JSON.stringify(updateSubmissionData));
+ if (!updateSubmissionData.isSuccess) {
+ return Promise.reject(`Failed to update submission metadata - ${JSON.stringify(updateSubmissionData.errors)}`);
+ }
+ if (!(yield this.PollModuleStatus())) {
+ // Wait until all modules are in the ready state
+ return Promise.reject("Failed to poll module status.");
+ }
+ return updateSubmissionData;
+ });
+ }
+ UpdateProductPackages(updatedProductString) {
+ return __awaiter(this, void 0, void 0, function* () {
+ if (!(yield this.PollModuleStatus())) {
+ // Wait until all modules are in the ready state
+ return Promise.reject("Failed to poll module status.");
+ }
+ const updatedProductPackages = JSON.parse(updatedProductString);
+ console.log(updatedProductPackages);
+ const updateSubmissionData = yield this.UpdateStoreSubmissionPackages(updatedProductPackages);
+ console.log(JSON.stringify(updateSubmissionData));
+ if (!updateSubmissionData.isSuccess) {
+ return Promise.reject(`Failed to update submission - ${JSON.stringify(updateSubmissionData.errors)}`);
+ }
+ console.log("Committing package changes...");
+ const commitResult = yield this.CommitUpdateStoreSubmissionPackages();
+ if (!commitResult.isSuccess) {
+ return Promise.reject(`Failed to commit the updated submission - ${JSON.stringify(commitResult.errors)}`);
+ }
+ console.log(JSON.stringify(commitResult));
+ if (!(yield this.PollModuleStatus())) {
+ // Wait until all modules are in the ready state
+ return Promise.reject("Failed to poll module status.");
+ }
+ return updateSubmissionData;
+ });
+ }
+ PublishSubmission() {
+ return __awaiter(this, void 0, void 0, function* () {
+ const commitResult = yield this.CommitUpdateStoreSubmissionPackages();
+ if (!commitResult.isSuccess) {
+ return Promise.reject(`Failed to commit the updated submission - ${JSON.stringify(commitResult.errors)}`);
+ }
+ console.log(JSON.stringify(commitResult));
+ if (!(yield this.PollModuleStatus())) {
+ // Wait until all modules are in the ready state
+ return Promise.reject("Failed to poll module status.");
+ }
+ let submissionId = null;
+ const submitSubmissionResponse = yield this.SubmitSubmission();
+ console.log(JSON.stringify(submitSubmissionResponse));
+ if (submitSubmissionResponse.isSuccess) {
+ if (submitSubmissionResponse.responseData.submissionId != null &&
+ submitSubmissionResponse.responseData.submissionId.length > 0) {
+ submissionId = submitSubmissionResponse.responseData.submissionId;
+ }
+ else if (submitSubmissionResponse.responseData.ongoingSubmissionId != null &&
+ submitSubmissionResponse.responseData.ongoingSubmissionId.length > 0) {
+ submissionId =
+ submitSubmissionResponse.responseData.ongoingSubmissionId;
+ }
+ }
+ return new Promise((resolve, reject) => {
+ if (submissionId == null) {
+ console.log("Failed to get submission ID");
+ reject("Failed to get submission ID");
+ }
+ else {
+ resolve(submissionId);
+ }
+ });
+ });
+ }
+ GetExistingDraftListingAssets(listingLanguage) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return new Promise((resolve, reject) => {
+ this.GetCurrentDraftListingAssets(listingLanguage)
+ .then((draftListingAssetsResponse) => {
+ if (!draftListingAssetsResponse.isSuccess) {
+ reject(`Failed to get the existing draft listing assets. - ${JSON.stringify(draftListingAssetsResponse, null, 2)}`);
+ }
+ else {
+ resolve(JSON.stringify(draftListingAssetsResponse.responseData));
+ }
+ })
+ .catch((error) => {
+ reject(`Failed to get the existing draft listing assets. - ${error.errors}`);
+ });
+ });
+ });
+ }
+ LoadState() {
+ var _a, _b, _c, _d, _e, _f, _g;
+ this.productId = (_a = process.env[`${exports.EnvVariablePrefix}product_id`]) !== null && _a !== void 0 ? _a : "";
+ this.sellerId = (_b = process.env[`${exports.EnvVariablePrefix}seller_id`]) !== null && _b !== void 0 ? _b : "";
+ this.tenantId = (_c = process.env[`${exports.EnvVariablePrefix}tenant_id`]) !== null && _c !== void 0 ? _c : "";
+ this.clientId = (_d = process.env[`${exports.EnvVariablePrefix}client_id`]) !== null && _d !== void 0 ? _d : "";
+ this.clientSecret = (_e = process.env[`${exports.EnvVariablePrefix}client_secret`]) !== null && _e !== void 0 ? _e : "";
+ this.accessToken = (_f = process.env[`${exports.EnvVariablePrefix}access_token`]) !== null && _f !== void 0 ? _f : "";
+ const onlyOnReady = (_g = process.env[`${exports.EnvVariablePrefix}only-on-ready`]) !== null && _g !== void 0 ? _g : "false";
+ this.onlyOnReady = onlyOnReady === "true";
+ }
+}
+exports.StoreApis = StoreApis;
+Object.defineProperty(StoreApis, "microsoftOnlineLoginHost", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: "login.microsoftonline.com"
+});
+Object.defineProperty(StoreApis, "authOAuth2TokenSuffix", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: "/oauth2/v2.0/token"
+});
+Object.defineProperty(StoreApis, "scope", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: "https://api.store.microsoft.com/.default"
+});
+Object.defineProperty(StoreApis, "storeApiUrl", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: "api.store.microsoft.com"
+});
//# sourceMappingURL=store_apis.js.map
/***/ }),
@@ -930,6 +957,7 @@ const file_command_1 = __nccwpck_require__(717);
const utils_1 = __nccwpck_require__(278);
const os = __importStar(__nccwpck_require__(37));
const path = __importStar(__nccwpck_require__(17));
+const uuid_1 = __nccwpck_require__(974);
const oidc_utils_1 = __nccwpck_require__(41);
/**
* The code to exit an action
@@ -959,7 +987,14 @@ function exportVariable(name, val) {
process.env[name] = convertedVal;
const filePath = process.env['GITHUB_ENV'] || '';
if (filePath) {
- const delimiter = '_GitHubActionsFileCommandDelimeter_';
+ const delimiter = `ghadelimiter_${uuid_1.v4()}`;
+ // These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter.
+ if (name.includes(delimiter)) {
+ throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
+ }
+ if (convertedVal.includes(delimiter)) {
+ throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
+ }
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
file_command_1.issueCommand('ENV', commandValue);
}
@@ -1215,6 +1250,13 @@ Object.defineProperty(exports, "summary", ({ enumerable: true, get: function ()
*/
var summary_2 = __nccwpck_require__(327);
Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } }));
+/**
+ * Path exports
+ */
+var path_utils_1 = __nccwpck_require__(981);
+Object.defineProperty(exports, "toPosixPath", ({ enumerable: true, get: function () { return path_utils_1.toPosixPath; } }));
+Object.defineProperty(exports, "toWin32Path", ({ enumerable: true, get: function () { return path_utils_1.toWin32Path; } }));
+Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: function () { return path_utils_1.toPlatformPath; } }));
//# sourceMappingURL=core.js.map
/***/ }),
@@ -1347,8 +1389,73 @@ class OidcClient {
});
}
}
-exports.OidcClient = OidcClient;
-//# sourceMappingURL=oidc-utils.js.map
+exports.OidcClient = OidcClient;
+//# sourceMappingURL=oidc-utils.js.map
+
+/***/ }),
+
+/***/ 981:
+/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
+
+"use strict";
+
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0;
+const path = __importStar(__nccwpck_require__(17));
+/**
+ * toPosixPath converts the given path to the posix form. On Windows, \\ will be
+ * replaced with /.
+ *
+ * @param pth. Path to transform.
+ * @return string Posix path.
+ */
+function toPosixPath(pth) {
+ return pth.replace(/[\\]/g, '/');
+}
+exports.toPosixPath = toPosixPath;
+/**
+ * toWin32Path converts the given path to the win32 form. On Linux, / will be
+ * replaced with \\.
+ *
+ * @param pth. Path to transform.
+ * @return string Win32 path.
+ */
+function toWin32Path(pth) {
+ return pth.replace(/[/]/g, '\\');
+}
+exports.toWin32Path = toWin32Path;
+/**
+ * toPlatformPath converts the given path to a platform-specific path. It does
+ * this by replacing instances of / and \ with the platform-specific path
+ * separator.
+ *
+ * @param pth The path to platformize.
+ * @return string The platform-specific path.
+ */
+function toPlatformPath(pth) {
+ return pth.replace(/[/\\]/g, path.sep);
+}
+exports.toPlatformPath = toPlatformPath;
+//# sourceMappingURL=path-utils.js.map
/***/ }),
@@ -1588,104 +1695,750 @@ class Summary {
const element = this.wrap(allowedTag, text);
return this.addRaw(element).addEOL();
}
- /**
- * Adds an HTML thematic break (
) to the summary buffer
- *
- * @returns {Summary} summary instance
- */
- addSeparator() {
- const element = this.wrap('hr', null);
- return this.addRaw(element).addEOL();
+ /**
+ * Adds an HTML thematic break (
) to the summary buffer
+ *
+ * @returns {Summary} summary instance
+ */
+ addSeparator() {
+ const element = this.wrap('hr', null);
+ return this.addRaw(element).addEOL();
+ }
+ /**
+ * Adds an HTML line break (
) to the summary buffer
+ *
+ * @returns {Summary} summary instance
+ */
+ addBreak() {
+ const element = this.wrap('br', null);
+ return this.addRaw(element).addEOL();
+ }
+ /**
+ * Adds an HTML blockquote to the summary buffer
+ *
+ * @param {string} text quote text
+ * @param {string} cite (optional) citation url
+ *
+ * @returns {Summary} summary instance
+ */
+ addQuote(text, cite) {
+ const attrs = Object.assign({}, (cite && { cite }));
+ const element = this.wrap('blockquote', text, attrs);
+ return this.addRaw(element).addEOL();
+ }
+ /**
+ * Adds an HTML anchor tag to the summary buffer
+ *
+ * @param {string} text link text/content
+ * @param {string} href hyperlink
+ *
+ * @returns {Summary} summary instance
+ */
+ addLink(text, href) {
+ const element = this.wrap('a', text, { href });
+ return this.addRaw(element).addEOL();
+ }
+}
+const _summary = new Summary();
+/**
+ * @deprecated use `core.summary`
+ */
+exports.markdownSummary = _summary;
+exports.summary = _summary;
+//# sourceMappingURL=summary.js.map
+
+/***/ }),
+
+/***/ 278:
+/***/ ((__unused_webpack_module, exports) => {
+
+"use strict";
+
+// We use any as a valid input type
+/* eslint-disable @typescript-eslint/no-explicit-any */
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+exports.toCommandProperties = exports.toCommandValue = void 0;
+/**
+ * Sanitizes an input into a string so it can be passed into issueCommand safely
+ * @param input input to sanitize into a string
+ */
+function toCommandValue(input) {
+ if (input === null || input === undefined) {
+ return '';
+ }
+ else if (typeof input === 'string' || input instanceof String) {
+ return input;
+ }
+ return JSON.stringify(input);
+}
+exports.toCommandValue = toCommandValue;
+/**
+ *
+ * @param annotationProperties
+ * @returns The command properties to send with the actual annotation command
+ * See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
+ */
+function toCommandProperties(annotationProperties) {
+ if (!Object.keys(annotationProperties).length) {
+ return {};
+ }
+ return {
+ title: annotationProperties.title,
+ file: annotationProperties.file,
+ line: annotationProperties.startLine,
+ endLine: annotationProperties.endLine,
+ col: annotationProperties.startColumn,
+ endColumn: annotationProperties.endColumn
+ };
+}
+exports.toCommandProperties = toCommandProperties;
+//# sourceMappingURL=utils.js.map
+
+/***/ }),
+
+/***/ 974:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+Object.defineProperty(exports, "v1", ({
+ enumerable: true,
+ get: function () {
+ return _v.default;
+ }
+}));
+Object.defineProperty(exports, "v3", ({
+ enumerable: true,
+ get: function () {
+ return _v2.default;
+ }
+}));
+Object.defineProperty(exports, "v4", ({
+ enumerable: true,
+ get: function () {
+ return _v3.default;
+ }
+}));
+Object.defineProperty(exports, "v5", ({
+ enumerable: true,
+ get: function () {
+ return _v4.default;
+ }
+}));
+Object.defineProperty(exports, "NIL", ({
+ enumerable: true,
+ get: function () {
+ return _nil.default;
+ }
+}));
+Object.defineProperty(exports, "version", ({
+ enumerable: true,
+ get: function () {
+ return _version.default;
+ }
+}));
+Object.defineProperty(exports, "validate", ({
+ enumerable: true,
+ get: function () {
+ return _validate.default;
+ }
+}));
+Object.defineProperty(exports, "stringify", ({
+ enumerable: true,
+ get: function () {
+ return _stringify.default;
+ }
+}));
+Object.defineProperty(exports, "parse", ({
+ enumerable: true,
+ get: function () {
+ return _parse.default;
+ }
+}));
+
+var _v = _interopRequireDefault(__nccwpck_require__(595));
+
+var _v2 = _interopRequireDefault(__nccwpck_require__(993));
+
+var _v3 = _interopRequireDefault(__nccwpck_require__(472));
+
+var _v4 = _interopRequireDefault(__nccwpck_require__(217));
+
+var _nil = _interopRequireDefault(__nccwpck_require__(381));
+
+var _version = _interopRequireDefault(__nccwpck_require__(427));
+
+var _validate = _interopRequireDefault(__nccwpck_require__(609));
+
+var _stringify = _interopRequireDefault(__nccwpck_require__(458));
+
+var _parse = _interopRequireDefault(__nccwpck_require__(385));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/***/ }),
+
+/***/ 842:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+exports["default"] = void 0;
+
+var _crypto = _interopRequireDefault(__nccwpck_require__(113));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function md5(bytes) {
+ if (Array.isArray(bytes)) {
+ bytes = Buffer.from(bytes);
+ } else if (typeof bytes === 'string') {
+ bytes = Buffer.from(bytes, 'utf8');
+ }
+
+ return _crypto.default.createHash('md5').update(bytes).digest();
+}
+
+var _default = md5;
+exports["default"] = _default;
+
+/***/ }),
+
+/***/ 381:
+/***/ ((__unused_webpack_module, exports) => {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+exports["default"] = void 0;
+var _default = '00000000-0000-0000-0000-000000000000';
+exports["default"] = _default;
+
+/***/ }),
+
+/***/ 385:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+exports["default"] = void 0;
+
+var _validate = _interopRequireDefault(__nccwpck_require__(609));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function parse(uuid) {
+ if (!(0, _validate.default)(uuid)) {
+ throw TypeError('Invalid UUID');
+ }
+
+ let v;
+ const arr = new Uint8Array(16); // Parse ########-....-....-....-............
+
+ arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
+ arr[1] = v >>> 16 & 0xff;
+ arr[2] = v >>> 8 & 0xff;
+ arr[3] = v & 0xff; // Parse ........-####-....-....-............
+
+ arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
+ arr[5] = v & 0xff; // Parse ........-....-####-....-............
+
+ arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
+ arr[7] = v & 0xff; // Parse ........-....-....-####-............
+
+ arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
+ arr[9] = v & 0xff; // Parse ........-....-....-....-############
+ // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
+
+ arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
+ arr[11] = v / 0x100000000 & 0xff;
+ arr[12] = v >>> 24 & 0xff;
+ arr[13] = v >>> 16 & 0xff;
+ arr[14] = v >>> 8 & 0xff;
+ arr[15] = v & 0xff;
+ return arr;
+}
+
+var _default = parse;
+exports["default"] = _default;
+
+/***/ }),
+
+/***/ 230:
+/***/ ((__unused_webpack_module, exports) => {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+exports["default"] = void 0;
+var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
+exports["default"] = _default;
+
+/***/ }),
+
+/***/ 784:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+exports["default"] = rng;
+
+var _crypto = _interopRequireDefault(__nccwpck_require__(113));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate
+
+let poolPtr = rnds8Pool.length;
+
+function rng() {
+ if (poolPtr > rnds8Pool.length - 16) {
+ _crypto.default.randomFillSync(rnds8Pool);
+
+ poolPtr = 0;
+ }
+
+ return rnds8Pool.slice(poolPtr, poolPtr += 16);
+}
+
+/***/ }),
+
+/***/ 844:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+exports["default"] = void 0;
+
+var _crypto = _interopRequireDefault(__nccwpck_require__(113));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function sha1(bytes) {
+ if (Array.isArray(bytes)) {
+ bytes = Buffer.from(bytes);
+ } else if (typeof bytes === 'string') {
+ bytes = Buffer.from(bytes, 'utf8');
+ }
+
+ return _crypto.default.createHash('sha1').update(bytes).digest();
+}
+
+var _default = sha1;
+exports["default"] = _default;
+
+/***/ }),
+
+/***/ 458:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+exports["default"] = void 0;
+
+var _validate = _interopRequireDefault(__nccwpck_require__(609));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Convert array of 16 byte values to UUID string format of the form:
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
+ */
+const byteToHex = [];
+
+for (let i = 0; i < 256; ++i) {
+ byteToHex.push((i + 0x100).toString(16).substr(1));
+}
+
+function stringify(arr, offset = 0) {
+ // Note: Be careful editing this code! It's been tuned for performance
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
+ const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
+ // of the following:
+ // - One or more input array values don't map to a hex octet (leading to
+ // "undefined" in the uuid)
+ // - Invalid input values for the RFC `version` or `variant` fields
+
+ if (!(0, _validate.default)(uuid)) {
+ throw TypeError('Stringified UUID is invalid');
+ }
+
+ return uuid;
+}
+
+var _default = stringify;
+exports["default"] = _default;
+
+/***/ }),
+
+/***/ 595:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+exports["default"] = void 0;
+
+var _rng = _interopRequireDefault(__nccwpck_require__(784));
+
+var _stringify = _interopRequireDefault(__nccwpck_require__(458));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+// **`v1()` - Generate time-based UUID**
+//
+// Inspired by https://github.com/LiosK/UUID.js
+// and http://docs.python.org/library/uuid.html
+let _nodeId;
+
+let _clockseq; // Previous uuid creation time
+
+
+let _lastMSecs = 0;
+let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
+
+function v1(options, buf, offset) {
+ let i = buf && offset || 0;
+ const b = buf || new Array(16);
+ options = options || {};
+ let node = options.node || _nodeId;
+ let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
+ // specified. We do this lazily to minimize issues related to insufficient
+ // system entropy. See #189
+
+ if (node == null || clockseq == null) {
+ const seedBytes = options.random || (options.rng || _rng.default)();
+
+ if (node == null) {
+ // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
+ node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
+ }
+
+ if (clockseq == null) {
+ // Per 4.2.2, randomize (14 bit) clockseq
+ clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
}
- /**
- * Adds an HTML line break (
) to the summary buffer
- *
- * @returns {Summary} summary instance
- */
- addBreak() {
- const element = this.wrap('br', null);
- return this.addRaw(element).addEOL();
+ } // UUID timestamps are 100 nano-second units since the Gregorian epoch,
+ // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
+ // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
+ // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
+
+
+ let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
+ // cycle to simulate higher resolution clock
+
+ let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
+
+ const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
+
+ if (dt < 0 && options.clockseq === undefined) {
+ clockseq = clockseq + 1 & 0x3fff;
+ } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
+ // time interval
+
+
+ if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
+ nsecs = 0;
+ } // Per 4.2.1.2 Throw error if too many uuids are requested
+
+
+ if (nsecs >= 10000) {
+ throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
+ }
+
+ _lastMSecs = msecs;
+ _lastNSecs = nsecs;
+ _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
+
+ msecs += 12219292800000; // `time_low`
+
+ const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
+ b[i++] = tl >>> 24 & 0xff;
+ b[i++] = tl >>> 16 & 0xff;
+ b[i++] = tl >>> 8 & 0xff;
+ b[i++] = tl & 0xff; // `time_mid`
+
+ const tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
+ b[i++] = tmh >>> 8 & 0xff;
+ b[i++] = tmh & 0xff; // `time_high_and_version`
+
+ b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
+
+ b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
+
+ b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
+
+ b[i++] = clockseq & 0xff; // `node`
+
+ for (let n = 0; n < 6; ++n) {
+ b[i + n] = node[n];
+ }
+
+ return buf || (0, _stringify.default)(b);
+}
+
+var _default = v1;
+exports["default"] = _default;
+
+/***/ }),
+
+/***/ 993:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+exports["default"] = void 0;
+
+var _v = _interopRequireDefault(__nccwpck_require__(920));
+
+var _md = _interopRequireDefault(__nccwpck_require__(842));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+const v3 = (0, _v.default)('v3', 0x30, _md.default);
+var _default = v3;
+exports["default"] = _default;
+
+/***/ }),
+
+/***/ 920:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+exports["default"] = _default;
+exports.URL = exports.DNS = void 0;
+
+var _stringify = _interopRequireDefault(__nccwpck_require__(458));
+
+var _parse = _interopRequireDefault(__nccwpck_require__(385));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function stringToBytes(str) {
+ str = unescape(encodeURIComponent(str)); // UTF8 escape
+
+ const bytes = [];
+
+ for (let i = 0; i < str.length; ++i) {
+ bytes.push(str.charCodeAt(i));
+ }
+
+ return bytes;
+}
+
+const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
+exports.DNS = DNS;
+const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
+exports.URL = URL;
+
+function _default(name, version, hashfunc) {
+ function generateUUID(value, namespace, buf, offset) {
+ if (typeof value === 'string') {
+ value = stringToBytes(value);
}
- /**
- * Adds an HTML blockquote to the summary buffer
- *
- * @param {string} text quote text
- * @param {string} cite (optional) citation url
- *
- * @returns {Summary} summary instance
- */
- addQuote(text, cite) {
- const attrs = Object.assign({}, (cite && { cite }));
- const element = this.wrap('blockquote', text, attrs);
- return this.addRaw(element).addEOL();
+
+ if (typeof namespace === 'string') {
+ namespace = (0, _parse.default)(namespace);
}
- /**
- * Adds an HTML anchor tag to the summary buffer
- *
- * @param {string} text link text/content
- * @param {string} href hyperlink
- *
- * @returns {Summary} summary instance
- */
- addLink(text, href) {
- const element = this.wrap('a', text, { href });
- return this.addRaw(element).addEOL();
+
+ if (namespace.length !== 16) {
+ throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
+ } // Compute hash of namespace and value, Per 4.3
+ // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
+ // hashfunc([...namespace, ... value])`
+
+
+ let bytes = new Uint8Array(16 + value.length);
+ bytes.set(namespace);
+ bytes.set(value, namespace.length);
+ bytes = hashfunc(bytes);
+ bytes[6] = bytes[6] & 0x0f | version;
+ bytes[8] = bytes[8] & 0x3f | 0x80;
+
+ if (buf) {
+ offset = offset || 0;
+
+ for (let i = 0; i < 16; ++i) {
+ buf[offset + i] = bytes[i];
+ }
+
+ return buf;
}
+
+ return (0, _stringify.default)(bytes);
+ } // Function#name is not settable on some platforms (#270)
+
+
+ try {
+ generateUUID.name = name; // eslint-disable-next-line no-empty
+ } catch (err) {} // For CommonJS default export support
+
+
+ generateUUID.DNS = DNS;
+ generateUUID.URL = URL;
+ return generateUUID;
}
-const _summary = new Summary();
-/**
- * @deprecated use `core.summary`
- */
-exports.markdownSummary = _summary;
-exports.summary = _summary;
-//# sourceMappingURL=summary.js.map
/***/ }),
-/***/ 278:
-/***/ ((__unused_webpack_module, exports) => {
+/***/ 472:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
"use strict";
-// We use any as a valid input type
-/* eslint-disable @typescript-eslint/no-explicit-any */
-Object.defineProperty(exports, "__esModule", ({ value: true }));
-exports.toCommandProperties = exports.toCommandValue = void 0;
-/**
- * Sanitizes an input into a string so it can be passed into issueCommand safely
- * @param input input to sanitize into a string
- */
-function toCommandValue(input) {
- if (input === null || input === undefined) {
- return '';
- }
- else if (typeof input === 'string' || input instanceof String) {
- return input;
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+exports["default"] = void 0;
+
+var _rng = _interopRequireDefault(__nccwpck_require__(784));
+
+var _stringify = _interopRequireDefault(__nccwpck_require__(458));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function v4(options, buf, offset) {
+ options = options || {};
+
+ const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
+
+
+ rnds[6] = rnds[6] & 0x0f | 0x40;
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
+
+ if (buf) {
+ offset = offset || 0;
+
+ for (let i = 0; i < 16; ++i) {
+ buf[offset + i] = rnds[i];
}
- return JSON.stringify(input);
+
+ return buf;
+ }
+
+ return (0, _stringify.default)(rnds);
}
-exports.toCommandValue = toCommandValue;
-/**
- *
- * @param annotationProperties
- * @returns The command properties to send with the actual annotation command
- * See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
- */
-function toCommandProperties(annotationProperties) {
- if (!Object.keys(annotationProperties).length) {
- return {};
- }
- return {
- title: annotationProperties.title,
- file: annotationProperties.file,
- line: annotationProperties.startLine,
- endLine: annotationProperties.endLine,
- col: annotationProperties.startColumn,
- endColumn: annotationProperties.endColumn
- };
+
+var _default = v4;
+exports["default"] = _default;
+
+/***/ }),
+
+/***/ 217:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+exports["default"] = void 0;
+
+var _v = _interopRequireDefault(__nccwpck_require__(920));
+
+var _sha = _interopRequireDefault(__nccwpck_require__(844));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+const v5 = (0, _v.default)('v5', 0x50, _sha.default);
+var _default = v5;
+exports["default"] = _default;
+
+/***/ }),
+
+/***/ 609:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+exports["default"] = void 0;
+
+var _regex = _interopRequireDefault(__nccwpck_require__(230));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function validate(uuid) {
+ return typeof uuid === 'string' && _regex.default.test(uuid);
}
-exports.toCommandProperties = toCommandProperties;
-//# sourceMappingURL=utils.js.map
+
+var _default = validate;
+exports["default"] = _default;
+
+/***/ }),
+
+/***/ 427:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+exports["default"] = void 0;
+
+var _validate = _interopRequireDefault(__nccwpck_require__(609));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function version(uuid) {
+ if (!(0, _validate.default)(uuid)) {
+ throw TypeError('Invalid UUID');
+ }
+
+ return parseInt(uuid.substr(14, 1), 16);
+}
+
+var _default = version;
+exports["default"] = _default;
/***/ }),
@@ -2745,6 +3498,14 @@ module.exports = require("assert");
/***/ }),
+/***/ 113:
+/***/ ((module) => {
+
+"use strict";
+module.exports = require("crypto");
+
+/***/ }),
+
/***/ 361:
/***/ ((module) => {
diff --git a/lib/azure_devops_task.js b/lib/azure_devops_task.js
index 935ed91..4251422 100644
--- a/lib/azure_devops_task.js
+++ b/lib/azure_devops_task.js
@@ -1,85 +1,85 @@
-"use strict";
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const tl = require("azure-pipelines-task-lib/task");
-const store_apis_1 = require("./store_apis");
-(function main() {
- return __awaiter(this, void 0, void 0, function* () {
- const storeApis = new store_apis_1.StoreApis();
- try {
- const command = tl.getInput("command");
- switch (command) {
- case "configure": {
- storeApis.productId = tl.getInput("productId") || "";
- storeApis.sellerId = tl.getInput("sellerId") || "";
- storeApis.tenantId = tl.getInput("tenantId") || "";
- storeApis.clientId = tl.getInput("clientId") || "";
- storeApis.clientSecret = tl.getInput("clientSecret") || "";
- yield storeApis.InitAsync();
- tl.setVariable(`${store_apis_1.EnvVariablePrefix}product_id`, storeApis.productId, true, true);
- tl.setVariable(`${store_apis_1.EnvVariablePrefix}seller_id`, storeApis.sellerId, true, true);
- tl.setVariable(`${store_apis_1.EnvVariablePrefix}tenant_id`, storeApis.tenantId, true, true);
- tl.setVariable(`${store_apis_1.EnvVariablePrefix}client_id`, storeApis.clientId, true, true);
- tl.setVariable(`${store_apis_1.EnvVariablePrefix}client_secret`, storeApis.clientSecret, true, true);
- tl.setVariable(`${store_apis_1.EnvVariablePrefix}access_token`, storeApis.accessToken, true, true);
- break;
- }
- case "get": {
- const moduleName = tl.getInput("moduleName") || "";
- const listingLanguage = tl.getInput("listingLanguage") || "en";
- const draftSubmission = yield storeApis.GetExistingDraft(moduleName, listingLanguage);
- tl.setVariable("draftSubmission", draftSubmission.toString());
- break;
- }
- case "update": {
- const updatedMetadataString = tl.getInput("metadataUpdate");
- const updatedProductString = tl.getInput("productUpdate");
- if (!updatedMetadataString && !updatedProductString) {
- tl.setResult(tl.TaskResult.Failed, `Nothing to update. Both product-update and metadata-update are null.`);
- return;
- }
- if (updatedMetadataString) {
- const updateSubmissionMetadata = yield storeApis.UpdateSubmissionMetadata(updatedMetadataString);
- console.log(updateSubmissionMetadata);
- }
- if (updatedProductString) {
- const updateSubmissionData = yield storeApis.UpdateProductPackages(updatedProductString);
- console.log(updateSubmissionData);
- }
- break;
- }
- case "poll": {
- const pollingSubmissionId = tl.getInput("pollingSubmissionId");
- if (!pollingSubmissionId) {
- tl.setResult(tl.TaskResult.Failed, `pollingSubmissionId parameter cannot be empty.`);
- return;
- }
- const publishingStatus = yield storeApis.PollSubmissionStatus(pollingSubmissionId);
- tl.setVariable("submissionStatus", publishingStatus);
- break;
- }
- case "publish": {
- const submissionId = yield storeApis.PublishSubmission();
- tl.setVariable("pollingSubmissionId", submissionId);
- break;
- }
- default: {
- tl.setResult(tl.TaskResult.Failed, `Unknown command - ("${command}").`);
- break;
- }
- }
- }
- catch (error) {
- tl.setResult(tl.TaskResult.Failed, error);
- }
- });
-})();
+"use strict";
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+const tl = require("azure-pipelines-task-lib/task");
+const store_apis_1 = require("./store_apis");
+(function main() {
+ return __awaiter(this, void 0, void 0, function* () {
+ const storeApis = new store_apis_1.StoreApis();
+ try {
+ const command = tl.getInput("command");
+ switch (command) {
+ case "configure": {
+ storeApis.productId = tl.getInput("productId") || "";
+ storeApis.sellerId = tl.getInput("sellerId") || "";
+ storeApis.tenantId = tl.getInput("tenantId") || "";
+ storeApis.clientId = tl.getInput("clientId") || "";
+ storeApis.clientSecret = tl.getInput("clientSecret") || "";
+ yield storeApis.InitAsync();
+ tl.setVariable(`${store_apis_1.EnvVariablePrefix}product_id`, storeApis.productId, true, true);
+ tl.setVariable(`${store_apis_1.EnvVariablePrefix}seller_id`, storeApis.sellerId, true, true);
+ tl.setVariable(`${store_apis_1.EnvVariablePrefix}tenant_id`, storeApis.tenantId, true, true);
+ tl.setVariable(`${store_apis_1.EnvVariablePrefix}client_id`, storeApis.clientId, true, true);
+ tl.setVariable(`${store_apis_1.EnvVariablePrefix}client_secret`, storeApis.clientSecret, true, true);
+ tl.setVariable(`${store_apis_1.EnvVariablePrefix}access_token`, storeApis.accessToken, true, true);
+ break;
+ }
+ case "get": {
+ const moduleName = tl.getInput("moduleName") || "";
+ const listingLanguage = tl.getInput("listingLanguage") || "en";
+ const draftSubmission = yield storeApis.GetExistingDraft(moduleName, listingLanguage);
+ tl.setVariable("draftSubmission", draftSubmission.toString());
+ break;
+ }
+ case "update": {
+ const updatedMetadataString = tl.getInput("metadataUpdate");
+ const updatedProductString = tl.getInput("productUpdate");
+ if (!updatedMetadataString && !updatedProductString) {
+ tl.setResult(tl.TaskResult.Failed, `Nothing to update. Both product-update and metadata-update are null.`);
+ return;
+ }
+ if (updatedMetadataString) {
+ const updateSubmissionMetadata = yield storeApis.UpdateSubmissionMetadata(updatedMetadataString);
+ console.log(updateSubmissionMetadata);
+ }
+ if (updatedProductString) {
+ const updateSubmissionData = yield storeApis.UpdateProductPackages(updatedProductString);
+ console.log(updateSubmissionData);
+ }
+ break;
+ }
+ case "poll": {
+ const pollingSubmissionId = tl.getInput("pollingSubmissionId");
+ if (!pollingSubmissionId) {
+ tl.setResult(tl.TaskResult.Failed, `pollingSubmissionId parameter cannot be empty.`);
+ return;
+ }
+ const publishingStatus = yield storeApis.PollSubmissionStatus(pollingSubmissionId);
+ tl.setVariable("submissionStatus", publishingStatus);
+ break;
+ }
+ case "publish": {
+ const submissionId = yield storeApis.PublishSubmission();
+ tl.setVariable("pollingSubmissionId", submissionId);
+ break;
+ }
+ default: {
+ tl.setResult(tl.TaskResult.Failed, `Unknown command - ("${command}").`);
+ break;
+ }
+ }
+ }
+ catch (error) {
+ tl.setResult(tl.TaskResult.Failed, error);
+ }
+ });
+})();
//# sourceMappingURL=azure_devops_task.js.map
\ No newline at end of file
diff --git a/lib/github_action.js b/lib/github_action.js
index 21aed07..cbef0c5 100644
--- a/lib/github_action.js
+++ b/lib/github_action.js
@@ -1,114 +1,124 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
-}) : function(o, v) {
- o["default"] = v;
-});
-var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
-};
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const core = __importStar(require("@actions/core"));
-const store_apis_1 = require("./store_apis");
-(function main() {
- return __awaiter(this, void 0, void 0, function* () {
- const storeApis = new store_apis_1.StoreApis();
- try {
- const command = core.getInput("command");
- switch (command) {
- case "configure": {
- storeApis.productId = core.getInput("product-id");
- storeApis.sellerId = core.getInput("seller-id");
- storeApis.tenantId = core.getInput("tenant-id");
- storeApis.clientId = core.getInput("client-id");
- storeApis.clientSecret = core.getInput("client-secret");
- yield storeApis.InitAsync();
- core.exportVariable(`${store_apis_1.EnvVariablePrefix}product_id`, storeApis.productId);
- core.exportVariable(`${store_apis_1.EnvVariablePrefix}seller_id`, storeApis.sellerId);
- core.exportVariable(`${store_apis_1.EnvVariablePrefix}tenant_id`, storeApis.tenantId);
- core.exportVariable(`${store_apis_1.EnvVariablePrefix}client_id`, storeApis.clientId);
- core.exportVariable(`${store_apis_1.EnvVariablePrefix}client_secret`, storeApis.clientSecret);
- core.exportVariable(`${store_apis_1.EnvVariablePrefix}access_token`, storeApis.accessToken);
- core.setSecret(storeApis.productId);
- core.setSecret(storeApis.sellerId);
- core.setSecret(storeApis.tenantId);
- core.setSecret(storeApis.clientId);
- core.setSecret(storeApis.clientSecret);
- core.setSecret(storeApis.accessToken);
- break;
- }
- case "get": {
- const moduleName = core.getInput("module-name");
- const listingLanguage = core.getInput("listing-language");
- const draftSubmission = yield storeApis.GetExistingDraft(moduleName, listingLanguage);
- core.setOutput("draft-submission", draftSubmission);
- break;
- }
- case "update": {
- const updatedMetadataString = core.getInput("metadata-update");
- const updatedProductString = core.getInput("product-update");
- if (!updatedMetadataString && !updatedProductString) {
- core.setFailed(`Nothing to update. Both product-update and metadata-update are null.`);
- return;
- }
- if (updatedMetadataString) {
- const updateSubmissionMetadata = yield storeApis.UpdateSubmissionMetadata(updatedMetadataString);
- console.log(updateSubmissionMetadata);
- }
- if (updatedProductString) {
- const updateSubmissionData = yield storeApis.UpdateProductPackages(updatedProductString);
- console.log(updateSubmissionData);
- }
- break;
- }
- case "poll": {
- const pollingSubmissionId = core.getInput("polling-submission-id");
- if (!pollingSubmissionId) {
- core.setFailed(`polling-submission-id parameter cannot be empty.`);
- return;
- }
- const publishingStatus = yield storeApis.PollSubmissionStatus(pollingSubmissionId);
- core.setOutput("submission-status", publishingStatus);
- break;
- }
- case "publish": {
- const submissionId = yield storeApis.PublishSubmission();
- core.setOutput("polling-submission-id", submissionId);
- break;
- }
- default: {
- core.setFailed(`Unknown command - ("${command}").`);
- break;
- }
- }
- }
- catch (error) {
- core.setFailed(error);
- }
- });
-})();
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+const core = __importStar(require("@actions/core"));
+const store_apis_1 = require("./store_apis");
+(function main() {
+ return __awaiter(this, void 0, void 0, function* () {
+ const storeApis = new store_apis_1.StoreApis();
+ try {
+ const command = core.getInput("command");
+ switch (command) {
+ case "configure": {
+ storeApis.productId = core.getInput("product-id");
+ storeApis.sellerId = core.getInput("seller-id");
+ storeApis.tenantId = core.getInput("tenant-id");
+ storeApis.clientId = core.getInput("client-id");
+ storeApis.clientSecret = core.getInput("client-secret");
+ storeApis.onlyOnReady = core.getBooleanInput("only-on-ready");
+ yield storeApis.InitAsync();
+ core.exportVariable(`${store_apis_1.EnvVariablePrefix}product_id`, storeApis.productId);
+ core.exportVariable(`${store_apis_1.EnvVariablePrefix}seller_id`, storeApis.sellerId);
+ core.exportVariable(`${store_apis_1.EnvVariablePrefix}tenant_id`, storeApis.tenantId);
+ core.exportVariable(`${store_apis_1.EnvVariablePrefix}client_id`, storeApis.clientId);
+ core.exportVariable(`${store_apis_1.EnvVariablePrefix}client_secret`, storeApis.clientSecret);
+ core.exportVariable(`${store_apis_1.EnvVariablePrefix}access_token`, storeApis.accessToken);
+ core.exportVariable(`${store_apis_1.EnvVariablePrefix}only-on-ready`, storeApis.onlyOnReady);
+ core.setSecret(storeApis.productId);
+ core.setSecret(storeApis.sellerId);
+ core.setSecret(storeApis.tenantId);
+ core.setSecret(storeApis.clientId);
+ core.setSecret(storeApis.clientSecret);
+ core.setSecret(storeApis.accessToken);
+ break;
+ }
+ case "get": {
+ const moduleName = core.getInput("module-name");
+ const listingLanguage = core.getInput("listing-language");
+ const draftSubmission = yield storeApis.GetExistingDraft(moduleName, listingLanguage);
+ core.setOutput("draft-submission", draftSubmission);
+ break;
+ }
+ case "update": {
+ if (!(yield storeApis.IsReady())) {
+ core.notice(`Only on ready is set and module is not ready, skipping.`);
+ return;
+ }
+ const updatedMetadataString = core.getInput("metadata-update");
+ const updatedProductString = core.getInput("product-update");
+ if (!updatedMetadataString && !updatedProductString) {
+ core.setFailed(`Nothing to update. Both product-update and metadata-update are null.`);
+ return;
+ }
+ if (updatedMetadataString) {
+ const updateSubmissionMetadata = yield storeApis.UpdateSubmissionMetadata(updatedMetadataString);
+ console.log(updateSubmissionMetadata);
+ }
+ if (updatedProductString) {
+ const updateSubmissionData = yield storeApis.UpdateProductPackages(updatedProductString);
+ console.log(updateSubmissionData);
+ }
+ break;
+ }
+ case "poll": {
+ const pollingSubmissionId = core.getInput("polling-submission-id");
+ if (!pollingSubmissionId) {
+ core.setFailed(`polling-submission-id parameter cannot be empty.`);
+ return;
+ }
+ const publishingStatus = yield storeApis.PollSubmissionStatus(pollingSubmissionId);
+ core.setOutput("submission-status", publishingStatus);
+ break;
+ }
+ case "publish": {
+ if (!(yield storeApis.IsReady())) {
+ core.notice(`Only on ready is set and module is not ready, skipping`);
+ return;
+ }
+ const submissionId = yield storeApis.PublishSubmission();
+ core.setOutput("polling-submission-id", submissionId);
+ break;
+ }
+ default: {
+ core.setFailed(`Unknown command - ("${command}").`);
+ break;
+ }
+ }
+ }
+ catch (error) {
+ core.setFailed(error);
+ }
+ });
+})();
//# sourceMappingURL=github_action.js.map
\ No newline at end of file
diff --git a/lib/github_action.js.map b/lib/github_action.js.map
index ed260d0..d30ed6d 100644
--- a/lib/github_action.js.map
+++ b/lib/github_action.js.map
@@ -1 +1 @@
-{"version":3,"file":"github_action.js","sourceRoot":"","sources":["../src/github_action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AACtC,6CAA4D;AAE5D,CAAC,SAAe,IAAI;;QAClB,MAAM,SAAS,GAAG,IAAI,sBAAS,EAAE,CAAC;QAElC,IAAI;YACF,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YACzC,QAAQ,OAAO,EAAE;gBACf,KAAK,WAAW,CAAC,CAAC;oBAChB,SAAS,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;oBAClD,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;oBAChD,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;oBAChD,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;oBAChD,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,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AC,CAAC,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE;wBAChC,IAAI,CAAC,MAAM,CAAC,wDAAwD,CAAC,CAAC;wBACtE,OAAO;qBACR;oBACD,MAAM,YAAY,GAAG,MAAM,SAAS,CAAC,iBAAiB,EAAE,CAAC;oBACzD,IAAI,CAAC,SAAS,CAAC,uBAAuB,EAAE,YAAY,CAAC,CAAC;oBAEtD,MAAM;iBACP;gBAED,OAAO,CAAC,CAAC;oBACP,IAAI,CAAC,SAAS,CAAC,uBAAuB,OAAO,KAAK,CAAC,CAAC;oBAEpD,MAAM;iBACP;aACF;SACF;QAAC,OAAO,KAAc,EAAE;YACvB,IAAI,CAAC,SAAS,CAAC,KAAe,CAAC,CAAC;SACjC;IACH,CAAC;CAAA,CAAC,EAAE,CAAC"}
\ No newline at end of file
diff --git a/lib/store_apis.js b/lib/store_apis.js
index f50f629..b994be8 100644
--- a/lib/store_apis.js
+++ b/lib/store_apis.js
@@ -1,662 +1,679 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
-}) : function(o, v) {
- o["default"] = v;
-});
-var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
-};
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.StoreApis = exports.EnvVariablePrefix = void 0;
-const https = __importStar(require("https"));
-exports.EnvVariablePrefix = "MICROSOFT_STORE_ACTION_";
-class ResponseWrapper {
- constructor() {
- Object.defineProperty(this, "responseData", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "isSuccess", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "errors", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class ErrorResponse {
- constructor() {
- Object.defineProperty(this, "statusCode", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "message", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class Error {
- constructor() {
- Object.defineProperty(this, "code", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "message", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "target", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class SubmissionResponse {
- constructor() {
- Object.defineProperty(this, "pollingUrl", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "submissionId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "ongoingSubmissionId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-var PublishingStatus;
-(function (PublishingStatus) {
- PublishingStatus["INPROGRESS"] = "INPROGRESS";
- PublishingStatus["PUBLISHED"] = "PUBLISHED";
- PublishingStatus["FAILED"] = "FAILED";
- PublishingStatus["UNKNOWN"] = "UNKNOWN";
-})(PublishingStatus || (PublishingStatus = {}));
-class ModuleStatus {
- constructor() {
- Object.defineProperty(this, "isReady", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "ongoingSubmissionId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class SubmissionStatus {
- constructor() {
- Object.defineProperty(this, "publishingStatus", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "hasFailed", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class ListingAssetsResponse {
- constructor() {
- Object.defineProperty(this, "listingAssets", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class ImageSize {
- constructor() {
- Object.defineProperty(this, "width", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "height", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class ListingAsset {
- constructor() {
- Object.defineProperty(this, "language", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "storeLogos", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "screenshots", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class Screenshot {
- constructor() {
- Object.defineProperty(this, "id", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "assetUrl", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "imageSize", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class StoreLogo {
- constructor() {
- Object.defineProperty(this, "id", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "assetUrl", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "imageSize", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class StoreApis {
- constructor() {
- Object.defineProperty(this, "accessToken", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "productId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "sellerId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "tenantId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "clientId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "clientSecret", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- this.LoadState();
- }
- Delay(ms) {
- return new Promise((resolve) => setTimeout(resolve, ms));
- }
- GetAccessToken() {
- return __awaiter(this, void 0, void 0, function* () {
- const requestParameters = {
- grant_type: "client_credentials",
- client_id: this.clientId,
- client_secret: this.clientSecret,
- scope: StoreApis.scope,
- };
- const formBody = [];
- for (const property in requestParameters) {
- const encodedKey = encodeURIComponent(property);
- const encodedValue = encodeURIComponent(requestParameters[property]);
- formBody.push(encodedKey + "=" + encodedValue);
- }
- const dataString = formBody.join("\r\n&");
- const options = {
- host: StoreApis.microsoftOnlineLoginHost,
- path: `/${this.tenantId}${StoreApis.authOAuth2TokenSuffix}`,
- method: "POST",
- headers: {
- "Content-Type": "application/x-www-form-urlencoded",
- "Content-Length": dataString.length,
- },
- };
- return new Promise((resolve, reject) => {
- const req = https.request(options, (res) => {
- let responseString = "";
- res.on("data", (data) => {
- responseString += data;
- });
- res.on("end", function () {
- const responseObject = JSON.parse(responseString);
- if (responseObject.error)
- reject(responseObject);
- else
- resolve(responseObject.access_token);
- });
- });
- req.on("error", (e) => {
- console.error(e);
- reject(e);
- });
- req.write(dataString);
- req.end();
- });
- });
- }
- GetCurrentDraftSubmissionPackagesData() {
- return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/packages`);
- }
- GetCurrentDraftSubmissionMetadata(moduleName, listingLanguages) {
- return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/metadata/${moduleName}?languages=${listingLanguages}`);
- }
- UpdateCurrentDraftSubmissionMetadata(submissionMetadata) {
- return this.CreateStoreHttpRequest(JSON.stringify(submissionMetadata), "PUT", `/submission/v1/product/${this.productId}/metadata`);
- }
- UpdateStoreSubmissionPackages(submission) {
- return __awaiter(this, void 0, void 0, function* () {
- return this.CreateStoreHttpRequest(JSON.stringify(submission), "PUT", `/submission/v1/product/${this.productId}/packages`);
- });
- }
- CommitUpdateStoreSubmissionPackages() {
- return __awaiter(this, void 0, void 0, function* () {
- return this.CreateStoreHttpRequest("", "POST", `/submission/v1/product/${this.productId}/packages/commit`);
- });
- }
- GetModuleStatus() {
- return __awaiter(this, void 0, void 0, function* () {
- return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/status`);
- });
- }
- GetSubmissionStatus(submissionId) {
- return __awaiter(this, void 0, void 0, function* () {
- return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/submission/${submissionId}/status`);
- });
- }
- SubmitSubmission() {
- return __awaiter(this, void 0, void 0, function* () {
- return this.CreateStoreHttpRequest("", "POST", `/submission/v1/product/${this.productId}/submit`);
- });
- }
- GetCurrentDraftListingAssets(listingLanguages) {
- return __awaiter(this, void 0, void 0, function* () {
- return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/listings/assets?languages=${listingLanguages}`);
- });
- }
- CreateStoreHttpRequest(requestParameters, method, path) {
- return __awaiter(this, void 0, void 0, function* () {
- const options = {
- host: StoreApis.storeApiUrl,
- path: path,
- method: method,
- headers: {
- "Content-Type": "application/json",
- "Content-Length": requestParameters.length,
- Authorization: "Bearer " + this.accessToken,
- "X-Seller-Account-Id": this.sellerId,
- },
- };
- return new Promise((resolve, reject) => {
- const req = https.request(options, (res) => {
- if (res.statusCode == 404) {
- const error = new ResponseWrapper();
- error.isSuccess = false;
- error.errors = [];
- error.errors[0] = new Error();
- error.errors[0].message = "Not found";
- reject(error);
- return;
- }
- let responseString = "";
- res.on("data", (data) => {
- responseString += data;
- });
- res.on("end", function () {
- const responseObject = JSON.parse(responseString);
- resolve(responseObject);
- });
- });
- req.on("error", (e) => {
- console.error(e);
- reject(e);
- });
- req.write(requestParameters);
- req.end();
- });
- });
- }
- PollModuleStatus() {
- return __awaiter(this, void 0, void 0, function* () {
- let status = new ModuleStatus();
- status.isReady = false;
- while (!status.isReady) {
- const moduleStatus = yield this.GetModuleStatus();
- console.log(JSON.stringify(moduleStatus));
- status = moduleStatus.responseData;
- if (!moduleStatus.isSuccess) {
- const errorResponse = moduleStatus;
- if (errorResponse.statusCode == 401) {
- console.log(`Access token expired. Requesting new one. (message='${errorResponse.message}')`);
- yield this.InitAsync();
- status = new ModuleStatus();
- status.isReady = false;
- continue;
- }
- console.log("Error");
- break;
- }
- if (status.isReady) {
- console.log("Success!");
- return true;
- }
- else {
- if (moduleStatus.errors &&
- moduleStatus.errors.length > 0 &&
- moduleStatus.errors.find((e) => e.target != "packages" || e.code == "packageuploaderror")) {
- console.log(moduleStatus.errors);
- return false;
- }
- }
- console.log("Waiting 10 seconds.");
- yield this.Delay(10000);
- }
- return false;
- });
- }
- InitAsync() {
- return __awaiter(this, void 0, void 0, function* () {
- this.accessToken = yield this.GetAccessToken();
- });
- }
- GetExistingDraft(moduleName, listingLanguage) {
- return __awaiter(this, void 0, void 0, function* () {
- return new Promise((resolve, reject) => {
- if (moduleName &&
- moduleName.toLowerCase() != "availability" &&
- moduleName.toLowerCase() != "listings" &&
- moduleName.toLowerCase() != "properties") {
- reject("Module name must be 'availability', 'listings' or 'properties'");
- return;
- }
- (moduleName
- ? this.GetCurrentDraftSubmissionMetadata(moduleName, listingLanguage)
- : this.GetCurrentDraftSubmissionPackagesData())
- .then((currentDraftResponse) => {
- if (!currentDraftResponse.isSuccess) {
- reject(`Failed to get the existing draft. - ${JSON.stringify(currentDraftResponse, null, 2)}`);
- }
- else {
- resolve(JSON.stringify(currentDraftResponse.responseData));
- }
- })
- .catch((error) => {
- reject(`Failed to get the existing draft. - ${error.errors}`);
- });
- });
- });
- }
- PollSubmissionStatus(pollingSubmissionId) {
- return __awaiter(this, void 0, void 0, function* () {
- let status = new SubmissionStatus();
- status.hasFailed = false;
- // eslint-disable-next-line no-async-promise-executor
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
- while (!status.hasFailed) {
- const submissionStatus = yield this.GetSubmissionStatus(pollingSubmissionId);
- console.log(JSON.stringify(submissionStatus));
- status = submissionStatus.responseData;
- if (!submissionStatus.isSuccess || status.hasFailed) {
- const errorResponse = submissionStatus;
- if (errorResponse.statusCode == 401) {
- console.log(`Access token expired. Requesting new one. (message='${errorResponse.message}')`);
- yield this.InitAsync();
- status = new SubmissionStatus();
- status.hasFailed = false;
- continue;
- }
- console.log("Error");
- reject("Error");
- return;
- }
- if (status.publishingStatus == PublishingStatus.PUBLISHED ||
- status.publishingStatus == PublishingStatus.FAILED) {
- console.log(`PublishingStatus = ${status.publishingStatus}`);
- resolve(status.publishingStatus);
- return;
- }
- console.log("Waiting 10 seconds.");
- yield this.Delay(10000);
- }
- }));
- });
- }
- UpdateSubmissionMetadata(submissionMetadataString) {
- return __awaiter(this, void 0, void 0, function* () {
- if (!(yield this.PollModuleStatus())) {
- // Wait until all modules are in the ready state
- return Promise.reject("Failed to poll module status.");
- }
- const submissionMetadata = JSON.parse(submissionMetadataString);
- console.log(submissionMetadata);
- const updateSubmissionData = yield this.UpdateCurrentDraftSubmissionMetadata(submissionMetadata);
- console.log(JSON.stringify(updateSubmissionData));
- if (!updateSubmissionData.isSuccess) {
- return Promise.reject(`Failed to update submission metadata - ${JSON.stringify(updateSubmissionData.errors)}`);
- }
- if (!(yield this.PollModuleStatus())) {
- // Wait until all modules are in the ready state
- return Promise.reject("Failed to poll module status.");
- }
- return updateSubmissionData;
- });
- }
- UpdateProductPackages(updatedProductString) {
- return __awaiter(this, void 0, void 0, function* () {
- if (!(yield this.PollModuleStatus())) {
- // Wait until all modules are in the ready state
- return Promise.reject("Failed to poll module status.");
- }
- const updatedProductPackages = JSON.parse(updatedProductString);
- console.log(updatedProductPackages);
- const updateSubmissionData = yield this.UpdateStoreSubmissionPackages(updatedProductPackages);
- console.log(JSON.stringify(updateSubmissionData));
- if (!updateSubmissionData.isSuccess) {
- return Promise.reject(`Failed to update submission - ${JSON.stringify(updateSubmissionData.errors)}`);
- }
- console.log("Committing package changes...");
- const commitResult = yield this.CommitUpdateStoreSubmissionPackages();
- if (!commitResult.isSuccess) {
- return Promise.reject(`Failed to commit the updated submission - ${JSON.stringify(commitResult.errors)}`);
- }
- console.log(JSON.stringify(commitResult));
- if (!(yield this.PollModuleStatus())) {
- // Wait until all modules are in the ready state
- return Promise.reject("Failed to poll module status.");
- }
- return updateSubmissionData;
- });
- }
- PublishSubmission() {
- return __awaiter(this, void 0, void 0, function* () {
- const commitResult = yield this.CommitUpdateStoreSubmissionPackages();
- if (!commitResult.isSuccess) {
- return Promise.reject(`Failed to commit the updated submission - ${JSON.stringify(commitResult.errors)}`);
- }
- console.log(JSON.stringify(commitResult));
- if (!(yield this.PollModuleStatus())) {
- // Wait until all modules are in the ready state
- return Promise.reject("Failed to poll module status.");
- }
- let submissionId = null;
- const submitSubmissionResponse = yield this.SubmitSubmission();
- console.log(JSON.stringify(submitSubmissionResponse));
- if (submitSubmissionResponse.isSuccess) {
- if (submitSubmissionResponse.responseData.submissionId != null &&
- submitSubmissionResponse.responseData.submissionId.length > 0) {
- submissionId = submitSubmissionResponse.responseData.submissionId;
- }
- else if (submitSubmissionResponse.responseData.ongoingSubmissionId != null &&
- submitSubmissionResponse.responseData.ongoingSubmissionId.length > 0) {
- submissionId =
- submitSubmissionResponse.responseData.ongoingSubmissionId;
- }
- }
- return new Promise((resolve, reject) => {
- if (submissionId == null) {
- console.log("Failed to get submission ID");
- reject("Failed to get submission ID");
- }
- else {
- resolve(submissionId);
- }
- });
- });
- }
- GetExistingDraftListingAssets(listingLanguage) {
- return __awaiter(this, void 0, void 0, function* () {
- return new Promise((resolve, reject) => {
- this.GetCurrentDraftListingAssets(listingLanguage)
- .then((draftListingAssetsResponse) => {
- if (!draftListingAssetsResponse.isSuccess) {
- reject(`Failed to get the existing draft listing assets. - ${JSON.stringify(draftListingAssetsResponse, null, 2)}`);
- }
- else {
- resolve(JSON.stringify(draftListingAssetsResponse.responseData));
- }
- })
- .catch((error) => {
- reject(`Failed to get the existing draft listing assets. - ${error.errors}`);
- });
- });
- });
- }
- LoadState() {
- var _a, _b, _c, _d, _e, _f;
- this.productId = (_a = process.env[`${exports.EnvVariablePrefix}product_id`]) !== null && _a !== void 0 ? _a : "";
- this.sellerId = (_b = process.env[`${exports.EnvVariablePrefix}seller_id`]) !== null && _b !== void 0 ? _b : "";
- this.tenantId = (_c = process.env[`${exports.EnvVariablePrefix}tenant_id`]) !== null && _c !== void 0 ? _c : "";
- this.clientId = (_d = process.env[`${exports.EnvVariablePrefix}client_id`]) !== null && _d !== void 0 ? _d : "";
- this.clientSecret = (_e = process.env[`${exports.EnvVariablePrefix}client_secret`]) !== null && _e !== void 0 ? _e : "";
- this.accessToken = (_f = process.env[`${exports.EnvVariablePrefix}access_token`]) !== null && _f !== void 0 ? _f : "";
- }
-}
-exports.StoreApis = StoreApis;
-Object.defineProperty(StoreApis, "microsoftOnlineLoginHost", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: "login.microsoftonline.com"
-});
-Object.defineProperty(StoreApis, "authOAuth2TokenSuffix", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: "/oauth2/v2.0/token"
-});
-Object.defineProperty(StoreApis, "scope", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: "https://api.store.microsoft.com/.default"
-});
-Object.defineProperty(StoreApis, "storeApiUrl", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: "api.store.microsoft.com"
-});
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.StoreApis = exports.EnvVariablePrefix = void 0;
+const https = __importStar(require("https"));
+exports.EnvVariablePrefix = "MICROSOFT_STORE_ACTION_";
+class ResponseWrapper {
+ constructor() {
+ Object.defineProperty(this, "responseData", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "isSuccess", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "errors", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class ErrorResponse {
+ constructor() {
+ Object.defineProperty(this, "statusCode", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "message", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class Error {
+ constructor() {
+ Object.defineProperty(this, "code", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "message", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "target", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class SubmissionResponse {
+ constructor() {
+ Object.defineProperty(this, "pollingUrl", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "submissionId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "ongoingSubmissionId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+var PublishingStatus;
+(function (PublishingStatus) {
+ PublishingStatus["INPROGRESS"] = "INPROGRESS";
+ PublishingStatus["PUBLISHED"] = "PUBLISHED";
+ PublishingStatus["FAILED"] = "FAILED";
+ PublishingStatus["UNKNOWN"] = "UNKNOWN";
+})(PublishingStatus || (PublishingStatus = {}));
+class ModuleStatus {
+ constructor() {
+ Object.defineProperty(this, "isReady", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "ongoingSubmissionId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class SubmissionStatus {
+ constructor() {
+ Object.defineProperty(this, "publishingStatus", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "hasFailed", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class ListingAssetsResponse {
+ constructor() {
+ Object.defineProperty(this, "listingAssets", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class ImageSize {
+ constructor() {
+ Object.defineProperty(this, "width", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "height", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class ListingAsset {
+ constructor() {
+ Object.defineProperty(this, "language", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "storeLogos", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "screenshots", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class Screenshot {
+ constructor() {
+ Object.defineProperty(this, "id", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "assetUrl", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "imageSize", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class StoreLogo {
+ constructor() {
+ Object.defineProperty(this, "id", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "assetUrl", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "imageSize", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class StoreApis {
+ constructor() {
+ Object.defineProperty(this, "accessToken", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "productId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "sellerId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "tenantId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "clientId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "clientSecret", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "onlyOnReady", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ this.LoadState();
+ }
+ Delay(ms) {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+ }
+ GetAccessToken() {
+ return __awaiter(this, void 0, void 0, function* () {
+ const requestParameters = {
+ grant_type: "client_credentials",
+ client_id: this.clientId,
+ client_secret: this.clientSecret,
+ scope: StoreApis.scope,
+ };
+ const formBody = [];
+ for (const property in requestParameters) {
+ const encodedKey = encodeURIComponent(property);
+ const encodedValue = encodeURIComponent(requestParameters[property]);
+ formBody.push(encodedKey + "=" + encodedValue);
+ }
+ const dataString = formBody.join("\r\n&");
+ const options = {
+ host: StoreApis.microsoftOnlineLoginHost,
+ path: `/${this.tenantId}${StoreApis.authOAuth2TokenSuffix}`,
+ method: "POST",
+ headers: {
+ "Content-Type": "application/x-www-form-urlencoded",
+ "Content-Length": dataString.length,
+ },
+ };
+ return new Promise((resolve, reject) => {
+ const req = https.request(options, (res) => {
+ let responseString = "";
+ res.on("data", (data) => {
+ responseString += data;
+ });
+ res.on("end", function () {
+ const responseObject = JSON.parse(responseString);
+ if (responseObject.error)
+ reject(responseObject);
+ else
+ resolve(responseObject.access_token);
+ });
+ });
+ req.on("error", (e) => {
+ console.error(e);
+ reject(e);
+ });
+ req.write(dataString);
+ req.end();
+ });
+ });
+ }
+ GetCurrentDraftSubmissionPackagesData() {
+ return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/packages`);
+ }
+ GetCurrentDraftSubmissionMetadata(moduleName, listingLanguages) {
+ return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/metadata/${moduleName}?languages=${listingLanguages}`);
+ }
+ UpdateCurrentDraftSubmissionMetadata(submissionMetadata) {
+ return this.CreateStoreHttpRequest(JSON.stringify(submissionMetadata), "PUT", `/submission/v1/product/${this.productId}/metadata`);
+ }
+ UpdateStoreSubmissionPackages(submission) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.CreateStoreHttpRequest(JSON.stringify(submission), "PUT", `/submission/v1/product/${this.productId}/packages`);
+ });
+ }
+ CommitUpdateStoreSubmissionPackages() {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.CreateStoreHttpRequest("", "POST", `/submission/v1/product/${this.productId}/packages/commit`);
+ });
+ }
+ GetModuleStatus() {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/status`);
+ });
+ }
+ GetSubmissionStatus(submissionId) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/submission/${submissionId}/status`);
+ });
+ }
+ SubmitSubmission() {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.CreateStoreHttpRequest("", "POST", `/submission/v1/product/${this.productId}/submit`);
+ });
+ }
+ GetCurrentDraftListingAssets(listingLanguages) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/listings/assets?languages=${listingLanguages}`);
+ });
+ }
+ CreateStoreHttpRequest(requestParameters, method, path) {
+ return __awaiter(this, void 0, void 0, function* () {
+ const options = {
+ host: StoreApis.storeApiUrl,
+ path: path,
+ method: method,
+ headers: {
+ "Content-Type": "application/json",
+ "Content-Length": requestParameters.length,
+ Authorization: "Bearer " + this.accessToken,
+ "X-Seller-Account-Id": this.sellerId,
+ },
+ };
+ return new Promise((resolve, reject) => {
+ const req = https.request(options, (res) => {
+ if (res.statusCode == 404) {
+ const error = new ResponseWrapper();
+ error.isSuccess = false;
+ error.errors = [];
+ error.errors[0] = new Error();
+ error.errors[0].message = "Not found";
+ reject(error);
+ return;
+ }
+ let responseString = "";
+ res.on("data", (data) => {
+ responseString += data;
+ });
+ res.on("end", function () {
+ const responseObject = JSON.parse(responseString);
+ resolve(responseObject);
+ });
+ });
+ req.on("error", (e) => {
+ console.error(e);
+ reject(e);
+ });
+ req.write(requestParameters);
+ req.end();
+ });
+ });
+ }
+ PollModuleStatus() {
+ return __awaiter(this, void 0, void 0, function* () {
+ let status = new ModuleStatus();
+ status.isReady = false;
+ while (!status.isReady) {
+ const moduleStatus = yield this.GetModuleStatus();
+ console.log(JSON.stringify(moduleStatus));
+ status = moduleStatus.responseData;
+ if (!moduleStatus.isSuccess) {
+ const errorResponse = moduleStatus;
+ if (errorResponse.statusCode == 401) {
+ console.log(`Access token expired. Requesting new one. (message='${errorResponse.message}')`);
+ yield this.InitAsync();
+ status = new ModuleStatus();
+ status.isReady = false;
+ continue;
+ }
+ console.log("Error");
+ break;
+ }
+ if (status.isReady) {
+ console.log("Success!");
+ return true;
+ }
+ else {
+ if (moduleStatus.errors &&
+ moduleStatus.errors.length > 0 &&
+ moduleStatus.errors.find((e) => e.target != "packages" || e.code == "packageuploaderror")) {
+ console.log(moduleStatus.errors);
+ return false;
+ }
+ }
+ console.log("Waiting 10 seconds.");
+ yield this.Delay(10000);
+ }
+ return false;
+ });
+ }
+ InitAsync() {
+ return __awaiter(this, void 0, void 0, function* () {
+ this.accessToken = yield this.GetAccessToken();
+ });
+ }
+ IsReady() {
+ return __awaiter(this, void 0, void 0, function* () {
+ if (!this.onlyOnReady) {
+ return true;
+ }
+ const moduleStatus = yield this.GetModuleStatus();
+ return moduleStatus.responseData.isReady;
+ });
+ }
+ GetExistingDraft(moduleName, listingLanguage) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return new Promise((resolve, reject) => {
+ if (moduleName &&
+ moduleName.toLowerCase() != "availability" &&
+ moduleName.toLowerCase() != "listings" &&
+ moduleName.toLowerCase() != "properties") {
+ reject("Module name must be 'availability', 'listings' or 'properties'");
+ return;
+ }
+ (moduleName
+ ? this.GetCurrentDraftSubmissionMetadata(moduleName, listingLanguage)
+ : this.GetCurrentDraftSubmissionPackagesData())
+ .then((currentDraftResponse) => {
+ if (!currentDraftResponse.isSuccess) {
+ reject(`Failed to get the existing draft. - ${JSON.stringify(currentDraftResponse, null, 2)}`);
+ }
+ else {
+ resolve(JSON.stringify(currentDraftResponse.responseData));
+ }
+ })
+ .catch((error) => {
+ reject(`Failed to get the existing draft. - ${error.errors}`);
+ });
+ });
+ });
+ }
+ PollSubmissionStatus(pollingSubmissionId) {
+ return __awaiter(this, void 0, void 0, function* () {
+ let status = new SubmissionStatus();
+ status.hasFailed = false;
+ // eslint-disable-next-line no-async-promise-executor
+ return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
+ while (!status.hasFailed) {
+ const submissionStatus = yield this.GetSubmissionStatus(pollingSubmissionId);
+ console.log(JSON.stringify(submissionStatus));
+ status = submissionStatus.responseData;
+ if (!submissionStatus.isSuccess || status.hasFailed) {
+ const errorResponse = submissionStatus;
+ if (errorResponse.statusCode == 401) {
+ console.log(`Access token expired. Requesting new one. (message='${errorResponse.message}')`);
+ yield this.InitAsync();
+ status = new SubmissionStatus();
+ status.hasFailed = false;
+ continue;
+ }
+ console.log("Error");
+ reject("Error");
+ return;
+ }
+ if (status.publishingStatus == PublishingStatus.PUBLISHED ||
+ status.publishingStatus == PublishingStatus.FAILED) {
+ console.log(`PublishingStatus = ${status.publishingStatus}`);
+ resolve(status.publishingStatus);
+ return;
+ }
+ console.log("Waiting 10 seconds.");
+ yield this.Delay(10000);
+ }
+ }));
+ });
+ }
+ UpdateSubmissionMetadata(submissionMetadataString) {
+ return __awaiter(this, void 0, void 0, function* () {
+ if (!(yield this.PollModuleStatus())) {
+ // Wait until all modules are in the ready state
+ return Promise.reject("Failed to poll module status.");
+ }
+ const submissionMetadata = JSON.parse(submissionMetadataString);
+ console.log(submissionMetadata);
+ const updateSubmissionData = yield this.UpdateCurrentDraftSubmissionMetadata(submissionMetadata);
+ console.log(JSON.stringify(updateSubmissionData));
+ if (!updateSubmissionData.isSuccess) {
+ return Promise.reject(`Failed to update submission metadata - ${JSON.stringify(updateSubmissionData.errors)}`);
+ }
+ if (!(yield this.PollModuleStatus())) {
+ // Wait until all modules are in the ready state
+ return Promise.reject("Failed to poll module status.");
+ }
+ return updateSubmissionData;
+ });
+ }
+ UpdateProductPackages(updatedProductString) {
+ return __awaiter(this, void 0, void 0, function* () {
+ if (!(yield this.PollModuleStatus())) {
+ // Wait until all modules are in the ready state
+ return Promise.reject("Failed to poll module status.");
+ }
+ const updatedProductPackages = JSON.parse(updatedProductString);
+ console.log(updatedProductPackages);
+ const updateSubmissionData = yield this.UpdateStoreSubmissionPackages(updatedProductPackages);
+ console.log(JSON.stringify(updateSubmissionData));
+ if (!updateSubmissionData.isSuccess) {
+ return Promise.reject(`Failed to update submission - ${JSON.stringify(updateSubmissionData.errors)}`);
+ }
+ console.log("Committing package changes...");
+ const commitResult = yield this.CommitUpdateStoreSubmissionPackages();
+ if (!commitResult.isSuccess) {
+ return Promise.reject(`Failed to commit the updated submission - ${JSON.stringify(commitResult.errors)}`);
+ }
+ console.log(JSON.stringify(commitResult));
+ if (!(yield this.PollModuleStatus())) {
+ // Wait until all modules are in the ready state
+ return Promise.reject("Failed to poll module status.");
+ }
+ return updateSubmissionData;
+ });
+ }
+ PublishSubmission() {
+ return __awaiter(this, void 0, void 0, function* () {
+ const commitResult = yield this.CommitUpdateStoreSubmissionPackages();
+ if (!commitResult.isSuccess) {
+ return Promise.reject(`Failed to commit the updated submission - ${JSON.stringify(commitResult.errors)}`);
+ }
+ console.log(JSON.stringify(commitResult));
+ if (!(yield this.PollModuleStatus())) {
+ // Wait until all modules are in the ready state
+ return Promise.reject("Failed to poll module status.");
+ }
+ let submissionId = null;
+ const submitSubmissionResponse = yield this.SubmitSubmission();
+ console.log(JSON.stringify(submitSubmissionResponse));
+ if (submitSubmissionResponse.isSuccess) {
+ if (submitSubmissionResponse.responseData.submissionId != null &&
+ submitSubmissionResponse.responseData.submissionId.length > 0) {
+ submissionId = submitSubmissionResponse.responseData.submissionId;
+ }
+ else if (submitSubmissionResponse.responseData.ongoingSubmissionId != null &&
+ submitSubmissionResponse.responseData.ongoingSubmissionId.length > 0) {
+ submissionId =
+ submitSubmissionResponse.responseData.ongoingSubmissionId;
+ }
+ }
+ return new Promise((resolve, reject) => {
+ if (submissionId == null) {
+ console.log("Failed to get submission ID");
+ reject("Failed to get submission ID");
+ }
+ else {
+ resolve(submissionId);
+ }
+ });
+ });
+ }
+ GetExistingDraftListingAssets(listingLanguage) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return new Promise((resolve, reject) => {
+ this.GetCurrentDraftListingAssets(listingLanguage)
+ .then((draftListingAssetsResponse) => {
+ if (!draftListingAssetsResponse.isSuccess) {
+ reject(`Failed to get the existing draft listing assets. - ${JSON.stringify(draftListingAssetsResponse, null, 2)}`);
+ }
+ else {
+ resolve(JSON.stringify(draftListingAssetsResponse.responseData));
+ }
+ })
+ .catch((error) => {
+ reject(`Failed to get the existing draft listing assets. - ${error.errors}`);
+ });
+ });
+ });
+ }
+ LoadState() {
+ var _a, _b, _c, _d, _e, _f, _g;
+ this.productId = (_a = process.env[`${exports.EnvVariablePrefix}product_id`]) !== null && _a !== void 0 ? _a : "";
+ this.sellerId = (_b = process.env[`${exports.EnvVariablePrefix}seller_id`]) !== null && _b !== void 0 ? _b : "";
+ this.tenantId = (_c = process.env[`${exports.EnvVariablePrefix}tenant_id`]) !== null && _c !== void 0 ? _c : "";
+ this.clientId = (_d = process.env[`${exports.EnvVariablePrefix}client_id`]) !== null && _d !== void 0 ? _d : "";
+ this.clientSecret = (_e = process.env[`${exports.EnvVariablePrefix}client_secret`]) !== null && _e !== void 0 ? _e : "";
+ this.accessToken = (_f = process.env[`${exports.EnvVariablePrefix}access_token`]) !== null && _f !== void 0 ? _f : "";
+ const onlyOnReady = (_g = process.env[`${exports.EnvVariablePrefix}only-on-ready`]) !== null && _g !== void 0 ? _g : "false";
+ this.onlyOnReady = onlyOnReady === "true";
+ }
+}
+exports.StoreApis = StoreApis;
+Object.defineProperty(StoreApis, "microsoftOnlineLoginHost", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: "login.microsoftonline.com"
+});
+Object.defineProperty(StoreApis, "authOAuth2TokenSuffix", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: "/oauth2/v2.0/token"
+});
+Object.defineProperty(StoreApis, "scope", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: "https://api.store.microsoft.com/.default"
+});
+Object.defineProperty(StoreApis, "storeApiUrl", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: "api.store.microsoft.com"
+});
//# sourceMappingURL=store_apis.js.map
\ No newline at end of file
diff --git a/lib/store_apis.js.map b/lib/store_apis.js.map
index 34b281a..6949fe4 100644
--- a/lib/store_apis.js.map
+++ b/lib/store_apis.js.map
@@ -1 +1 @@
-{"version":3,"file":"store_apis.js","sourceRoot":"","sources":["../src/store_apis.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAElB,QAAA,iBAAiB,GAAG,yBAAyB,CAAC;AAE3D,MAAM,eAAe;IAArB;QACE;;;;;WAAgB;QAChB;;;;;WAAmB;QACnB;;;;;WAAgB;IAClB,CAAC;CAAA;AAED,MAAM,aAAa;IAAnB;QACE;;;;;WAAmB;QACnB;;;;;WAAgB;IAClB,CAAC;CAAA;AAED,MAAM,KAAK;IAAX;QACE;;;;;WAAa;QACb;;;;;WAAgB;QAChB;;;;;WAAe;IACjB,CAAC;CAAA;AAED,MAAM,kBAAkB;IAAxB;QACE;;;;;WAAmB;QAC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yBAAiB,eAAe,CAAC,mCAAI,OAAO,CAAC;QAChF,IAAI,CAAC,WAAW,GAAG,WAAW,KAAK,MAAM,CAAC;IAC5C,CAAC;;AAjgBH,8BAkgBC;AAjgBC;;;;WACE,2BAA2B;GAAC;AAC9B;;;;WAAgD,oBAAoB;GAAC;AACrE;;;;WAAgC,0CAA0C;GAAC;AAC3E;;;;WAAsC,yBAAyB;GAAC"}
\ No newline at end of file
diff --git a/src/github_action.ts b/src/github_action.ts
index 2c769e7..ca4bc5a 100644
--- a/src/github_action.ts
+++ b/src/github_action.ts
@@ -13,6 +13,7 @@ import { StoreApis, EnvVariablePrefix } from "./store_apis";
storeApis.tenantId = core.getInput("tenant-id");
storeApis.clientId = core.getInput("client-id");
storeApis.clientSecret = core.getInput("client-secret");
+ storeApis.onlyOnReady = core.getBooleanInput("only-on-ready");
await storeApis.InitAsync();
@@ -40,6 +41,10 @@ import { StoreApis, EnvVariablePrefix } from "./store_apis";
`${EnvVariablePrefix}access_token`,
storeApis.accessToken
);
+ core.exportVariable(
+ `${EnvVariablePrefix}only-on-ready`,
+ storeApis.onlyOnReady
+ );
core.setSecret(storeApis.productId);
core.setSecret(storeApis.sellerId);
core.setSecret(storeApis.tenantId);
@@ -63,6 +68,10 @@ import { StoreApis, EnvVariablePrefix } from "./store_apis";
}
case "update": {
+ if (!(await storeApis.IsReady())) {
+ core.notice(`Only on ready is set and module is not ready, skipping.`);
+ return;
+ }
const updatedMetadataString = core.getInput("metadata-update");
const updatedProductString = core.getInput("product-update");
if (!updatedMetadataString && !updatedProductString) {
@@ -105,6 +114,10 @@ import { StoreApis, EnvVariablePrefix } from "./store_apis";
}
case "publish": {
+ if (!(await storeApis.IsReady())) {
+ core.notice(`Only on ready is set and module is not ready, skipping`);
+ return;
+ }
const submissionId = await storeApis.PublishSubmission();
core.setOutput("polling-submission-id", submissionId);
diff --git a/src/store_apis.ts b/src/store_apis.ts
index 70aed8d..d042cd1 100644
--- a/src/store_apis.ts
+++ b/src/store_apis.ts
@@ -86,6 +86,7 @@ export class StoreApis {
public tenantId: string;
public clientId: string;
public clientSecret: string;
+ public onlyOnReady: boolean;
private Delay(ms: number): Promise {
return new Promise((resolve) => setTimeout(resolve, ms));
@@ -331,6 +332,15 @@ export class StoreApis {
this.accessToken = await this.GetAccessToken();
}
+ public async IsReady(): Promise {
+ if (!this.onlyOnReady) {
+ return true;
+ }
+
+ const moduleStatus = await this.GetModuleStatus();
+ return moduleStatus.responseData.isReady;
+ }
+
public async GetExistingDraft(
moduleName: string,
listingLanguage: string
@@ -570,5 +580,7 @@ export class StoreApis {
this.clientId = process.env[`${EnvVariablePrefix}client_id`] ?? "";
this.clientSecret = process.env[`${EnvVariablePrefix}client_secret`] ?? "";
this.accessToken = process.env[`${EnvVariablePrefix}access_token`] ?? "";
+ const onlyOnReady = process.env[`${EnvVariablePrefix}only-on-ready`] ?? "false";
+ this.onlyOnReady = onlyOnReady === "true";
}
}
diff --git a/submission-task/index.js b/submission-task/index.js
index 8246c4e..9e0e450 100644
--- a/submission-task/index.js
+++ b/submission-task/index.js
@@ -5,90 +5,90 @@
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
-
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-Object.defineProperty(exports, "__esModule", ({ value: true }));
-const tl = __nccwpck_require__(347);
-const store_apis_1 = __nccwpck_require__(7605);
-(function main() {
- return __awaiter(this, void 0, void 0, function* () {
- const storeApis = new store_apis_1.StoreApis();
- try {
- const command = tl.getInput("command");
- switch (command) {
- case "configure": {
- storeApis.productId = tl.getInput("productId") || "";
- storeApis.sellerId = tl.getInput("sellerId") || "";
- storeApis.tenantId = tl.getInput("tenantId") || "";
- storeApis.clientId = tl.getInput("clientId") || "";
- storeApis.clientSecret = tl.getInput("clientSecret") || "";
- yield storeApis.InitAsync();
- tl.setVariable(`${store_apis_1.EnvVariablePrefix}product_id`, storeApis.productId, true, true);
- tl.setVariable(`${store_apis_1.EnvVariablePrefix}seller_id`, storeApis.sellerId, true, true);
- tl.setVariable(`${store_apis_1.EnvVariablePrefix}tenant_id`, storeApis.tenantId, true, true);
- tl.setVariable(`${store_apis_1.EnvVariablePrefix}client_id`, storeApis.clientId, true, true);
- tl.setVariable(`${store_apis_1.EnvVariablePrefix}client_secret`, storeApis.clientSecret, true, true);
- tl.setVariable(`${store_apis_1.EnvVariablePrefix}access_token`, storeApis.accessToken, true, true);
- break;
- }
- case "get": {
- const moduleName = tl.getInput("moduleName") || "";
- const listingLanguage = tl.getInput("listingLanguage") || "en";
- const draftSubmission = yield storeApis.GetExistingDraft(moduleName, listingLanguage);
- tl.setVariable("draftSubmission", draftSubmission.toString());
- break;
- }
- case "update": {
- const updatedMetadataString = tl.getInput("metadataUpdate");
- const updatedProductString = tl.getInput("productUpdate");
- if (!updatedMetadataString && !updatedProductString) {
- tl.setResult(tl.TaskResult.Failed, `Nothing to update. Both product-update and metadata-update are null.`);
- return;
- }
- if (updatedMetadataString) {
- const updateSubmissionMetadata = yield storeApis.UpdateSubmissionMetadata(updatedMetadataString);
- console.log(updateSubmissionMetadata);
- }
- if (updatedProductString) {
- const updateSubmissionData = yield storeApis.UpdateProductPackages(updatedProductString);
- console.log(updateSubmissionData);
- }
- break;
- }
- case "poll": {
- const pollingSubmissionId = tl.getInput("pollingSubmissionId");
- if (!pollingSubmissionId) {
- tl.setResult(tl.TaskResult.Failed, `pollingSubmissionId parameter cannot be empty.`);
- return;
- }
- const publishingStatus = yield storeApis.PollSubmissionStatus(pollingSubmissionId);
- tl.setVariable("submissionStatus", publishingStatus);
- break;
- }
- case "publish": {
- const submissionId = yield storeApis.PublishSubmission();
- tl.setVariable("pollingSubmissionId", submissionId);
- break;
- }
- default: {
- tl.setResult(tl.TaskResult.Failed, `Unknown command - ("${command}").`);
- break;
- }
- }
- }
- catch (error) {
- tl.setResult(tl.TaskResult.Failed, error);
- }
- });
-})();
+
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+};
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+const tl = __nccwpck_require__(347);
+const store_apis_1 = __nccwpck_require__(7605);
+(function main() {
+ return __awaiter(this, void 0, void 0, function* () {
+ const storeApis = new store_apis_1.StoreApis();
+ try {
+ const command = tl.getInput("command");
+ switch (command) {
+ case "configure": {
+ storeApis.productId = tl.getInput("productId") || "";
+ storeApis.sellerId = tl.getInput("sellerId") || "";
+ storeApis.tenantId = tl.getInput("tenantId") || "";
+ storeApis.clientId = tl.getInput("clientId") || "";
+ storeApis.clientSecret = tl.getInput("clientSecret") || "";
+ yield storeApis.InitAsync();
+ tl.setVariable(`${store_apis_1.EnvVariablePrefix}product_id`, storeApis.productId, true, true);
+ tl.setVariable(`${store_apis_1.EnvVariablePrefix}seller_id`, storeApis.sellerId, true, true);
+ tl.setVariable(`${store_apis_1.EnvVariablePrefix}tenant_id`, storeApis.tenantId, true, true);
+ tl.setVariable(`${store_apis_1.EnvVariablePrefix}client_id`, storeApis.clientId, true, true);
+ tl.setVariable(`${store_apis_1.EnvVariablePrefix}client_secret`, storeApis.clientSecret, true, true);
+ tl.setVariable(`${store_apis_1.EnvVariablePrefix}access_token`, storeApis.accessToken, true, true);
+ break;
+ }
+ case "get": {
+ const moduleName = tl.getInput("moduleName") || "";
+ const listingLanguage = tl.getInput("listingLanguage") || "en";
+ const draftSubmission = yield storeApis.GetExistingDraft(moduleName, listingLanguage);
+ tl.setVariable("draftSubmission", draftSubmission.toString());
+ break;
+ }
+ case "update": {
+ const updatedMetadataString = tl.getInput("metadataUpdate");
+ const updatedProductString = tl.getInput("productUpdate");
+ if (!updatedMetadataString && !updatedProductString) {
+ tl.setResult(tl.TaskResult.Failed, `Nothing to update. Both product-update and metadata-update are null.`);
+ return;
+ }
+ if (updatedMetadataString) {
+ const updateSubmissionMetadata = yield storeApis.UpdateSubmissionMetadata(updatedMetadataString);
+ console.log(updateSubmissionMetadata);
+ }
+ if (updatedProductString) {
+ const updateSubmissionData = yield storeApis.UpdateProductPackages(updatedProductString);
+ console.log(updateSubmissionData);
+ }
+ break;
+ }
+ case "poll": {
+ const pollingSubmissionId = tl.getInput("pollingSubmissionId");
+ if (!pollingSubmissionId) {
+ tl.setResult(tl.TaskResult.Failed, `pollingSubmissionId parameter cannot be empty.`);
+ return;
+ }
+ const publishingStatus = yield storeApis.PollSubmissionStatus(pollingSubmissionId);
+ tl.setVariable("submissionStatus", publishingStatus);
+ break;
+ }
+ case "publish": {
+ const submissionId = yield storeApis.PublishSubmission();
+ tl.setVariable("pollingSubmissionId", submissionId);
+ break;
+ }
+ default: {
+ tl.setResult(tl.TaskResult.Failed, `Unknown command - ("${command}").`);
+ break;
+ }
+ }
+ }
+ catch (error) {
+ tl.setResult(tl.TaskResult.Failed, error);
+ }
+ });
+})();
//# sourceMappingURL=azure_devops_task.js.map
/***/ }),
@@ -97,667 +97,684 @@ const store_apis_1 = __nccwpck_require__(7605);
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
-
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
-}) : function(o, v) {
- o["default"] = v;
-});
-var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
-};
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-Object.defineProperty(exports, "__esModule", ({ value: true }));
-exports.StoreApis = exports.EnvVariablePrefix = void 0;
-const https = __importStar(__nccwpck_require__(5687));
-exports.EnvVariablePrefix = "MICROSOFT_STORE_ACTION_";
-class ResponseWrapper {
- constructor() {
- Object.defineProperty(this, "responseData", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "isSuccess", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "errors", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class ErrorResponse {
- constructor() {
- Object.defineProperty(this, "statusCode", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "message", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class Error {
- constructor() {
- Object.defineProperty(this, "code", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "message", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "target", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class SubmissionResponse {
- constructor() {
- Object.defineProperty(this, "pollingUrl", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "submissionId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "ongoingSubmissionId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-var PublishingStatus;
-(function (PublishingStatus) {
- PublishingStatus["INPROGRESS"] = "INPROGRESS";
- PublishingStatus["PUBLISHED"] = "PUBLISHED";
- PublishingStatus["FAILED"] = "FAILED";
- PublishingStatus["UNKNOWN"] = "UNKNOWN";
-})(PublishingStatus || (PublishingStatus = {}));
-class ModuleStatus {
- constructor() {
- Object.defineProperty(this, "isReady", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "ongoingSubmissionId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class SubmissionStatus {
- constructor() {
- Object.defineProperty(this, "publishingStatus", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "hasFailed", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class ListingAssetsResponse {
- constructor() {
- Object.defineProperty(this, "listingAssets", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class ImageSize {
- constructor() {
- Object.defineProperty(this, "width", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "height", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class ListingAsset {
- constructor() {
- Object.defineProperty(this, "language", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "storeLogos", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "screenshots", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class Screenshot {
- constructor() {
- Object.defineProperty(this, "id", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "assetUrl", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "imageSize", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class StoreLogo {
- constructor() {
- Object.defineProperty(this, "id", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "assetUrl", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "imageSize", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- }
-}
-class StoreApis {
- constructor() {
- Object.defineProperty(this, "accessToken", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "productId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "sellerId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "tenantId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "clientId", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- Object.defineProperty(this, "clientSecret", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: void 0
- });
- this.LoadState();
- }
- Delay(ms) {
- return new Promise((resolve) => setTimeout(resolve, ms));
- }
- GetAccessToken() {
- return __awaiter(this, void 0, void 0, function* () {
- const requestParameters = {
- grant_type: "client_credentials",
- client_id: this.clientId,
- client_secret: this.clientSecret,
- scope: StoreApis.scope,
- };
- const formBody = [];
- for (const property in requestParameters) {
- const encodedKey = encodeURIComponent(property);
- const encodedValue = encodeURIComponent(requestParameters[property]);
- formBody.push(encodedKey + "=" + encodedValue);
- }
- const dataString = formBody.join("\r\n&");
- const options = {
- host: StoreApis.microsoftOnlineLoginHost,
- path: `/${this.tenantId}${StoreApis.authOAuth2TokenSuffix}`,
- method: "POST",
- headers: {
- "Content-Type": "application/x-www-form-urlencoded",
- "Content-Length": dataString.length,
- },
- };
- return new Promise((resolve, reject) => {
- const req = https.request(options, (res) => {
- let responseString = "";
- res.on("data", (data) => {
- responseString += data;
- });
- res.on("end", function () {
- const responseObject = JSON.parse(responseString);
- if (responseObject.error)
- reject(responseObject);
- else
- resolve(responseObject.access_token);
- });
- });
- req.on("error", (e) => {
- console.error(e);
- reject(e);
- });
- req.write(dataString);
- req.end();
- });
- });
- }
- GetCurrentDraftSubmissionPackagesData() {
- return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/packages`);
- }
- GetCurrentDraftSubmissionMetadata(moduleName, listingLanguages) {
- return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/metadata/${moduleName}?languages=${listingLanguages}`);
- }
- UpdateCurrentDraftSubmissionMetadata(submissionMetadata) {
- return this.CreateStoreHttpRequest(JSON.stringify(submissionMetadata), "PUT", `/submission/v1/product/${this.productId}/metadata`);
- }
- UpdateStoreSubmissionPackages(submission) {
- return __awaiter(this, void 0, void 0, function* () {
- return this.CreateStoreHttpRequest(JSON.stringify(submission), "PUT", `/submission/v1/product/${this.productId}/packages`);
- });
- }
- CommitUpdateStoreSubmissionPackages() {
- return __awaiter(this, void 0, void 0, function* () {
- return this.CreateStoreHttpRequest("", "POST", `/submission/v1/product/${this.productId}/packages/commit`);
- });
- }
- GetModuleStatus() {
- return __awaiter(this, void 0, void 0, function* () {
- return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/status`);
- });
- }
- GetSubmissionStatus(submissionId) {
- return __awaiter(this, void 0, void 0, function* () {
- return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/submission/${submissionId}/status`);
- });
- }
- SubmitSubmission() {
- return __awaiter(this, void 0, void 0, function* () {
- return this.CreateStoreHttpRequest("", "POST", `/submission/v1/product/${this.productId}/submit`);
- });
- }
- GetCurrentDraftListingAssets(listingLanguages) {
- return __awaiter(this, void 0, void 0, function* () {
- return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/listings/assets?languages=${listingLanguages}`);
- });
- }
- CreateStoreHttpRequest(requestParameters, method, path) {
- return __awaiter(this, void 0, void 0, function* () {
- const options = {
- host: StoreApis.storeApiUrl,
- path: path,
- method: method,
- headers: {
- "Content-Type": "application/json",
- "Content-Length": requestParameters.length,
- Authorization: "Bearer " + this.accessToken,
- "X-Seller-Account-Id": this.sellerId,
- },
- };
- return new Promise((resolve, reject) => {
- const req = https.request(options, (res) => {
- if (res.statusCode == 404) {
- const error = new ResponseWrapper();
- error.isSuccess = false;
- error.errors = [];
- error.errors[0] = new Error();
- error.errors[0].message = "Not found";
- reject(error);
- return;
- }
- let responseString = "";
- res.on("data", (data) => {
- responseString += data;
- });
- res.on("end", function () {
- const responseObject = JSON.parse(responseString);
- resolve(responseObject);
- });
- });
- req.on("error", (e) => {
- console.error(e);
- reject(e);
- });
- req.write(requestParameters);
- req.end();
- });
- });
- }
- PollModuleStatus() {
- return __awaiter(this, void 0, void 0, function* () {
- let status = new ModuleStatus();
- status.isReady = false;
- while (!status.isReady) {
- const moduleStatus = yield this.GetModuleStatus();
- console.log(JSON.stringify(moduleStatus));
- status = moduleStatus.responseData;
- if (!moduleStatus.isSuccess) {
- const errorResponse = moduleStatus;
- if (errorResponse.statusCode == 401) {
- console.log(`Access token expired. Requesting new one. (message='${errorResponse.message}')`);
- yield this.InitAsync();
- status = new ModuleStatus();
- status.isReady = false;
- continue;
- }
- console.log("Error");
- break;
- }
- if (status.isReady) {
- console.log("Success!");
- return true;
- }
- else {
- if (moduleStatus.errors &&
- moduleStatus.errors.length > 0 &&
- moduleStatus.errors.find((e) => e.target != "packages" || e.code == "packageuploaderror")) {
- console.log(moduleStatus.errors);
- return false;
- }
- }
- console.log("Waiting 10 seconds.");
- yield this.Delay(10000);
- }
- return false;
- });
- }
- InitAsync() {
- return __awaiter(this, void 0, void 0, function* () {
- this.accessToken = yield this.GetAccessToken();
- });
- }
- GetExistingDraft(moduleName, listingLanguage) {
- return __awaiter(this, void 0, void 0, function* () {
- return new Promise((resolve, reject) => {
- if (moduleName &&
- moduleName.toLowerCase() != "availability" &&
- moduleName.toLowerCase() != "listings" &&
- moduleName.toLowerCase() != "properties") {
- reject("Module name must be 'availability', 'listings' or 'properties'");
- return;
- }
- (moduleName
- ? this.GetCurrentDraftSubmissionMetadata(moduleName, listingLanguage)
- : this.GetCurrentDraftSubmissionPackagesData())
- .then((currentDraftResponse) => {
- if (!currentDraftResponse.isSuccess) {
- reject(`Failed to get the existing draft. - ${JSON.stringify(currentDraftResponse, null, 2)}`);
- }
- else {
- resolve(JSON.stringify(currentDraftResponse.responseData));
- }
- })
- .catch((error) => {
- reject(`Failed to get the existing draft. - ${error.errors}`);
- });
- });
- });
- }
- PollSubmissionStatus(pollingSubmissionId) {
- return __awaiter(this, void 0, void 0, function* () {
- let status = new SubmissionStatus();
- status.hasFailed = false;
- // eslint-disable-next-line no-async-promise-executor
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
- while (!status.hasFailed) {
- const submissionStatus = yield this.GetSubmissionStatus(pollingSubmissionId);
- console.log(JSON.stringify(submissionStatus));
- status = submissionStatus.responseData;
- if (!submissionStatus.isSuccess || status.hasFailed) {
- const errorResponse = submissionStatus;
- if (errorResponse.statusCode == 401) {
- console.log(`Access token expired. Requesting new one. (message='${errorResponse.message}')`);
- yield this.InitAsync();
- status = new SubmissionStatus();
- status.hasFailed = false;
- continue;
- }
- console.log("Error");
- reject("Error");
- return;
- }
- if (status.publishingStatus == PublishingStatus.PUBLISHED ||
- status.publishingStatus == PublishingStatus.FAILED) {
- console.log(`PublishingStatus = ${status.publishingStatus}`);
- resolve(status.publishingStatus);
- return;
- }
- console.log("Waiting 10 seconds.");
- yield this.Delay(10000);
- }
- }));
- });
- }
- UpdateSubmissionMetadata(submissionMetadataString) {
- return __awaiter(this, void 0, void 0, function* () {
- if (!(yield this.PollModuleStatus())) {
- // Wait until all modules are in the ready state
- return Promise.reject("Failed to poll module status.");
- }
- const submissionMetadata = JSON.parse(submissionMetadataString);
- console.log(submissionMetadata);
- const updateSubmissionData = yield this.UpdateCurrentDraftSubmissionMetadata(submissionMetadata);
- console.log(JSON.stringify(updateSubmissionData));
- if (!updateSubmissionData.isSuccess) {
- return Promise.reject(`Failed to update submission metadata - ${JSON.stringify(updateSubmissionData.errors)}`);
- }
- if (!(yield this.PollModuleStatus())) {
- // Wait until all modules are in the ready state
- return Promise.reject("Failed to poll module status.");
- }
- return updateSubmissionData;
- });
- }
- UpdateProductPackages(updatedProductString) {
- return __awaiter(this, void 0, void 0, function* () {
- if (!(yield this.PollModuleStatus())) {
- // Wait until all modules are in the ready state
- return Promise.reject("Failed to poll module status.");
- }
- const updatedProductPackages = JSON.parse(updatedProductString);
- console.log(updatedProductPackages);
- const updateSubmissionData = yield this.UpdateStoreSubmissionPackages(updatedProductPackages);
- console.log(JSON.stringify(updateSubmissionData));
- if (!updateSubmissionData.isSuccess) {
- return Promise.reject(`Failed to update submission - ${JSON.stringify(updateSubmissionData.errors)}`);
- }
- console.log("Committing package changes...");
- const commitResult = yield this.CommitUpdateStoreSubmissionPackages();
- if (!commitResult.isSuccess) {
- return Promise.reject(`Failed to commit the updated submission - ${JSON.stringify(commitResult.errors)}`);
- }
- console.log(JSON.stringify(commitResult));
- if (!(yield this.PollModuleStatus())) {
- // Wait until all modules are in the ready state
- return Promise.reject("Failed to poll module status.");
- }
- return updateSubmissionData;
- });
- }
- PublishSubmission() {
- return __awaiter(this, void 0, void 0, function* () {
- const commitResult = yield this.CommitUpdateStoreSubmissionPackages();
- if (!commitResult.isSuccess) {
- return Promise.reject(`Failed to commit the updated submission - ${JSON.stringify(commitResult.errors)}`);
- }
- console.log(JSON.stringify(commitResult));
- if (!(yield this.PollModuleStatus())) {
- // Wait until all modules are in the ready state
- return Promise.reject("Failed to poll module status.");
- }
- let submissionId = null;
- const submitSubmissionResponse = yield this.SubmitSubmission();
- console.log(JSON.stringify(submitSubmissionResponse));
- if (submitSubmissionResponse.isSuccess) {
- if (submitSubmissionResponse.responseData.submissionId != null &&
- submitSubmissionResponse.responseData.submissionId.length > 0) {
- submissionId = submitSubmissionResponse.responseData.submissionId;
- }
- else if (submitSubmissionResponse.responseData.ongoingSubmissionId != null &&
- submitSubmissionResponse.responseData.ongoingSubmissionId.length > 0) {
- submissionId =
- submitSubmissionResponse.responseData.ongoingSubmissionId;
- }
- }
- return new Promise((resolve, reject) => {
- if (submissionId == null) {
- console.log("Failed to get submission ID");
- reject("Failed to get submission ID");
- }
- else {
- resolve(submissionId);
- }
- });
- });
- }
- GetExistingDraftListingAssets(listingLanguage) {
- return __awaiter(this, void 0, void 0, function* () {
- return new Promise((resolve, reject) => {
- this.GetCurrentDraftListingAssets(listingLanguage)
- .then((draftListingAssetsResponse) => {
- if (!draftListingAssetsResponse.isSuccess) {
- reject(`Failed to get the existing draft listing assets. - ${JSON.stringify(draftListingAssetsResponse, null, 2)}`);
- }
- else {
- resolve(JSON.stringify(draftListingAssetsResponse.responseData));
- }
- })
- .catch((error) => {
- reject(`Failed to get the existing draft listing assets. - ${error.errors}`);
- });
- });
- });
- }
- LoadState() {
- var _a, _b, _c, _d, _e, _f;
- this.productId = (_a = process.env[`${exports.EnvVariablePrefix}product_id`]) !== null && _a !== void 0 ? _a : "";
- this.sellerId = (_b = process.env[`${exports.EnvVariablePrefix}seller_id`]) !== null && _b !== void 0 ? _b : "";
- this.tenantId = (_c = process.env[`${exports.EnvVariablePrefix}tenant_id`]) !== null && _c !== void 0 ? _c : "";
- this.clientId = (_d = process.env[`${exports.EnvVariablePrefix}client_id`]) !== null && _d !== void 0 ? _d : "";
- this.clientSecret = (_e = process.env[`${exports.EnvVariablePrefix}client_secret`]) !== null && _e !== void 0 ? _e : "";
- this.accessToken = (_f = process.env[`${exports.EnvVariablePrefix}access_token`]) !== null && _f !== void 0 ? _f : "";
- }
-}
-exports.StoreApis = StoreApis;
-Object.defineProperty(StoreApis, "microsoftOnlineLoginHost", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: "login.microsoftonline.com"
-});
-Object.defineProperty(StoreApis, "authOAuth2TokenSuffix", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: "/oauth2/v2.0/token"
-});
-Object.defineProperty(StoreApis, "scope", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: "https://api.store.microsoft.com/.default"
-});
-Object.defineProperty(StoreApis, "storeApiUrl", {
- enumerable: true,
- configurable: true,
- writable: true,
- value: "api.store.microsoft.com"
-});
+
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+};
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+exports.StoreApis = exports.EnvVariablePrefix = void 0;
+const https = __importStar(__nccwpck_require__(5687));
+exports.EnvVariablePrefix = "MICROSOFT_STORE_ACTION_";
+class ResponseWrapper {
+ constructor() {
+ Object.defineProperty(this, "responseData", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "isSuccess", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "errors", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class ErrorResponse {
+ constructor() {
+ Object.defineProperty(this, "statusCode", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "message", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class Error {
+ constructor() {
+ Object.defineProperty(this, "code", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "message", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "target", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class SubmissionResponse {
+ constructor() {
+ Object.defineProperty(this, "pollingUrl", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "submissionId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "ongoingSubmissionId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+var PublishingStatus;
+(function (PublishingStatus) {
+ PublishingStatus["INPROGRESS"] = "INPROGRESS";
+ PublishingStatus["PUBLISHED"] = "PUBLISHED";
+ PublishingStatus["FAILED"] = "FAILED";
+ PublishingStatus["UNKNOWN"] = "UNKNOWN";
+})(PublishingStatus || (PublishingStatus = {}));
+class ModuleStatus {
+ constructor() {
+ Object.defineProperty(this, "isReady", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "ongoingSubmissionId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class SubmissionStatus {
+ constructor() {
+ Object.defineProperty(this, "publishingStatus", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "hasFailed", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class ListingAssetsResponse {
+ constructor() {
+ Object.defineProperty(this, "listingAssets", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class ImageSize {
+ constructor() {
+ Object.defineProperty(this, "width", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "height", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class ListingAsset {
+ constructor() {
+ Object.defineProperty(this, "language", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "storeLogos", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "screenshots", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class Screenshot {
+ constructor() {
+ Object.defineProperty(this, "id", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "assetUrl", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "imageSize", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class StoreLogo {
+ constructor() {
+ Object.defineProperty(this, "id", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "assetUrl", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "imageSize", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ }
+}
+class StoreApis {
+ constructor() {
+ Object.defineProperty(this, "accessToken", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "productId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "sellerId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "tenantId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "clientId", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "clientSecret", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ Object.defineProperty(this, "onlyOnReady", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: void 0
+ });
+ this.LoadState();
+ }
+ Delay(ms) {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+ }
+ GetAccessToken() {
+ return __awaiter(this, void 0, void 0, function* () {
+ const requestParameters = {
+ grant_type: "client_credentials",
+ client_id: this.clientId,
+ client_secret: this.clientSecret,
+ scope: StoreApis.scope,
+ };
+ const formBody = [];
+ for (const property in requestParameters) {
+ const encodedKey = encodeURIComponent(property);
+ const encodedValue = encodeURIComponent(requestParameters[property]);
+ formBody.push(encodedKey + "=" + encodedValue);
+ }
+ const dataString = formBody.join("\r\n&");
+ const options = {
+ host: StoreApis.microsoftOnlineLoginHost,
+ path: `/${this.tenantId}${StoreApis.authOAuth2TokenSuffix}`,
+ method: "POST",
+ headers: {
+ "Content-Type": "application/x-www-form-urlencoded",
+ "Content-Length": dataString.length,
+ },
+ };
+ return new Promise((resolve, reject) => {
+ const req = https.request(options, (res) => {
+ let responseString = "";
+ res.on("data", (data) => {
+ responseString += data;
+ });
+ res.on("end", function () {
+ const responseObject = JSON.parse(responseString);
+ if (responseObject.error)
+ reject(responseObject);
+ else
+ resolve(responseObject.access_token);
+ });
+ });
+ req.on("error", (e) => {
+ console.error(e);
+ reject(e);
+ });
+ req.write(dataString);
+ req.end();
+ });
+ });
+ }
+ GetCurrentDraftSubmissionPackagesData() {
+ return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/packages`);
+ }
+ GetCurrentDraftSubmissionMetadata(moduleName, listingLanguages) {
+ return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/metadata/${moduleName}?languages=${listingLanguages}`);
+ }
+ UpdateCurrentDraftSubmissionMetadata(submissionMetadata) {
+ return this.CreateStoreHttpRequest(JSON.stringify(submissionMetadata), "PUT", `/submission/v1/product/${this.productId}/metadata`);
+ }
+ UpdateStoreSubmissionPackages(submission) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.CreateStoreHttpRequest(JSON.stringify(submission), "PUT", `/submission/v1/product/${this.productId}/packages`);
+ });
+ }
+ CommitUpdateStoreSubmissionPackages() {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.CreateStoreHttpRequest("", "POST", `/submission/v1/product/${this.productId}/packages/commit`);
+ });
+ }
+ GetModuleStatus() {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/status`);
+ });
+ }
+ GetSubmissionStatus(submissionId) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/submission/${submissionId}/status`);
+ });
+ }
+ SubmitSubmission() {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.CreateStoreHttpRequest("", "POST", `/submission/v1/product/${this.productId}/submit`);
+ });
+ }
+ GetCurrentDraftListingAssets(listingLanguages) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.CreateStoreHttpRequest("", "GET", `/submission/v1/product/${this.productId}/listings/assets?languages=${listingLanguages}`);
+ });
+ }
+ CreateStoreHttpRequest(requestParameters, method, path) {
+ return __awaiter(this, void 0, void 0, function* () {
+ const options = {
+ host: StoreApis.storeApiUrl,
+ path: path,
+ method: method,
+ headers: {
+ "Content-Type": "application/json",
+ "Content-Length": requestParameters.length,
+ Authorization: "Bearer " + this.accessToken,
+ "X-Seller-Account-Id": this.sellerId,
+ },
+ };
+ return new Promise((resolve, reject) => {
+ const req = https.request(options, (res) => {
+ if (res.statusCode == 404) {
+ const error = new ResponseWrapper();
+ error.isSuccess = false;
+ error.errors = [];
+ error.errors[0] = new Error();
+ error.errors[0].message = "Not found";
+ reject(error);
+ return;
+ }
+ let responseString = "";
+ res.on("data", (data) => {
+ responseString += data;
+ });
+ res.on("end", function () {
+ const responseObject = JSON.parse(responseString);
+ resolve(responseObject);
+ });
+ });
+ req.on("error", (e) => {
+ console.error(e);
+ reject(e);
+ });
+ req.write(requestParameters);
+ req.end();
+ });
+ });
+ }
+ PollModuleStatus() {
+ return __awaiter(this, void 0, void 0, function* () {
+ let status = new ModuleStatus();
+ status.isReady = false;
+ while (!status.isReady) {
+ const moduleStatus = yield this.GetModuleStatus();
+ console.log(JSON.stringify(moduleStatus));
+ status = moduleStatus.responseData;
+ if (!moduleStatus.isSuccess) {
+ const errorResponse = moduleStatus;
+ if (errorResponse.statusCode == 401) {
+ console.log(`Access token expired. Requesting new one. (message='${errorResponse.message}')`);
+ yield this.InitAsync();
+ status = new ModuleStatus();
+ status.isReady = false;
+ continue;
+ }
+ console.log("Error");
+ break;
+ }
+ if (status.isReady) {
+ console.log("Success!");
+ return true;
+ }
+ else {
+ if (moduleStatus.errors &&
+ moduleStatus.errors.length > 0 &&
+ moduleStatus.errors.find((e) => e.target != "packages" || e.code == "packageuploaderror")) {
+ console.log(moduleStatus.errors);
+ return false;
+ }
+ }
+ console.log("Waiting 10 seconds.");
+ yield this.Delay(10000);
+ }
+ return false;
+ });
+ }
+ InitAsync() {
+ return __awaiter(this, void 0, void 0, function* () {
+ this.accessToken = yield this.GetAccessToken();
+ });
+ }
+ IsReady() {
+ return __awaiter(this, void 0, void 0, function* () {
+ if (!this.onlyOnReady) {
+ return true;
+ }
+ const moduleStatus = yield this.GetModuleStatus();
+ return moduleStatus.responseData.isReady;
+ });
+ }
+ GetExistingDraft(moduleName, listingLanguage) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return new Promise((resolve, reject) => {
+ if (moduleName &&
+ moduleName.toLowerCase() != "availability" &&
+ moduleName.toLowerCase() != "listings" &&
+ moduleName.toLowerCase() != "properties") {
+ reject("Module name must be 'availability', 'listings' or 'properties'");
+ return;
+ }
+ (moduleName
+ ? this.GetCurrentDraftSubmissionMetadata(moduleName, listingLanguage)
+ : this.GetCurrentDraftSubmissionPackagesData())
+ .then((currentDraftResponse) => {
+ if (!currentDraftResponse.isSuccess) {
+ reject(`Failed to get the existing draft. - ${JSON.stringify(currentDraftResponse, null, 2)}`);
+ }
+ else {
+ resolve(JSON.stringify(currentDraftResponse.responseData));
+ }
+ })
+ .catch((error) => {
+ reject(`Failed to get the existing draft. - ${error.errors}`);
+ });
+ });
+ });
+ }
+ PollSubmissionStatus(pollingSubmissionId) {
+ return __awaiter(this, void 0, void 0, function* () {
+ let status = new SubmissionStatus();
+ status.hasFailed = false;
+ // eslint-disable-next-line no-async-promise-executor
+ return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
+ while (!status.hasFailed) {
+ const submissionStatus = yield this.GetSubmissionStatus(pollingSubmissionId);
+ console.log(JSON.stringify(submissionStatus));
+ status = submissionStatus.responseData;
+ if (!submissionStatus.isSuccess || status.hasFailed) {
+ const errorResponse = submissionStatus;
+ if (errorResponse.statusCode == 401) {
+ console.log(`Access token expired. Requesting new one. (message='${errorResponse.message}')`);
+ yield this.InitAsync();
+ status = new SubmissionStatus();
+ status.hasFailed = false;
+ continue;
+ }
+ console.log("Error");
+ reject("Error");
+ return;
+ }
+ if (status.publishingStatus == PublishingStatus.PUBLISHED ||
+ status.publishingStatus == PublishingStatus.FAILED) {
+ console.log(`PublishingStatus = ${status.publishingStatus}`);
+ resolve(status.publishingStatus);
+ return;
+ }
+ console.log("Waiting 10 seconds.");
+ yield this.Delay(10000);
+ }
+ }));
+ });
+ }
+ UpdateSubmissionMetadata(submissionMetadataString) {
+ return __awaiter(this, void 0, void 0, function* () {
+ if (!(yield this.PollModuleStatus())) {
+ // Wait until all modules are in the ready state
+ return Promise.reject("Failed to poll module status.");
+ }
+ const submissionMetadata = JSON.parse(submissionMetadataString);
+ console.log(submissionMetadata);
+ const updateSubmissionData = yield this.UpdateCurrentDraftSubmissionMetadata(submissionMetadata);
+ console.log(JSON.stringify(updateSubmissionData));
+ if (!updateSubmissionData.isSuccess) {
+ return Promise.reject(`Failed to update submission metadata - ${JSON.stringify(updateSubmissionData.errors)}`);
+ }
+ if (!(yield this.PollModuleStatus())) {
+ // Wait until all modules are in the ready state
+ return Promise.reject("Failed to poll module status.");
+ }
+ return updateSubmissionData;
+ });
+ }
+ UpdateProductPackages(updatedProductString) {
+ return __awaiter(this, void 0, void 0, function* () {
+ if (!(yield this.PollModuleStatus())) {
+ // Wait until all modules are in the ready state
+ return Promise.reject("Failed to poll module status.");
+ }
+ const updatedProductPackages = JSON.parse(updatedProductString);
+ console.log(updatedProductPackages);
+ const updateSubmissionData = yield this.UpdateStoreSubmissionPackages(updatedProductPackages);
+ console.log(JSON.stringify(updateSubmissionData));
+ if (!updateSubmissionData.isSuccess) {
+ return Promise.reject(`Failed to update submission - ${JSON.stringify(updateSubmissionData.errors)}`);
+ }
+ console.log("Committing package changes...");
+ const commitResult = yield this.CommitUpdateStoreSubmissionPackages();
+ if (!commitResult.isSuccess) {
+ return Promise.reject(`Failed to commit the updated submission - ${JSON.stringify(commitResult.errors)}`);
+ }
+ console.log(JSON.stringify(commitResult));
+ if (!(yield this.PollModuleStatus())) {
+ // Wait until all modules are in the ready state
+ return Promise.reject("Failed to poll module status.");
+ }
+ return updateSubmissionData;
+ });
+ }
+ PublishSubmission() {
+ return __awaiter(this, void 0, void 0, function* () {
+ const commitResult = yield this.CommitUpdateStoreSubmissionPackages();
+ if (!commitResult.isSuccess) {
+ return Promise.reject(`Failed to commit the updated submission - ${JSON.stringify(commitResult.errors)}`);
+ }
+ console.log(JSON.stringify(commitResult));
+ if (!(yield this.PollModuleStatus())) {
+ // Wait until all modules are in the ready state
+ return Promise.reject("Failed to poll module status.");
+ }
+ let submissionId = null;
+ const submitSubmissionResponse = yield this.SubmitSubmission();
+ console.log(JSON.stringify(submitSubmissionResponse));
+ if (submitSubmissionResponse.isSuccess) {
+ if (submitSubmissionResponse.responseData.submissionId != null &&
+ submitSubmissionResponse.responseData.submissionId.length > 0) {
+ submissionId = submitSubmissionResponse.responseData.submissionId;
+ }
+ else if (submitSubmissionResponse.responseData.ongoingSubmissionId != null &&
+ submitSubmissionResponse.responseData.ongoingSubmissionId.length > 0) {
+ submissionId =
+ submitSubmissionResponse.responseData.ongoingSubmissionId;
+ }
+ }
+ return new Promise((resolve, reject) => {
+ if (submissionId == null) {
+ console.log("Failed to get submission ID");
+ reject("Failed to get submission ID");
+ }
+ else {
+ resolve(submissionId);
+ }
+ });
+ });
+ }
+ GetExistingDraftListingAssets(listingLanguage) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return new Promise((resolve, reject) => {
+ this.GetCurrentDraftListingAssets(listingLanguage)
+ .then((draftListingAssetsResponse) => {
+ if (!draftListingAssetsResponse.isSuccess) {
+ reject(`Failed to get the existing draft listing assets. - ${JSON.stringify(draftListingAssetsResponse, null, 2)}`);
+ }
+ else {
+ resolve(JSON.stringify(draftListingAssetsResponse.responseData));
+ }
+ })
+ .catch((error) => {
+ reject(`Failed to get the existing draft listing assets. - ${error.errors}`);
+ });
+ });
+ });
+ }
+ LoadState() {
+ var _a, _b, _c, _d, _e, _f, _g;
+ this.productId = (_a = process.env[`${exports.EnvVariablePrefix}product_id`]) !== null && _a !== void 0 ? _a : "";
+ this.sellerId = (_b = process.env[`${exports.EnvVariablePrefix}seller_id`]) !== null && _b !== void 0 ? _b : "";
+ this.tenantId = (_c = process.env[`${exports.EnvVariablePrefix}tenant_id`]) !== null && _c !== void 0 ? _c : "";
+ this.clientId = (_d = process.env[`${exports.EnvVariablePrefix}client_id`]) !== null && _d !== void 0 ? _d : "";
+ this.clientSecret = (_e = process.env[`${exports.EnvVariablePrefix}client_secret`]) !== null && _e !== void 0 ? _e : "";
+ this.accessToken = (_f = process.env[`${exports.EnvVariablePrefix}access_token`]) !== null && _f !== void 0 ? _f : "";
+ const onlyOnReady = (_g = process.env[`${exports.EnvVariablePrefix}only-on-ready`]) !== null && _g !== void 0 ? _g : "false";
+ this.onlyOnReady = onlyOnReady === "true";
+ }
+}
+exports.StoreApis = StoreApis;
+Object.defineProperty(StoreApis, "microsoftOnlineLoginHost", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: "login.microsoftonline.com"
+});
+Object.defineProperty(StoreApis, "authOAuth2TokenSuffix", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: "/oauth2/v2.0/token"
+});
+Object.defineProperty(StoreApis, "scope", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: "https://api.store.microsoft.com/.default"
+});
+Object.defineProperty(StoreApis, "storeApiUrl", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: "api.store.microsoft.com"
+});
//# sourceMappingURL=store_apis.js.map
/***/ }),