@gitkraken/core-gitlens 0.48.0 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -1
- package/dist/git/cache.d.ts +4 -0
- package/dist/git/cache.js +12 -0
- package/dist/git/cache.js.map +1 -1
- package/dist/git/providers/config.d.ts +3 -2
- package/dist/git-cli/cliGitProvider.d.ts +2 -0
- package/dist/git-cli/cliGitProvider.js +6 -0
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts +10 -6
- package/dist/git-cli/providers/config.js +46 -11
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts +1 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js +3 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +3 -2
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +9 -0
- package/dist/plus/integrations/integrationService.js +43 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +6 -0
- package/dist/plus/integrations/models/workItemWrites.d.ts +136 -0
- package/dist/plus/integrations/models/workItemWrites.js +0 -0
- package/dist/plus/integrations/providers/azure/workItemWriteMetadata.d.ts +38 -0
- package/dist/plus/integrations/providers/azure/workItemWriteMetadata.js +73 -0
- package/dist/plus/integrations/providers/azure/workItemWriteMetadata.js.map +1 -0
- package/dist/plus/integrations/providers/azureDevOps.d.ts +3 -0
- package/dist/plus/integrations/providers/azureDevOps.js +12 -1
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +1 -1
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.d.ts +17 -0
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.js +100 -0
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.js.map +1 -0
- package/dist/plus/integrations/providers/azureWorkItemWrites.d.ts +38 -0
- package/dist/plus/integrations/providers/azureWorkItemWrites.js +442 -0
- package/dist/plus/integrations/providers/azureWorkItemWrites.js.map +1 -0
- package/dist/plus/integrations/providers/providersApi.d.ts +4 -1
- package/dist/plus/integrations/providers/providersApi.js +7 -0
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/utils/keys/keymapDispatcher.js +8 -0
- package/dist/utils/keys/keymapDispatcher.js.map +1 -1
- package/docs/integrations.md +64 -0
- package/package.json +1 -1
|
@@ -154,6 +154,7 @@ var KeymapDispatcher = class {
|
|
|
154
154
|
}
|
|
155
155
|
const partnerSegment = (partnerBinding, partner) => partnerBinding.overridden ? partnerBinding.keys : partner.keys ?? partnerBinding.keys;
|
|
156
156
|
const rows = [];
|
|
157
|
+
const shownRows = /* @__PURE__ */ new Set();
|
|
157
158
|
for (const group of this.registrationGroups) for (const descriptor of group) {
|
|
158
159
|
if (descriptor.sheet === "hidden") continue;
|
|
159
160
|
const sheet = descriptor.sheet;
|
|
@@ -173,6 +174,13 @@ var KeymapDispatcher = class {
|
|
|
173
174
|
ids.push(partner.id);
|
|
174
175
|
}
|
|
175
176
|
if (binding == null && ids.length === 0) continue;
|
|
177
|
+
const rowKey = [
|
|
178
|
+
sheet.group,
|
|
179
|
+
sheet.label,
|
|
180
|
+
...keys
|
|
181
|
+
].join("\0");
|
|
182
|
+
if (shownRows.has(rowKey)) continue;
|
|
183
|
+
shownRows.add(rowKey);
|
|
176
184
|
rows.push({
|
|
177
185
|
group: sheet.group,
|
|
178
186
|
label: sheet.label,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keymapDispatcher.js","names":[],"sources":["../../../../utils/src/keys/keymapDispatcher.ts"],"sourcesContent":["/// <reference lib=\"dom\" />\n\nimport type { Disposable } from '../disposable.js';\nimport { createDisposable } from '../disposable.js';\nimport { matchesChord } from './chord.js';\nimport type {\n\tKeyBinding,\n\tKeyBindingDescriptor,\n\tKeyBindingOverrides,\n\tOverlayEntry,\n\tSheetDisplayEntry,\n\tSheetDisplayText,\n} from './keybinding.js';\nimport { registerBinding, resolveKeydown, resolveOverlayClose } from './keybinding.js';\n\n/** Where a scope is \"active\": rooted at a specific element, or matched by a CSS selector against the\n * keydown's composed path. */\nexport type ScopeRegistration = { root: Element } | { selector: string };\n\n/** A row for a rendered shortcut sheet — one binding's group/label/keys, in display form. */\nexport type KeymapSheetRow = {\n\tgroup: string;\n\tlabel: string;\n\torder?: number;\n\tkeys: readonly SheetDisplayEntry[];\n\tsubline?: readonly SheetDisplayEntry[];\n\t/** Whole localized subline; takes precedence over legacy display entries. */\n\tsublineText?: SheetDisplayText;\n\t/** The row's own id (if any) followed by each contributing partner's id — for the row tooltip.\n\t * Absent (rather than empty) when the row has no ids at all — a fixed/residual row. */\n\tids?: readonly string[];\n};\n\ntype ScopeEntry = {\n\tregistration: ScopeRegistration | 'always';\n\tguards: readonly ((e: KeyboardEvent) => boolean)[];\n};\n\nexport type KeymapRegistrar<TScope extends string> = {\n\tregisterScope(\n\t\tid: TScope,\n\t\tregistration: ScopeRegistration | 'always',\n\t\tguards?: readonly ((e: KeyboardEvent) => boolean)[],\n\t): Disposable;\n\tregisterBindings(descriptors: readonly KeyBindingDescriptor<TScope, KeyboardEvent>[]): Disposable;\n\tpushOverlay(entry: OverlayEntry): Disposable;\n\tdispose(): void;\n};\n\n/** Owns a document-level keydown listener and dispatches it to registered bindings by scope, honoring\n * an overlay-close stack (Escape) ahead of any binding match. Framework-agnostic — consumers register\n * scopes/bindings/overlays and call {@link KeymapDispatcher.attach} once. */\nexport class KeymapDispatcher<TScope extends string> {\n\tprivate readonly isMac: boolean;\n\tprivate readonly onWarn: ((message: string) => void) | undefined;\n\tprivate readonly scopes = new Map<string, ScopeEntry>();\n\tprivate alwaysOrder: string[] = [];\n\t/** Registered descriptor groups, in registration order — kept so bindings can be rebuilt whenever\n\t * a group is added/removed or the overrides change. */\n\tprivate registrationGroups: (readonly KeyBindingDescriptor<string, KeyboardEvent>[])[] = [];\n\tprivate overrides: KeyBindingOverrides | undefined;\n\tprivate bindings: KeyBinding<string, KeyboardEvent>[] = [];\n\t/** Every registered descriptor's outcome, `undefined` when disabled by an override — lets\n\t * {@link sheetEntries} walk descriptors in registration order (not just the survivors) so a\n\t * disabled owner's row can still surface via a registered `with` partner. */\n\tprivate bindingByDescriptor = new Map<\n\t\tKeyBindingDescriptor<string, KeyboardEvent>,\n\t\tKeyBinding<string, KeyboardEvent> | undefined\n\t>();\n\tprivate overlayStack: OverlayEntry[] = [];\n\tprivate registrarCount = 0;\n\tprivate attached = false;\n\tprivate readonly root: Element | undefined;\n\n\tconstructor(options: { isMac: boolean; onWarn?: (message: string) => void; root?: Element }) {\n\t\tthis.isMac = options.isMac;\n\t\tthis.onWarn = options.onWarn;\n\t\tthis.root = options.root;\n\t}\n\n\tregisterScope(\n\t\tid: TScope,\n\t\tregistration: ScopeRegistration | 'always',\n\t\tguards: readonly ((e: KeyboardEvent) => boolean)[] = [],\n\t): Disposable {\n\t\treturn this.addScope(id, registration, guards);\n\t}\n\n\tregisterBindings(descriptors: readonly KeyBindingDescriptor<TScope, KeyboardEvent>[]): Disposable {\n\t\treturn this.addBindings(descriptors);\n\t}\n\n\tcreateRegistrar(): KeymapRegistrar<TScope> {\n\t\tconst suffix = `#${++this.registrarCount}`;\n\t\tconst owned = new Set<Disposable>();\n\t\tconst own = (disposable: Disposable): Disposable => {\n\t\t\towned.add(disposable);\n\t\t\treturn createDisposable(() => {\n\t\t\t\tif (owned.delete(disposable)) {\n\t\t\t\t\tdisposable.dispose();\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\n\t\treturn {\n\t\t\tregisterScope: (id, registration, guards = []) =>\n\t\t\t\town(this.addScope(`${id}${suffix}`, registration, guards)),\n\t\t\tregisterBindings: descriptors =>\n\t\t\t\town(this.addBindings(descriptors.map(d => ({ ...d, scope: `${d.scope}${suffix}` })))),\n\t\t\tpushOverlay: entry => own(this.pushOverlay(entry)),\n\t\t\tdispose: () => {\n\t\t\t\tfor (const disposable of owned) {\n\t\t\t\t\tdisposable.dispose();\n\t\t\t\t}\n\t\t\t\towned.clear();\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate addScope(\n\t\tid: string,\n\t\tregistration: ScopeRegistration | 'always',\n\t\tguards: readonly ((e: KeyboardEvent) => boolean)[],\n\t): Disposable {\n\t\tconst entry: ScopeEntry = { registration: registration, guards: guards };\n\t\tthis.scopes.set(id, entry);\n\t\tif (registration === 'always') {\n\t\t\tthis.alwaysOrder.push(id);\n\t\t}\n\n\t\treturn createDisposable(() => {\n\t\t\tif (this.scopes.get(id) === entry) {\n\t\t\t\tthis.scopes.delete(id);\n\t\t\t}\n\n\t\t\tthis.alwaysOrder = this.alwaysOrder.filter(scopeId => scopeId !== id);\n\t\t});\n\t}\n\n\tprivate addBindings(descriptors: readonly KeyBindingDescriptor<string, KeyboardEvent>[]): Disposable {\n\t\tthis.registrationGroups.push(descriptors);\n\t\tthis.rebuildBindings();\n\n\t\treturn createDisposable(() => {\n\t\t\tconst index = this.registrationGroups.indexOf(descriptors);\n\t\t\tif (index === -1) return;\n\n\t\t\tthis.registrationGroups.splice(index, 1);\n\t\t\tthis.rebuildBindings();\n\t\t});\n\t}\n\n\t/** Replaces the active override map and rebuilds the effective binding list. Cheap enough to call\n\t * on every config push. */\n\tsetOverrides(overrides: KeyBindingOverrides | undefined): void {\n\t\tthis.overrides = overrides;\n\t\tthis.warnIgnoredWildcards(overrides);\n\t\tthis.rebuildBindings();\n\t}\n\n\t/** Wildcards can only disable (see `resolveOverride`) — warns once per offending wildcard key so\n\t * a user who tried to rebind via `'panels.*'`/`'*'` learns why it didn't take. */\n\tprivate warnIgnoredWildcards(overrides: KeyBindingOverrides | undefined): void {\n\t\tif (!overrides || this.onWarn == null) return;\n\n\t\tfor (const key of Object.keys(overrides)) {\n\t\t\tif (key !== '*' && !key.endsWith('.*')) continue;\n\n\t\t\tconst value = overrides[key];\n\t\t\tif (value === false || value.length === 0) continue;\n\n\t\t\tthis.onWarn(`Ignoring shortcut override '${key}': a wildcard can only disable (false), not rebind`);\n\t\t}\n\t}\n\n\tprivate rebuildBindings(): void {\n\t\tconst bindings: KeyBinding<string, KeyboardEvent>[] = [];\n\t\tconst byDescriptor = new Map<\n\t\t\tKeyBindingDescriptor<string, KeyboardEvent>,\n\t\t\tKeyBinding<string, KeyboardEvent> | undefined\n\t\t>();\n\n\t\tfor (const group of this.registrationGroups) {\n\t\t\tfor (const descriptor of group) {\n\t\t\t\tconst binding = registerBinding(descriptor, this.isMac, this.overrides, this.onWarn);\n\t\t\t\tbyDescriptor.set(descriptor, binding);\n\t\t\t\tif (binding == null) continue;\n\n\t\t\t\tbindings.push(binding);\n\t\t\t}\n\t\t}\n\n\t\tthis.bindings = bindings;\n\t\tthis.bindingByDescriptor = byDescriptor;\n\t}\n\n\t/** Closes the topmost overlay willing to close, exactly as an Escape keydown would — for hosts whose\n\t * widgets consume Esc locally but still want the stack to outrank their own fallback action. */\n\tcloseTopOverlay(): boolean {\n\t\tconst candidates = resolveOverlayClose(this.overlayStack);\n\t\tfor (const entry of candidates) {\n\t\t\tif (!entry.onClose()) continue;\n\n\t\t\tconst index = this.overlayStack.indexOf(entry);\n\t\t\tif (index !== -1) {\n\t\t\t\tthis.overlayStack.splice(index, 1);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tpushOverlay(entry: OverlayEntry): Disposable {\n\t\tthis.overlayStack.push(entry);\n\n\t\treturn createDisposable(() => {\n\t\t\tconst index = this.overlayStack.indexOf(entry);\n\t\t\tif (index === -1) return;\n\n\t\t\tthis.overlayStack.splice(index, 1);\n\t\t});\n\t}\n\n\tattach(): void {\n\t\tif (this.attached) return;\n\n\t\tdocument.addEventListener('keydown', this._onKeydown, false);\n\t\tthis.attached = true;\n\t}\n\n\tdispose(): void {\n\t\tif (this.attached) {\n\t\t\tdocument.removeEventListener('keydown', this._onKeydown, false);\n\t\t\tthis.attached = false;\n\t\t}\n\n\t\tthis.scopes.clear();\n\t\tthis.alwaysOrder = [];\n\t\tthis.registrationGroups = [];\n\t\tthis.overrides = undefined;\n\t\tthis.bindings = [];\n\t\tthis.bindingByDescriptor = new Map();\n\t\tthis.overlayStack = [];\n\t}\n\n\tsheetEntries(): readonly KeymapSheetRow[] {\n\t\tconst byId = new Map<string, KeyBinding<string, KeyboardEvent>>();\n\t\tfor (const binding of this.bindings) {\n\t\t\tif (binding.id == null) continue;\n\n\t\t\tbyId.set(binding.id, binding);\n\t\t}\n\n\t\t// A partner's display segment — its live effective keys once overridden, otherwise the\n\t\t// `with` entry's own default display (falling back to the partner's own keys).\n\t\tconst partnerSegment = (\n\t\t\tpartnerBinding: KeyBinding<string, KeyboardEvent>,\n\t\t\tpartner: { keys?: readonly SheetDisplayEntry[] },\n\t\t): readonly SheetDisplayEntry[] =>\n\t\t\tpartnerBinding.overridden ? partnerBinding.keys : (partner.keys ?? partnerBinding.keys);\n\n\t\tconst rows: KeymapSheetRow[] = [];\n\t\t// Walk descriptors (not just `this.bindings`) so a visible descriptor disabled by an override\n\t\t// can still surface a row when one of its `with` partners is still registered.\n\t\tfor (const group of this.registrationGroups) {\n\t\t\tfor (const descriptor of group) {\n\t\t\t\tif (descriptor.sheet === 'hidden') continue;\n\n\t\t\t\tconst sheet = descriptor.sheet;\n\t\t\t\tconst binding = this.bindingByDescriptor.get(descriptor);\n\n\t\t\t\tconst keys: SheetDisplayEntry[] = [];\n\t\t\t\tconst ids: string[] = [];\n\n\t\t\t\tif (binding != null) {\n\t\t\t\t\tconst self = binding.overridden ? binding.keys : (sheet.keysOverride ?? binding.keys);\n\t\t\t\t\tkeys.push(...self);\n\t\t\t\t\tif (binding.id != null) {\n\t\t\t\t\t\tids.push(binding.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const partner of sheet.with ?? []) {\n\t\t\t\t\tconst partnerBinding = byId.get(partner.id);\n\t\t\t\t\tif (partnerBinding == null) continue; // disabled (or unregistered) partner contributes nothing\n\n\t\t\t\t\tif (keys.length > 0) {\n\t\t\t\t\t\tkeys.push('sep:/');\n\t\t\t\t\t}\n\t\t\t\t\tkeys.push(...partnerSegment(partnerBinding, partner));\n\t\t\t\t\tids.push(partner.id);\n\t\t\t\t}\n\n\t\t\t\t// The owner is disabled AND no `with` partner survived — nothing left to show.\n\t\t\t\tif (binding == null && ids.length === 0) continue;\n\n\t\t\t\trows.push({\n\t\t\t\t\tgroup: sheet.group,\n\t\t\t\t\tlabel: sheet.label,\n\t\t\t\t\torder: sheet.order,\n\t\t\t\t\tkeys: keys,\n\t\t\t\t\tsubline: sheet.subline,\n\t\t\t\t\tsublineText: sheet.sublineText,\n\t\t\t\t\tids: ids.length > 0 ? ids : undefined,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn rows;\n\t}\n\n\tprivate readonly _onKeydown = (e: KeyboardEvent): void => {\n\t\tif (e.defaultPrevented) return;\n\t\tif (this.root != null && !e.composedPath().includes(this.root)) return;\n\n\t\tif (e.key === 'Escape' && this.overlayStack.length > 0 && this.closeTopOverlay()) {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\treturn;\n\t\t}\n\n\t\tconst chain: string[] = [];\n\t\tfor (const element of e.composedPath()) {\n\t\t\tfor (const [id, entry] of this.scopes) {\n\t\t\t\tif (entry.registration === 'always') continue;\n\t\t\t\tif (chain.includes(id)) continue;\n\n\t\t\t\tconst registration = entry.registration;\n\t\t\t\tconst matches =\n\t\t\t\t\t('root' in registration && registration.root === element) ||\n\t\t\t\t\t('selector' in registration &&\n\t\t\t\t\t\telement instanceof Element &&\n\t\t\t\t\t\telement.matches(registration.selector));\n\t\t\t\tif (matches) {\n\t\t\t\t\tchain.push(id);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const id of this.alwaysOrder) {\n\t\t\tif (!chain.includes(id)) {\n\t\t\t\tchain.push(id);\n\t\t\t}\n\t\t}\n\n\t\tconst candidates = resolveKeydown(this.bindings, chain, e);\n\t\tfor (const candidate of candidates) {\n\t\t\tconst guards = this.scopes.get(candidate.scope)?.guards ?? [];\n\t\t\tif (guards.some(guard => !guard(e))) continue;\n\n\t\t\tif (candidate.when?.some(when => !when(e))) continue;\n\n\t\t\tconst chordIndex = candidate.chords.findIndex(chord => matchesChord(chord, e));\n\t\t\tif (!candidate.run(e, chordIndex)) continue;\n\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\treturn;\n\t\t}\n\t};\n}\n"],"mappings":";;;;;;;AAoDA,IAAa,mBAAb,MAAqD;CACpD;CACA;CACA,yBAA0B,IAAI,IAAwB;CACtD,cAAgC,CAAC;;;CAGjC,qBAAyF,CAAC;CAC1F;CACA,WAAwD,CAAC;;;;CAIzD,sCAA8B,IAAI,IAGhC;CACF,eAAuC,CAAC;CACxC,iBAAyB;CACzB,WAAmB;CACnB;CAEA,YAAY,SAAiF;EAC5F,KAAK,QAAQ,QAAQ;EACrB,KAAK,SAAS,QAAQ;EACtB,KAAK,OAAO,QAAQ;CACrB;CAEA,cACC,IACA,cACA,SAAqD,CAAC,GACzC;EACb,OAAO,KAAK,SAAS,IAAI,cAAc,MAAM;CAC9C;CAEA,iBAAiB,aAAiF;EACjG,OAAO,KAAK,YAAY,WAAW;CACpC;CAEA,kBAA2C;EAC1C,MAAM,SAAS,IAAI,EAAE,KAAK;EAC1B,MAAM,wBAAQ,IAAI,IAAgB;EAClC,MAAM,OAAO,eAAuC;GACnD,MAAM,IAAI,UAAU;GACpB,OAAO,uBAAuB;IAC7B,IAAI,MAAM,OAAO,UAAU,GAC1B,WAAW,QAAQ;GAErB,CAAC;EACF;EAEA,OAAO;GACN,gBAAgB,IAAI,cAAc,SAAS,CAAC,MAC3C,IAAI,KAAK,SAAS,GAAG,KAAK,UAAU,cAAc,MAAM,CAAC;GAC1D,mBAAkB,gBACjB,IAAI,KAAK,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,KAAK,KAAK,gBAAgB,GAAG;GACjF,EAAE,eAAe;GACjB,EAAE,gBAAgB;GAClB;EACD;EAEA,MAAM,QAAkB,CAAC;EACzB,KAAK,MAAM,WAAW,EAAE,aAAa,GACpC,KAAK,MAAM,CAAC,IAAI,UAAU,KAAK,QAAQ;GACtC,IAAI,MAAM,iBAAiB,UAAU;GACrC,IAAI,MAAM,SAAS,EAAE,GAAG;GAExB,MAAM,eAAe,MAAM;GAM3B,IAJE,UAAU,gBAAgB,aAAa,SAAS,WAChD,cAAc,gBACd,mBAAmB,WACnB,QAAQ,QAAQ,aAAa,QAAQ,GAEtC,MAAM,KAAK,EAAE;EAEf;EAGD,KAAK,MAAM,MAAM,KAAK,aACrB,IAAI,CAAC,MAAM,SAAS,EAAE,GACrB,MAAM,KAAK,EAAE;EAIf,MAAM,aAAa,eAAe,KAAK,UAAU,OAAO,CAAC;EACzD,KAAK,MAAM,aAAa,YAAY;GAEnC,KADe,KAAK,OAAO,IAAI,UAAU,KAAK,CAAC,EAAE,UAAU,CAAC,EAAA,CACjD,MAAK,UAAS,CAAC,MAAM,CAAC,CAAC,GAAG;GAErC,IAAI,UAAU,MAAM,MAAK,SAAQ,CAAC,KAAK,CAAC,CAAC,GAAG;GAE5C,MAAM,aAAa,UAAU,OAAO,WAAU,UAAS,aAAa,OAAO,CAAC,CAAC;GAC7E,IAAI,CAAC,UAAU,IAAI,GAAG,UAAU,GAAG;GAEnC,EAAE,eAAe;GACjB,EAAE,gBAAgB;GAClB;EACD;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"keymapDispatcher.js","names":[],"sources":["../../../../utils/src/keys/keymapDispatcher.ts"],"sourcesContent":["/// <reference lib=\"dom\" />\n\nimport type { Disposable } from '../disposable.js';\nimport { createDisposable } from '../disposable.js';\nimport { matchesChord } from './chord.js';\nimport type {\n\tKeyBinding,\n\tKeyBindingDescriptor,\n\tKeyBindingOverrides,\n\tOverlayEntry,\n\tSheetDisplayEntry,\n\tSheetDisplayText,\n} from './keybinding.js';\nimport { registerBinding, resolveKeydown, resolveOverlayClose } from './keybinding.js';\n\n/** Where a scope is \"active\": rooted at a specific element, or matched by a CSS selector against the\n * keydown's composed path. */\nexport type ScopeRegistration = { root: Element } | { selector: string };\n\n/** A row for a rendered shortcut sheet — one binding's group/label/keys, in display form. */\nexport type KeymapSheetRow = {\n\tgroup: string;\n\tlabel: string;\n\torder?: number;\n\tkeys: readonly SheetDisplayEntry[];\n\tsubline?: readonly SheetDisplayEntry[];\n\t/** Whole localized subline; takes precedence over legacy display entries. */\n\tsublineText?: SheetDisplayText;\n\t/** The row's own id (if any) followed by each contributing partner's id — for the row tooltip.\n\t * Absent (rather than empty) when the row has no ids at all — a fixed/residual row. */\n\tids?: readonly string[];\n};\n\ntype ScopeEntry = {\n\tregistration: ScopeRegistration | 'always';\n\tguards: readonly ((e: KeyboardEvent) => boolean)[];\n};\n\nexport type KeymapRegistrar<TScope extends string> = {\n\tregisterScope(\n\t\tid: TScope,\n\t\tregistration: ScopeRegistration | 'always',\n\t\tguards?: readonly ((e: KeyboardEvent) => boolean)[],\n\t): Disposable;\n\tregisterBindings(descriptors: readonly KeyBindingDescriptor<TScope, KeyboardEvent>[]): Disposable;\n\tpushOverlay(entry: OverlayEntry): Disposable;\n\tdispose(): void;\n};\n\n/** Owns a document-level keydown listener and dispatches it to registered bindings by scope, honoring\n * an overlay-close stack (Escape) ahead of any binding match. Framework-agnostic — consumers register\n * scopes/bindings/overlays and call {@link KeymapDispatcher.attach} once. */\nexport class KeymapDispatcher<TScope extends string> {\n\tprivate readonly isMac: boolean;\n\tprivate readonly onWarn: ((message: string) => void) | undefined;\n\tprivate readonly scopes = new Map<string, ScopeEntry>();\n\tprivate alwaysOrder: string[] = [];\n\t/** Registered descriptor groups, in registration order — kept so bindings can be rebuilt whenever\n\t * a group is added/removed or the overrides change. */\n\tprivate registrationGroups: (readonly KeyBindingDescriptor<string, KeyboardEvent>[])[] = [];\n\tprivate overrides: KeyBindingOverrides | undefined;\n\tprivate bindings: KeyBinding<string, KeyboardEvent>[] = [];\n\t/** Every registered descriptor's outcome, `undefined` when disabled by an override — lets\n\t * {@link sheetEntries} walk descriptors in registration order (not just the survivors) so a\n\t * disabled owner's row can still surface via a registered `with` partner. */\n\tprivate bindingByDescriptor = new Map<\n\t\tKeyBindingDescriptor<string, KeyboardEvent>,\n\t\tKeyBinding<string, KeyboardEvent> | undefined\n\t>();\n\tprivate overlayStack: OverlayEntry[] = [];\n\tprivate registrarCount = 0;\n\tprivate attached = false;\n\tprivate readonly root: Element | undefined;\n\n\tconstructor(options: { isMac: boolean; onWarn?: (message: string) => void; root?: Element }) {\n\t\tthis.isMac = options.isMac;\n\t\tthis.onWarn = options.onWarn;\n\t\tthis.root = options.root;\n\t}\n\n\tregisterScope(\n\t\tid: TScope,\n\t\tregistration: ScopeRegistration | 'always',\n\t\tguards: readonly ((e: KeyboardEvent) => boolean)[] = [],\n\t): Disposable {\n\t\treturn this.addScope(id, registration, guards);\n\t}\n\n\tregisterBindings(descriptors: readonly KeyBindingDescriptor<TScope, KeyboardEvent>[]): Disposable {\n\t\treturn this.addBindings(descriptors);\n\t}\n\n\tcreateRegistrar(): KeymapRegistrar<TScope> {\n\t\tconst suffix = `#${++this.registrarCount}`;\n\t\tconst owned = new Set<Disposable>();\n\t\tconst own = (disposable: Disposable): Disposable => {\n\t\t\towned.add(disposable);\n\t\t\treturn createDisposable(() => {\n\t\t\t\tif (owned.delete(disposable)) {\n\t\t\t\t\tdisposable.dispose();\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\n\t\treturn {\n\t\t\tregisterScope: (id, registration, guards = []) =>\n\t\t\t\town(this.addScope(`${id}${suffix}`, registration, guards)),\n\t\t\tregisterBindings: descriptors =>\n\t\t\t\town(this.addBindings(descriptors.map(d => ({ ...d, scope: `${d.scope}${suffix}` })))),\n\t\t\tpushOverlay: entry => own(this.pushOverlay(entry)),\n\t\t\tdispose: () => {\n\t\t\t\tfor (const disposable of owned) {\n\t\t\t\t\tdisposable.dispose();\n\t\t\t\t}\n\t\t\t\towned.clear();\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate addScope(\n\t\tid: string,\n\t\tregistration: ScopeRegistration | 'always',\n\t\tguards: readonly ((e: KeyboardEvent) => boolean)[],\n\t): Disposable {\n\t\tconst entry: ScopeEntry = { registration: registration, guards: guards };\n\t\tthis.scopes.set(id, entry);\n\t\tif (registration === 'always') {\n\t\t\tthis.alwaysOrder.push(id);\n\t\t}\n\n\t\treturn createDisposable(() => {\n\t\t\tif (this.scopes.get(id) === entry) {\n\t\t\t\tthis.scopes.delete(id);\n\t\t\t}\n\n\t\t\tthis.alwaysOrder = this.alwaysOrder.filter(scopeId => scopeId !== id);\n\t\t});\n\t}\n\n\tprivate addBindings(descriptors: readonly KeyBindingDescriptor<string, KeyboardEvent>[]): Disposable {\n\t\tthis.registrationGroups.push(descriptors);\n\t\tthis.rebuildBindings();\n\n\t\treturn createDisposable(() => {\n\t\t\tconst index = this.registrationGroups.indexOf(descriptors);\n\t\t\tif (index === -1) return;\n\n\t\t\tthis.registrationGroups.splice(index, 1);\n\t\t\tthis.rebuildBindings();\n\t\t});\n\t}\n\n\t/** Replaces the active override map and rebuilds the effective binding list. Cheap enough to call\n\t * on every config push. */\n\tsetOverrides(overrides: KeyBindingOverrides | undefined): void {\n\t\tthis.overrides = overrides;\n\t\tthis.warnIgnoredWildcards(overrides);\n\t\tthis.rebuildBindings();\n\t}\n\n\t/** Wildcards can only disable (see `resolveOverride`) — warns once per offending wildcard key so\n\t * a user who tried to rebind via `'panels.*'`/`'*'` learns why it didn't take. */\n\tprivate warnIgnoredWildcards(overrides: KeyBindingOverrides | undefined): void {\n\t\tif (!overrides || this.onWarn == null) return;\n\n\t\tfor (const key of Object.keys(overrides)) {\n\t\t\tif (key !== '*' && !key.endsWith('.*')) continue;\n\n\t\t\tconst value = overrides[key];\n\t\t\tif (value === false || value.length === 0) continue;\n\n\t\t\tthis.onWarn(`Ignoring shortcut override '${key}': a wildcard can only disable (false), not rebind`);\n\t\t}\n\t}\n\n\tprivate rebuildBindings(): void {\n\t\tconst bindings: KeyBinding<string, KeyboardEvent>[] = [];\n\t\tconst byDescriptor = new Map<\n\t\t\tKeyBindingDescriptor<string, KeyboardEvent>,\n\t\t\tKeyBinding<string, KeyboardEvent> | undefined\n\t\t>();\n\n\t\tfor (const group of this.registrationGroups) {\n\t\t\tfor (const descriptor of group) {\n\t\t\t\tconst binding = registerBinding(descriptor, this.isMac, this.overrides, this.onWarn);\n\t\t\t\tbyDescriptor.set(descriptor, binding);\n\t\t\t\tif (binding == null) continue;\n\n\t\t\t\tbindings.push(binding);\n\t\t\t}\n\t\t}\n\n\t\tthis.bindings = bindings;\n\t\tthis.bindingByDescriptor = byDescriptor;\n\t}\n\n\t/** Closes the topmost overlay willing to close, exactly as an Escape keydown would — for hosts whose\n\t * widgets consume Esc locally but still want the stack to outrank their own fallback action. */\n\tcloseTopOverlay(): boolean {\n\t\tconst candidates = resolveOverlayClose(this.overlayStack);\n\t\tfor (const entry of candidates) {\n\t\t\tif (!entry.onClose()) continue;\n\n\t\t\tconst index = this.overlayStack.indexOf(entry);\n\t\t\tif (index !== -1) {\n\t\t\t\tthis.overlayStack.splice(index, 1);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tpushOverlay(entry: OverlayEntry): Disposable {\n\t\tthis.overlayStack.push(entry);\n\n\t\treturn createDisposable(() => {\n\t\t\tconst index = this.overlayStack.indexOf(entry);\n\t\t\tif (index === -1) return;\n\n\t\t\tthis.overlayStack.splice(index, 1);\n\t\t});\n\t}\n\n\tattach(): void {\n\t\tif (this.attached) return;\n\n\t\tdocument.addEventListener('keydown', this._onKeydown, false);\n\t\tthis.attached = true;\n\t}\n\n\tdispose(): void {\n\t\tif (this.attached) {\n\t\t\tdocument.removeEventListener('keydown', this._onKeydown, false);\n\t\t\tthis.attached = false;\n\t\t}\n\n\t\tthis.scopes.clear();\n\t\tthis.alwaysOrder = [];\n\t\tthis.registrationGroups = [];\n\t\tthis.overrides = undefined;\n\t\tthis.bindings = [];\n\t\tthis.bindingByDescriptor = new Map();\n\t\tthis.overlayStack = [];\n\t}\n\n\tsheetEntries(): readonly KeymapSheetRow[] {\n\t\tconst byId = new Map<string, KeyBinding<string, KeyboardEvent>>();\n\t\tfor (const binding of this.bindings) {\n\t\t\tif (binding.id == null) continue;\n\n\t\t\tbyId.set(binding.id, binding);\n\t\t}\n\n\t\tconst partnerSegment = (\n\t\t\tpartnerBinding: KeyBinding<string, KeyboardEvent>,\n\t\t\tpartner: { keys?: readonly SheetDisplayEntry[] },\n\t\t): readonly SheetDisplayEntry[] =>\n\t\t\tpartnerBinding.overridden ? partnerBinding.keys : (partner.keys ?? partnerBinding.keys);\n\n\t\tconst rows: KeymapSheetRow[] = [];\n\t\tconst shownRows = new Set<string>();\n\t\t// KEEP: walk descriptors, not `this.bindings`, so a disabled owner still shows through a live `with` partner.\n\t\tfor (const group of this.registrationGroups) {\n\t\t\tfor (const descriptor of group) {\n\t\t\t\tif (descriptor.sheet === 'hidden') continue;\n\n\t\t\t\tconst sheet = descriptor.sheet;\n\t\t\t\tconst binding = this.bindingByDescriptor.get(descriptor);\n\n\t\t\t\tconst keys: SheetDisplayEntry[] = [];\n\t\t\t\tconst ids: string[] = [];\n\n\t\t\t\tif (binding != null) {\n\t\t\t\t\tconst self = binding.overridden ? binding.keys : (sheet.keysOverride ?? binding.keys);\n\t\t\t\t\tkeys.push(...self);\n\t\t\t\t\tif (binding.id != null) {\n\t\t\t\t\t\tids.push(binding.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const partner of sheet.with ?? []) {\n\t\t\t\t\tconst partnerBinding = byId.get(partner.id);\n\t\t\t\t\tif (partnerBinding == null) continue;\n\n\t\t\t\t\tif (keys.length > 0) {\n\t\t\t\t\t\tkeys.push('sep:/');\n\t\t\t\t\t}\n\t\t\t\t\tkeys.push(...partnerSegment(partnerBinding, partner));\n\t\t\t\t\tids.push(partner.id);\n\t\t\t\t}\n\n\t\t\t\tif (binding == null && ids.length === 0) continue;\n\n\t\t\t\t// KEEP: registrars sharing one dispatcher (one per graph) register the same rows; list each once.\n\t\t\t\tconst rowKey = [sheet.group, sheet.label, ...keys].join('\\0');\n\t\t\t\tif (shownRows.has(rowKey)) continue;\n\n\t\t\t\tshownRows.add(rowKey);\n\t\t\t\trows.push({\n\t\t\t\t\tgroup: sheet.group,\n\t\t\t\t\tlabel: sheet.label,\n\t\t\t\t\torder: sheet.order,\n\t\t\t\t\tkeys: keys,\n\t\t\t\t\tsubline: sheet.subline,\n\t\t\t\t\tsublineText: sheet.sublineText,\n\t\t\t\t\tids: ids.length > 0 ? ids : undefined,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn rows;\n\t}\n\n\tprivate readonly _onKeydown = (e: KeyboardEvent): void => {\n\t\tif (e.defaultPrevented) return;\n\t\tif (this.root != null && !e.composedPath().includes(this.root)) return;\n\n\t\tif (e.key === 'Escape' && this.overlayStack.length > 0 && this.closeTopOverlay()) {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\treturn;\n\t\t}\n\n\t\tconst chain: string[] = [];\n\t\tfor (const element of e.composedPath()) {\n\t\t\tfor (const [id, entry] of this.scopes) {\n\t\t\t\tif (entry.registration === 'always') continue;\n\t\t\t\tif (chain.includes(id)) continue;\n\n\t\t\t\tconst registration = entry.registration;\n\t\t\t\tconst matches =\n\t\t\t\t\t('root' in registration && registration.root === element) ||\n\t\t\t\t\t('selector' in registration &&\n\t\t\t\t\t\telement instanceof Element &&\n\t\t\t\t\t\telement.matches(registration.selector));\n\t\t\t\tif (matches) {\n\t\t\t\t\tchain.push(id);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const id of this.alwaysOrder) {\n\t\t\tif (!chain.includes(id)) {\n\t\t\t\tchain.push(id);\n\t\t\t}\n\t\t}\n\n\t\tconst candidates = resolveKeydown(this.bindings, chain, e);\n\t\tfor (const candidate of candidates) {\n\t\t\tconst guards = this.scopes.get(candidate.scope)?.guards ?? [];\n\t\t\tif (guards.some(guard => !guard(e))) continue;\n\n\t\t\tif (candidate.when?.some(when => !when(e))) continue;\n\n\t\t\tconst chordIndex = candidate.chords.findIndex(chord => matchesChord(chord, e));\n\t\t\tif (!candidate.run(e, chordIndex)) continue;\n\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\treturn;\n\t\t}\n\t};\n}\n"],"mappings":";;;;;;;AAoDA,IAAa,mBAAb,MAAqD;CACpD;CACA;CACA,yBAA0B,IAAI,IAAwB;CACtD,cAAgC,CAAC;;;CAGjC,qBAAyF,CAAC;CAC1F;CACA,WAAwD,CAAC;;;;CAIzD,sCAA8B,IAAI,IAGhC;CACF,eAAuC,CAAC;CACxC,iBAAyB;CACzB,WAAmB;CACnB;CAEA,YAAY,SAAiF;EAC5F,KAAK,QAAQ,QAAQ;EACrB,KAAK,SAAS,QAAQ;EACtB,KAAK,OAAO,QAAQ;CACrB;CAEA,cACC,IACA,cACA,SAAqD,CAAC,GACzC;EACb,OAAO,KAAK,SAAS,IAAI,cAAc,MAAM;CAC9C;CAEA,iBAAiB,aAAiF;EACjG,OAAO,KAAK,YAAY,WAAW;CACpC;CAEA,kBAA2C;EAC1C,MAAM,SAAS,IAAI,EAAE,KAAK;EAC1B,MAAM,wBAAQ,IAAI,IAAgB;EAClC,MAAM,OAAO,eAAuC;GACnD,MAAM,IAAI,UAAU;GACpB,OAAO,uBAAuB;IAC7B,IAAI,MAAM,OAAO,UAAU,GAC1B,WAAW,QAAQ;GAErB,CAAC;EACF;EAEA,OAAO;GACN,gBAAgB,IAAI,cAAc,SAAS,CAAC,MAC3C,IAAI,KAAK,SAAS,GAAG,KAAK,UAAU,cAAc,MAAM,CAAC;GAC1D,mBAAkB,gBACjB,IAAI,KAAK,YAAY,YAAY,KAAI,OAAM;IAAE,GAAG;IAAG,OAAO,GAAG,EAAE,QAAQ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,QAAQ,CAAC,EAAE,aAAa,CAAC,CAAC,SAAS,KAAK,IAAI,GAAG;EAEhE,IAAI,EAAE,QAAQ,YAAY,KAAK,aAAa,SAAS,KAAK,KAAK,gBAAgB,GAAG;GACjF,EAAE,eAAe;GACjB,EAAE,gBAAgB;GAClB;EACD;EAEA,MAAM,QAAkB,CAAC;EACzB,KAAK,MAAM,WAAW,EAAE,aAAa,GACpC,KAAK,MAAM,CAAC,IAAI,UAAU,KAAK,QAAQ;GACtC,IAAI,MAAM,iBAAiB,UAAU;GACrC,IAAI,MAAM,SAAS,EAAE,GAAG;GAExB,MAAM,eAAe,MAAM;GAM3B,IAJE,UAAU,gBAAgB,aAAa,SAAS,WAChD,cAAc,gBACd,mBAAmB,WACnB,QAAQ,QAAQ,aAAa,QAAQ,GAEtC,MAAM,KAAK,EAAE;EAEf;EAGD,KAAK,MAAM,MAAM,KAAK,aACrB,IAAI,CAAC,MAAM,SAAS,EAAE,GACrB,MAAM,KAAK,EAAE;EAIf,MAAM,aAAa,eAAe,KAAK,UAAU,OAAO,CAAC;EACzD,KAAK,MAAM,aAAa,YAAY;GAEnC,KADe,KAAK,OAAO,IAAI,UAAU,KAAK,CAAC,EAAE,UAAU,CAAC,EAAA,CACjD,MAAK,UAAS,CAAC,MAAM,CAAC,CAAC,GAAG;GAErC,IAAI,UAAU,MAAM,MAAK,SAAQ,CAAC,KAAK,CAAC,CAAC,GAAG;GAE5C,MAAM,aAAa,UAAU,OAAO,WAAU,UAAS,aAAa,OAAO,CAAC,CAAC;GAC7E,IAAI,CAAC,UAAU,IAAI,GAAG,UAAU,GAAG;GAEnC,EAAE,eAAe;GACjB,EAAE,gBAAgB;GAClB;EACD;CACD;AACD"}
|
package/docs/integrations.md
CHANGED
|
@@ -983,6 +983,70 @@ credential. `mutationDispatched: false` means Core stopped before sending the wr
|
|
|
983
983
|
`applied: 'maybe'` as uncertain and reconcile the issue state before retrying. A successful delete
|
|
984
984
|
requires Jira's `204` acknowledgement. Jira can also return `404` when visibility changes. [Jira Cloud REST v2 issue operations](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/)
|
|
985
985
|
|
|
986
|
+
### Azure DevOps Services work item writes
|
|
987
|
+
|
|
988
|
+
Use the work item methods on `IntegrationManager` from `@gitkraken/core-gitlens/plus/integrations/index.js`.
|
|
989
|
+
Every request names `GitCloudHostIntegrationId.AzureDevOps`, the selected `connectionId`, the Azure
|
|
990
|
+
`organizationId` and `organizationName`, and the `projectId`. Use the IDs and names returned by
|
|
991
|
+
Azure discovery. Existing-item operations also take a numeric `workItemId` scoped to that organization
|
|
992
|
+
and project.
|
|
993
|
+
|
|
994
|
+
| Method | Additional input | Success |
|
|
995
|
+
| ---------------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
996
|
+
| `getWorkItemCreateOptions` | Optional `workItemType` (Azure type name) | Enabled type names, or the selected type's fields, states, initial states and optional `bodyField`. |
|
|
997
|
+
| `getWorkItemWriteOptions` | `workItemId` | Current work item with revision, editable fields, candidate states, optional `bodyField` and delete capability. |
|
|
998
|
+
| `writeWorkItem` | `action: 'create'`, `workItemType`, `expectedAccountId`, `fields` | Created work item. |
|
|
999
|
+
| `writeWorkItem` | `action: 'edit'`, `workItemId`, `expectedAccountId`, `expectedRevision`, `fields` | Updated work item. |
|
|
1000
|
+
| `writeWorkItem` | `action: 'set-state'`, `workItemId`, `expectedAccountId`, `expectedRevision`, `state`, optional `fields` | Updated work item with state name and Azure category. |
|
|
1001
|
+
| `resolveWorkItemWriteTarget` | `workItemId`, optional `intent: 'delete'` | Canonical item and account for confirmation, with capability on delete intent. |
|
|
1002
|
+
| `deleteWorkItem` | `workItemId`, `expectedAccountId`, `expectedRevision` | Confirmed Recycle Bin result with `disposition: 'recycle-bin'`, `restorable: true`, `revision` and optional `deletedAt`. |
|
|
1003
|
+
|
|
1004
|
+
Pass the verified `accountId` returned by the options or target call as `expectedAccountId`. It is the Azure
|
|
1005
|
+
profile ID. The organization-local member ID used for viewer filters has a different purpose. Core resolves
|
|
1006
|
+
the selected read connection, checks the live Azure profile and the organization/project coordinates, and
|
|
1007
|
+
rechecks that the selected connection's credential is unchanged before dispatch. A profile that doesn't match
|
|
1008
|
+
`expectedAccountId` returns `no-connection`. Azure DevOps Services work item writes require an OAuth or Entra
|
|
1009
|
+
credential that can read the live Azure profile. Core returns `unsupported` without sending a request to
|
|
1010
|
+
Azure when the selected session has `type: 'pat'`. Before dispatch, an HTTP 401 or 403 that names a missing
|
|
1011
|
+
scope returns `insufficient-scope`, any other HTTP 401 or a sign-in page returns `no-connection`, and any
|
|
1012
|
+
other HTTP 403 returns `forbidden`.
|
|
1013
|
+
|
|
1014
|
+
Field keys are Azure reference names such as `System.Title` or `Custom.Sponsor`. For rich text, use the
|
|
1015
|
+
returned `bodyField` such as `Microsoft.VSTS.TCM.ReproSteps` when available. Options report the type's
|
|
1016
|
+
always-required writable fields, configured defaults and allowed values. A field without a value list has no
|
|
1017
|
+
`allowedValues`. Azure assigns the area and iteration when a create omits them. `System.AreaPath` and
|
|
1018
|
+
`System.IterationPath` are never required, and their values must be paths in the selected project. Of the
|
|
1019
|
+
`System.*` fields, Core accepts only `Title`, `Description`, `AssignedTo`, `Tags`, `Reason`, `History`,
|
|
1020
|
+
`AreaPath` and `IterationPath`; other fields follow Azure's read-only flag. Edits use `null` to clear a
|
|
1021
|
+
field. Send the selected state name through `set-state`. Azure applies conditional field and transition
|
|
1022
|
+
rules at save time. `Removed` is a workflow category that hides the item from boards, while delete moves it
|
|
1023
|
+
to the Recycle Bin.
|
|
1024
|
+
|
|
1025
|
+
Keep the item and revision returned by target resolution across confirmation. Edit and state changes send
|
|
1026
|
+
the expected revision as a JSON Patch precondition that Azure checks atomically. Azure exposes no such check
|
|
1027
|
+
on DELETE and doesn't enforce the project in the DELETE path. Before sending the request, Core checks the
|
|
1028
|
+
delete permission and test artifact types, then rereads the item for its project, revision and type, and
|
|
1029
|
+
rechecks the credential last. Afterwards it verifies Azure's deletion record, from the DELETE response or
|
|
1030
|
+
the Recycle Bin, by its item ID, project and revision. A plain success means the approved item was deleted
|
|
1031
|
+
at the next revision. When the record shows another project, or doesn't show exactly the next revision, the
|
|
1032
|
+
result is `{ ok: false, reason: 'target-changed', applied: true }`. It carries the deleted item's `project`
|
|
1033
|
+
and, when Azure reports it, its `revision` under `deleted`, and the Recycle Bin `deletion`. `deletedAt` is an
|
|
1034
|
+
ISO 8601 UTC timestamp, omitted when Core doesn't recognize Azure's deletion date format.
|
|
1035
|
+
`deleted.project.id` equals the approved project's ID when only the revision differs; it's absent when Core
|
|
1036
|
+
couldn't resolve the project. A missing `deleted.revision` means Azure didn't report it. Treat it as a
|
|
1037
|
+
confirmed deletion that Core can't match to the approved item and revision, not as a success. Core never
|
|
1038
|
+
sends a second DELETE, a restore or a permanent deletion. The delete capability reflects Azure's project
|
|
1039
|
+
permission. It's `allowed: 'unknown'` when Azure won't report the permission to the credential, and Azure
|
|
1040
|
+
decides at dispatch. Test artifacts use a separate Azure deletion flow and return `unsupported` for delete
|
|
1041
|
+
intent. Core identifies them by type and by Azure's test work item categories.
|
|
1042
|
+
|
|
1043
|
+
Failures use `IssueTrackerWriteFailure`, including Azure field errors on `invalid-input` and `conflict`
|
|
1044
|
+
for stale revisions. A scope refusal leaves the read connection usable. After dispatch, Azure's HTTP 401 or
|
|
1045
|
+
403 is `insufficient-scope` when Azure names the missing scope and `forbidden` otherwise. An HTTP 429,
|
|
1046
|
+
including one produced by the host's fetch, is `rate-limit` and never reported as applied. When Core cannot
|
|
1047
|
+
confirm the result of a dispatched write, it returns `applied: 'maybe'`. Reconcile the provider state before
|
|
1048
|
+
attempting a new write.
|
|
1049
|
+
|
|
986
1050
|
### GitHub and GitHub Enterprise Server pull request writes
|
|
987
1051
|
|
|
988
1052
|
Use `providerId: 'github'` and the `connectionId` that read the repository or pull request. Pass the
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitkraken/core-gitlens",
|
|
3
3
|
"description": "GitLens core — shared Git / AI / GitHub primitives for internal GitKraken consumption",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.50.0",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "GitKraken",
|