@@ -10408,7 +10408,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
1040810408 });
1040910409};
1041010410Object.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;
1041210412const core_1 = __nccwpck_require__(2186);
1041310413const github_1 = __nccwpck_require__(5438);
1041410414let octokit;
@@ -10648,6 +10648,37 @@ function updateField(projectMetadata, contentMetadata, value) {
1064810648 });
1064910649}
1065010650exports.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;
1065110682/**
1065210683 * Returns the validated and normalized inputs for the action
1065310684 *
@@ -10657,8 +10688,8 @@ function getInputs() {
1065710688 let operation = (0, core_1.getInput)("operation");
1065810689 if (operation === "")
1065910690 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 )`);
1066210693 return {};
1066310694 }
1066410695 const inputs = {
@@ -10704,6 +10735,11 @@ function run() {
1070410735 (0, core_1.setOutput)("field_updated_value", inputs.value);
1070510736 (0, core_1.info)(`Updated field ${inputs.fieldName} on ${contentMetadata.title} to ${inputs.value}`);
1070610737 }
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+ }
1070710743 else {
1070810744 (0, core_1.setOutput)("field_updated_value", (_b = contentMetadata.field) === null || _b === void 0 ? void 0 : _b.value);
1070910745 }
0 commit comments