@@ -10408,7 +10408,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10408
10408
});
10409
10409
};
10410
10410
Object.defineProperty(exports, "__esModule", ({ value: true }));
10411
- exports.run = exports.setupOctokit = exports.getInputs = exports.updateField = exports.convertValueToFieldType = exports.valueGraphqlType = exports.ensureExists = exports.fetchProjectMetadata = exports.fetchContentMetadata = void 0;
10411
+ exports.run = exports.setupOctokit = exports.getInputs = exports.clearField = exports. updateField = exports.convertValueToFieldType = exports.valueGraphqlType = exports.ensureExists = exports.fetchProjectMetadata = exports.fetchContentMetadata = void 0;
10412
10412
const core_1 = __nccwpck_require__(2186);
10413
10413
const github_1 = __nccwpck_require__(5438);
10414
10414
let octokit;
@@ -10648,6 +10648,37 @@ function updateField(projectMetadata, contentMetadata, value) {
10648
10648
});
10649
10649
}
10650
10650
exports.updateField = updateField;
10651
+ /**
10652
+ * Clears the field value for the content item
10653
+ * @param {GraphQlQueryResponseData} projectMetadata - The project metadata returned from fetchProjectMetadata()
10654
+ * @param {GraphQlQueryResponseData} contentMetadata - The content metadata returned from fetchContentMetadata()
10655
+ * @return {Promise<GraphQlQueryResponseData>} - The updated content metadata
10656
+ */
10657
+ function clearField(projectMetadata, contentMetadata) {
10658
+ return __awaiter(this, void 0, void 0, function* () {
10659
+ const result = yield octokit.graphql(`
10660
+ mutation($project: ID!, $item: ID!, $field: ID!) {
10661
+ clearProjectV2ItemFieldValue(
10662
+ input: {
10663
+ projectId: $project
10664
+ itemId: $item
10665
+ fieldId: $field
10666
+ }
10667
+ ) {
10668
+ projectV2Item {
10669
+ id
10670
+ }
10671
+ }
10672
+ }
10673
+ `, {
10674
+ project: projectMetadata.projectId,
10675
+ item: contentMetadata.id,
10676
+ field: projectMetadata.field.fieldId,
10677
+ });
10678
+ return result;
10679
+ });
10680
+ }
10681
+ exports.clearField = clearField;
10651
10682
/**
10652
10683
* Returns the validated and normalized inputs for the action
10653
10684
*
@@ -10657,8 +10688,8 @@ function getInputs() {
10657
10688
let operation = (0, core_1.getInput)("operation");
10658
10689
if (operation === "")
10659
10690
operation = "update";
10660
- if (!["read", "update"].includes(operation)) {
10661
- (0, core_1.setFailed)(`Invalid value passed for the 'operation' parameter (passed: ${operation}, allowed: read, update)`);
10691
+ if (!["read", "update", "clear" ].includes(operation)) {
10692
+ (0, core_1.setFailed)(`Invalid value passed for the 'operation' parameter (passed: ${operation}, allowed: read, update, clear )`);
10662
10693
return {};
10663
10694
}
10664
10695
const inputs = {
@@ -10704,6 +10735,11 @@ function run() {
10704
10735
(0, core_1.setOutput)("field_updated_value", inputs.value);
10705
10736
(0, core_1.info)(`Updated field ${inputs.fieldName} on ${contentMetadata.title} to ${inputs.value}`);
10706
10737
}
10738
+ else if (inputs.operation === "clear") {
10739
+ yield clearField(projectMetadata, contentMetadata);
10740
+ (0, core_1.setOutput)("field_updated_value", null);
10741
+ (0, core_1.info)(`Cleared field ${inputs.fieldName} on ${contentMetadata.title}`);
10742
+ }
10707
10743
else {
10708
10744
(0, core_1.setOutput)("field_updated_value", (_b = contentMetadata.field) === null || _b === void 0 ? void 0 : _b.value);
10709
10745
}
0 commit comments