Edits history of script submission #20154 for ' Create a new release for an organization (sentry)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Create a new release for an organization
     * Create a new release for the given organization.  Releases are used by
    Sentry to improve its error reporting abilities by correlating
    first seen events with the release that might have introduced the
    problem.
    Releases are also necessary for source maps and other debug features
    that require manual upload for functioning well.
     */
    export async function main(auth: RT.Sentry, body: Body) {
    	const url = new URL(
    		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/releases/`
    	)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Bearer ' + auth.token
    		},
    		body: JSON.stringify(body)
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    
    /* eslint-disable */
    /**
     * This file was automatically generated by json-schema-to-typescript.
     * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
     * and run json-schema-to-typescript to regenerate this file.
     */
    
    export interface Body {
    	/**
    	 * A version identifier for this release. Can be a version number, a commit hash, etc.
    	 */
    	version: string
    	/**
    	 * A list of project slugs that are involved in this release.
    	 */
    	projects: string[]
    	/**
    	 * An optional commit reference. This is useful if a tagged version has been provided.
    	 */
    	ref?: string
    	/**
    	 * A URL that points to the release. This can be the path to an online interface to the source code for instance
    	 */
    	url?: string
    	/**
    	 * An optional date that indicates when the release went live. If not provided the current time is assumed.
    	 */
    	dateReleased?: string
    	/**
    	 * An optional list of commit data to be associated with the release. Commits must include parameters `id` (the SHA of the commit), and can optionally include `repository`, `message`, `patch_set`, `author_name`, `author_email`, and `timestamp`.
    	 */
    	commits?: {
    		/**
    		 * A list of the files that have been changed in the commit. Specifying the patch_set is necessary to power suspect commits and suggested assignees.
    		 */
    		patch_set?: {
    			/**
    			 * The path to the file. Both forward and backward slashes are supported.
    			 */
    			path: string
    			/**
    			 * The type of change that happened in the commit.
    			 */
    			type: 'A' | 'M' | 'D'
    			[k: string]: unknown
    		}[]
    		/**
    		 * The full name of the repository the commit belongs to. If this field is not given Sentry will generate a name in the form: u'organization-<organization_id>' (i.e. if the organization id is 123, then the generated repository name will be u'organization-123).
    		 */
    		repository?: string
    		/**
    		 * The name of the commit author.
    		 */
    		author_name?: string
    		/**
    		 * The email of the commit author. The commit author's email is required to enable the suggested assignee feature.
    		 */
    		author_email?: string
    		/**
    		 * The commit timestamp is used to sort the commits given. If a timestamp is not included, the commits will remain sorted in the order given.
    		 */
    		timestamp?: string
    		/**
    		 * The commit message.
    		 */
    		message?: string
    		/**
    		 * The commit ID (the commit SHA).
    		 */
    		id?: string
    		[k: string]: unknown
    	}[]
    	/**
    	 * An optional way to indicate the start and end commits for each repository included in a release. Head commits must include parameters `repository` and `commit` (the HEAD sha). They can optionally include `previousCommit` (the sha of the HEAD of the previous release), which should be specified if this is the first time you've sent commit data. `commit` may contain a range in the form of `previousCommit..commit`.
    	 */
    	refs?: {
    		/**
    		 * The full name of the repository the commit belongs to.
    		 */
    		repository?: string
    		/**
    		 * The current release's commit.
    		 */
    		commit?: string
    		/**
    		 * The previous release's commit.
    		 */
    		previousCommit?: string
    		[k: string]: unknown
    	}[]
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago