@ms-cloudpack/api-server 0.63.10 → 0.64.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.
Files changed (164) hide show
  1. package/lib/apis/addPackageOverride.d.ts +1 -1
  2. package/lib/apis/addPackageOverride.js +7 -7
  3. package/lib/apis/addPackageOverride.js.map +1 -1
  4. package/lib/apis/ensurePackageBundled.js.map +1 -1
  5. package/lib/apis/getData.d.ts +7 -13
  6. package/lib/apis/getData.d.ts.map +1 -1
  7. package/lib/apis/getData.js +3 -4
  8. package/lib/apis/getData.js.map +1 -1
  9. package/lib/apis/getLinkConfig.d.ts +2 -2
  10. package/lib/apis/getLinkConfig.d.ts.map +1 -1
  11. package/lib/apis/getLinkConfig.js +3 -2
  12. package/lib/apis/getLinkConfig.js.map +1 -1
  13. package/lib/apis/getSessionId.d.ts +2 -6
  14. package/lib/apis/getSessionId.d.ts.map +1 -1
  15. package/lib/apis/getSessionId.js +3 -4
  16. package/lib/apis/getSessionId.js.map +1 -1
  17. package/lib/apis/linkPath.d.ts +29 -3
  18. package/lib/apis/linkPath.js +2 -2
  19. package/lib/apis/linkPath.js.map +1 -1
  20. package/lib/apis/notifyLinkChange.d.ts +2 -2
  21. package/lib/apis/notifyLinkChange.d.ts.map +1 -1
  22. package/lib/apis/notifyLinkChange.js +3 -2
  23. package/lib/apis/notifyLinkChange.js.map +1 -1
  24. package/lib/apis/onDataChanged.d.ts +7 -13
  25. package/lib/apis/onDataChanged.d.ts.map +1 -1
  26. package/lib/apis/onDataChanged.js +3 -7
  27. package/lib/apis/onDataChanged.js.map +1 -1
  28. package/lib/apis/openCodeEditor.d.ts +9 -19
  29. package/lib/apis/openCodeEditor.d.ts.map +1 -1
  30. package/lib/apis/openCodeEditor.js +6 -6
  31. package/lib/apis/openCodeEditor.js.map +1 -1
  32. package/lib/apis/openConfigEditor.d.ts +1 -1
  33. package/lib/apis/openConfigEditor.d.ts.map +1 -1
  34. package/lib/apis/openConfigEditor.js +3 -2
  35. package/lib/apis/openConfigEditor.js.map +1 -1
  36. package/lib/apis/openFilePath.d.ts +6 -12
  37. package/lib/apis/openFilePath.d.ts.map +1 -1
  38. package/lib/apis/openFilePath.js +4 -4
  39. package/lib/apis/openFilePath.js.map +1 -1
  40. package/lib/apis/publishData.d.ts +7 -13
  41. package/lib/apis/publishData.d.ts.map +1 -1
  42. package/lib/apis/publishData.js +3 -3
  43. package/lib/apis/publishData.js.map +1 -1
  44. package/lib/apis/reportSpan.d.ts +10 -20
  45. package/lib/apis/reportSpan.d.ts.map +1 -1
  46. package/lib/apis/reportSpan.js +5 -5
  47. package/lib/apis/reportSpan.js.map +1 -1
  48. package/lib/apis/restartAllTasks.d.ts +1 -1
  49. package/lib/apis/restartAllTasks.d.ts.map +1 -1
  50. package/lib/apis/restartAllTasks.js +14 -7
  51. package/lib/apis/restartAllTasks.js.map +1 -1
  52. package/lib/apis/restartTask.d.ts +4 -18
  53. package/lib/apis/restartTask.d.ts.map +1 -1
  54. package/lib/apis/restartTask.js +6 -5
  55. package/lib/apis/restartTask.js.map +1 -1
  56. package/lib/apis/unlinkPath.d.ts +29 -3
  57. package/lib/apis/unlinkPath.js +2 -2
  58. package/lib/apis/unlinkPath.js.map +1 -1
  59. package/lib/apis/validatePackageOverride.d.ts +1 -1
  60. package/lib/apis/validatePackageOverride.js +5 -8
  61. package/lib/apis/validatePackageOverride.js.map +1 -1
  62. package/lib/common/createApiContext.d.ts.map +1 -1
  63. package/lib/common/createApiContext.js +4 -1
  64. package/lib/common/createApiContext.js.map +1 -1
  65. package/lib/common/createMockContext.d.ts +16 -9
  66. package/lib/common/createMockContext.d.ts.map +1 -1
  67. package/lib/common/createMockContext.js +21 -16
  68. package/lib/common/createMockContext.js.map +1 -1
  69. package/lib/common/createMockSession.d.ts +1 -1
  70. package/lib/common/createMockSession.d.ts.map +1 -1
  71. package/lib/common/createMockSession.js.map +1 -1
  72. package/lib/common/createSession.d.ts +5 -1
  73. package/lib/common/createSession.d.ts.map +1 -1
  74. package/lib/common/createSession.js +1 -1
  75. package/lib/common/createSession.js.map +1 -1
  76. package/lib/data/busSources.d.ts +27 -240
  77. package/lib/data/busSources.d.ts.map +1 -1
  78. package/lib/data/busSources.js +2 -2
  79. package/lib/data/busSources.js.map +1 -1
  80. package/lib/index.d.ts +0 -2
  81. package/lib/index.d.ts.map +1 -1
  82. package/lib/index.js.map +1 -1
  83. package/lib/trpc/common.d.ts +41 -2
  84. package/lib/trpc/common.d.ts.map +1 -1
  85. package/lib/trpc/common.js +44 -3
  86. package/lib/trpc/common.js.map +1 -1
  87. package/lib/types/BundleInfo.d.ts +1 -1
  88. package/lib/types/BundleInfo.d.ts.map +1 -1
  89. package/lib/types/BundleInfo.js.map +1 -1
  90. package/lib/types/LinkPath.d.ts +16 -92
  91. package/lib/types/LinkPath.d.ts.map +1 -1
  92. package/lib/types/LinkPath.js +21 -17
  93. package/lib/types/LinkPath.js.map +1 -1
  94. package/lib/types/Task.d.ts +20 -12
  95. package/lib/types/Task.d.ts.map +1 -1
  96. package/lib/types/Task.js.map +1 -1
  97. package/lib/types/TaskDescription.d.ts +19 -73
  98. package/lib/types/TaskDescription.d.ts.map +1 -1
  99. package/lib/types/TaskDescription.js +15 -12
  100. package/lib/types/TaskDescription.js.map +1 -1
  101. package/lib/types/TaskList.d.ts +6 -115
  102. package/lib/types/TaskList.d.ts.map +1 -1
  103. package/lib/types/TaskList.js +3 -2
  104. package/lib/types/TaskList.js.map +1 -1
  105. package/lib/types/TaskMessage.d.ts +3 -11
  106. package/lib/types/TaskMessage.d.ts.map +1 -1
  107. package/lib/types/TaskMessage.js +4 -4
  108. package/lib/types/TaskMessage.js.map +1 -1
  109. package/lib/types/TaskMessageLocation.d.ts +2 -6
  110. package/lib/types/TaskMessageLocation.d.ts.map +1 -1
  111. package/lib/types/TaskMessageLocation.js +3 -3
  112. package/lib/types/TaskMessageLocation.js.map +1 -1
  113. package/lib/types/TaskStats.d.ts +26 -17
  114. package/lib/types/TaskStats.d.ts.map +1 -1
  115. package/lib/types/TaskStats.js +4 -3
  116. package/lib/types/TaskStats.js.map +1 -1
  117. package/lib/types/Timing.d.ts +8 -18
  118. package/lib/types/Timing.d.ts.map +1 -1
  119. package/lib/types/Timing.js +5 -8
  120. package/lib/types/Timing.js.map +1 -1
  121. package/lib/types/ZodGetLinkConfigOutput.d.ts +2 -2
  122. package/lib/types/ZodGetLinkConfigOutput.d.ts.map +1 -1
  123. package/lib/types/ZodGetLinkConfigOutput.js +12 -10
  124. package/lib/types/ZodGetLinkConfigOutput.js.map +1 -1
  125. package/lib/types/ZodNotifyLinkChangeInput.d.ts +12 -44
  126. package/lib/types/ZodNotifyLinkChangeInput.d.ts.map +1 -1
  127. package/lib/types/ZodNotifyLinkChangeInput.js +7 -3
  128. package/lib/types/ZodNotifyLinkChangeInput.js.map +1 -1
  129. package/lib/types/ZodResolveMap.d.ts +2 -2
  130. package/lib/types/ZodResolveMap.d.ts.map +1 -1
  131. package/lib/types/ZodResolveMap.js +6 -6
  132. package/lib/types/ZodResolveMap.js.map +1 -1
  133. package/lib/utilities/TaskRunner.d.ts +56 -18
  134. package/lib/utilities/TaskRunner.d.ts.map +1 -1
  135. package/lib/utilities/TaskRunner.js +176 -98
  136. package/lib/utilities/TaskRunner.js.map +1 -1
  137. package/lib/utilities/createBundleTask.d.ts.map +1 -1
  138. package/lib/utilities/createBundleTask.js +9 -15
  139. package/lib/utilities/createBundleTask.js.map +1 -1
  140. package/lib/utilities/getConsumedDependencies.d.ts.map +1 -1
  141. package/lib/utilities/getConsumedDependencies.js +3 -0
  142. package/lib/utilities/getConsumedDependencies.js.map +1 -1
  143. package/lib/utilities/getConsumedPaths.d.ts.map +1 -1
  144. package/lib/utilities/getConsumedPaths.js +3 -0
  145. package/lib/utilities/getConsumedPaths.js.map +1 -1
  146. package/lib/utilities/matchingZodObject.d.ts +15 -9
  147. package/lib/utilities/matchingZodObject.d.ts.map +1 -1
  148. package/lib/utilities/matchingZodObject.js +16 -6
  149. package/lib/utilities/matchingZodObject.js.map +1 -1
  150. package/lib/utilities/notifyReload.d.ts.map +1 -1
  151. package/lib/utilities/notifyReload.js +2 -1
  152. package/lib/utilities/notifyReload.js.map +1 -1
  153. package/lib/utilities/waitForBusData.d.ts +2 -2
  154. package/lib/utilities/waitForBusData.d.ts.map +1 -1
  155. package/lib/utilities/waitForBusData.js.map +1 -1
  156. package/package.json +16 -16
  157. package/lib/types/TaskEndDescription.d.ts +0 -26
  158. package/lib/types/TaskEndDescription.d.ts.map +0 -1
  159. package/lib/types/TaskEndDescription.js +0 -8
  160. package/lib/types/TaskEndDescription.js.map +0 -1
  161. package/lib/types/TaskStartDescription.d.ts +0 -19
  162. package/lib/types/TaskStartDescription.d.ts.map +0 -1
  163. package/lib/types/TaskStartDescription.js +0 -8
  164. package/lib/types/TaskStartDescription.js.map +0 -1
@@ -1,45 +1,13 @@
1
- import { z } from 'zod';
2
- export declare const ZodNotifyLinkChangeInput: z.ZodObject<{
3
- packagePath: z.ZodString;
4
- hash: z.ZodOptional<z.ZodString>;
5
- definition: z.ZodOptional<z.ZodObject<{
6
- name: z.ZodString;
7
- version: z.ZodString;
8
- exports: z.ZodAny;
9
- dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodUndefined, z.ZodString]>>>;
10
- peerDependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodUndefined, z.ZodString]>>>;
11
- }, "strip", z.ZodTypeAny, {
12
- name: string;
13
- version: string;
14
- exports?: any;
15
- dependencies?: Record<string, string | undefined> | undefined;
16
- peerDependencies?: Record<string, string | undefined> | undefined;
17
- }, {
18
- name: string;
19
- version: string;
20
- exports?: any;
21
- dependencies?: Record<string, string | undefined> | undefined;
22
- peerDependencies?: Record<string, string | undefined> | undefined;
23
- }>>;
24
- }, "strip", z.ZodTypeAny, {
25
- packagePath: string;
26
- hash?: string | undefined;
27
- definition?: {
28
- name: string;
29
- version: string;
30
- exports?: any;
31
- dependencies?: Record<string, string | undefined> | undefined;
32
- peerDependencies?: Record<string, string | undefined> | undefined;
33
- } | undefined;
34
- }, {
35
- packagePath: string;
36
- hash?: string | undefined;
37
- definition?: {
38
- name: string;
39
- version: string;
40
- exports?: any;
41
- dependencies?: Record<string, string | undefined> | undefined;
42
- peerDependencies?: Record<string, string | undefined> | undefined;
43
- } | undefined;
44
- }>;
1
+ import { z } from 'zod/v4-mini';
2
+ export declare const ZodNotifyLinkChangeInput: z.ZodMiniObject<{
3
+ packagePath: z.ZodMiniString<string>;
4
+ hash: z.ZodMiniOptional<z.ZodMiniString<string>>;
5
+ definition: z.ZodMiniOptional<z.ZodMiniObject<{
6
+ name: z.ZodMiniString<string>;
7
+ version: z.ZodMiniString<string>;
8
+ exports: z.ZodMiniOptional<z.ZodMiniAny>;
9
+ dependencies: z.ZodMiniOptional<z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniUndefined, z.ZodMiniString<string>]>>>>;
10
+ peerDependencies: z.ZodMiniOptional<z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniUndefined, z.ZodMiniString<string>]>>>>;
11
+ }, z.core.$strip>>;
12
+ }, z.core.$strip>;
45
13
  //# sourceMappingURL=ZodNotifyLinkChangeInput.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ZodNotifyLinkChangeInput.d.ts","sourceRoot":"","sources":["../../src/types/ZodNotifyLinkChangeInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAInC,CAAC"}
1
+ {"version":3,"file":"ZodNotifyLinkChangeInput.d.ts","sourceRoot":"","sources":["../../src/types/ZodNotifyLinkChangeInput.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAGhC,eAAO,MAAM,wBAAwB;;;;;;;;;;iBAInC,CAAC"}
@@ -1,8 +1,12 @@
1
- import { z } from 'zod';
1
+ //
2
+ // This must be in a separate file because it's imported by busSources.ts, which is also used
3
+ // in the browser, so it must only import zod types.
4
+ //
5
+ import { z } from 'zod/v4-mini';
2
6
  import { ZodLinkPackageDefinition } from '../types/LinkPath.js';
3
7
  export const ZodNotifyLinkChangeInput = z.object({
4
8
  packagePath: z.string(),
5
- hash: z.string().optional(),
6
- definition: ZodLinkPackageDefinition.optional(),
9
+ hash: z.optional(z.string()),
10
+ definition: z.optional(ZodLinkPackageDefinition),
7
11
  });
8
12
  //# sourceMappingURL=ZodNotifyLinkChangeInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ZodNotifyLinkChangeInput.js","sourceRoot":"","sources":["../../src/types/ZodNotifyLinkChangeInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,UAAU,EAAE,wBAAwB,CAAC,QAAQ,EAAE;CAChD,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { ZodLinkPackageDefinition } from '../types/LinkPath.js';\n\nexport const ZodNotifyLinkChangeInput = z.object({\n packagePath: z.string(),\n hash: z.string().optional(),\n definition: ZodLinkPackageDefinition.optional(),\n});\n"]}
1
+ {"version":3,"file":"ZodNotifyLinkChangeInput.js","sourceRoot":"","sources":["../../src/types/ZodNotifyLinkChangeInput.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,6FAA6F;AAC7F,oDAAoD;AACpD,EAAE;AACF,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAChC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC5B,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,wBAAwB,CAAC;CACjD,CAAC,CAAC","sourcesContent":["//\n// This must be in a separate file because it's imported by busSources.ts, which is also used\n// in the browser, so it must only import zod types.\n//\nimport { z } from 'zod/v4-mini';\nimport { ZodLinkPackageDefinition } from '../types/LinkPath.js';\n\nexport const ZodNotifyLinkChangeInput = z.object({\n packagePath: z.string(),\n hash: z.optional(z.string()),\n definition: z.optional(ZodLinkPackageDefinition),\n});\n"]}
@@ -1,4 +1,4 @@
1
- import { type ZodSchema } from 'zod';
1
+ import { z } from 'zod/v4-mini';
2
2
  import type { ResolveMap } from '@ms-cloudpack/common-types';
3
- export declare const ZodResolveMap: ZodSchema<ResolveMap>;
3
+ export declare const ZodResolveMap: z.ZodMiniType<ResolveMap, ResolveMap>;
4
4
  //# sourceMappingURL=ZodResolveMap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ZodResolveMap.d.ts","sourceRoot":"","sources":["../../src/types/ZodResolveMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,KAAK,SAAS,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,4BAA4B,CAAC;AAgB9E,eAAO,MAAM,aAAa,EAAE,SAAS,CAAC,UAAU,CAA4C,CAAC"}
1
+ {"version":3,"file":"ZodResolveMap.d.ts","sourceRoot":"","sources":["../../src/types/ZodResolveMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,4BAA4B,CAAC;AAqB9E,eAAO,MAAM,aAAa,EAAE,CAAC,CAAC,WAAW,CAAC,UAAU,EAAE,UAAU,CAA4C,CAAC"}
@@ -1,14 +1,14 @@
1
- import { z } from 'zod';
1
+ import { z } from 'zod/v4-mini';
2
2
  import { matchingZodObject } from '../utilities/matchingZodObject.js';
3
3
  const ZodResolveMapEntry = z.lazy(() => matchingZodObject({
4
4
  name: z.string(),
5
5
  version: z.string(),
6
6
  path: z.string(),
7
- dependencies: z.record(z.string()),
8
- requiredBy: z.record(z.string()),
9
- isExternal: z.boolean().optional(),
10
- isLinked: z.boolean().optional(),
11
- scopedVersions: z.record(z.lazy(() => ZodResolveMapEntry)).optional(),
7
+ dependencies: z.record(z.string(), z.string()),
8
+ requiredBy: z.record(z.string(), z.string()),
9
+ isExternal: z.optional(z.boolean()),
10
+ isLinked: z.optional(z.boolean()),
11
+ scopedVersions: z.optional(z.record(z.string(), z.lazy(() => ZodResolveMapEntry))),
12
12
  }));
13
13
  export const ZodResolveMap = z.record(z.string(), ZodResolveMapEntry);
14
14
  //# sourceMappingURL=ZodResolveMap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ZodResolveMap.js","sourceRoot":"","sources":["../../src/types/ZodResolveMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAkB,MAAM,KAAK,CAAC;AAExC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,MAAM,kBAAkB,GAA+B,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACjE,iBAAiB,CAAkB;IACjC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAChC,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAClC,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAChC,cAAc,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,QAAQ,EAAE;CACtE,CAAC,CACH,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAA0B,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { z, type ZodSchema } from 'zod';\nimport type { ResolveMap, ResolveMapEntry } from '@ms-cloudpack/common-types';\nimport { matchingZodObject } from '../utilities/matchingZodObject.js';\n\nconst ZodResolveMapEntry: ZodSchema<ResolveMapEntry> = z.lazy(() =>\n matchingZodObject<ResolveMapEntry>({\n name: z.string(),\n version: z.string(),\n path: z.string(),\n dependencies: z.record(z.string()),\n requiredBy: z.record(z.string()),\n isExternal: z.boolean().optional(),\n isLinked: z.boolean().optional(),\n scopedVersions: z.record(z.lazy(() => ZodResolveMapEntry)).optional(),\n }),\n);\n\nexport const ZodResolveMap: ZodSchema<ResolveMap> = z.record(z.string(), ZodResolveMapEntry);\n"]}
1
+ {"version":3,"file":"ZodResolveMap.js","sourceRoot":"","sources":["../../src/types/ZodResolveMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAEhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,MAAM,kBAAkB,GAAoD,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACtF,iBAAiB,CAAkB;IACjC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IAC9C,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IAC5C,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACnC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACjC,cAAc,EAAE,CAAC,CAAC,QAAQ,CACxB,CAAC,CAAC,MAAM,CACN,CAAC,CAAC,MAAM,EAAE,EACV,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,CACjC,CACF;CACF,CAAC,CACH,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAA0C,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { z } from 'zod/v4-mini';\nimport type { ResolveMap, ResolveMapEntry } from '@ms-cloudpack/common-types';\nimport { matchingZodObject } from '../utilities/matchingZodObject.js';\n\nconst ZodResolveMapEntry: z.ZodMiniType<ResolveMapEntry, ResolveMapEntry> = z.lazy(() =>\n matchingZodObject<ResolveMapEntry>({\n name: z.string(),\n version: z.string(),\n path: z.string(),\n dependencies: z.record(z.string(), z.string()),\n requiredBy: z.record(z.string(), z.string()),\n isExternal: z.optional(z.boolean()),\n isLinked: z.optional(z.boolean()),\n scopedVersions: z.optional(\n z.record(\n z.string(),\n z.lazy(() => ZodResolveMapEntry),\n ),\n ),\n }),\n);\n\nexport const ZodResolveMap: z.ZodMiniType<ResolveMap, ResolveMap> = z.record(z.string(), ZodResolveMapEntry);\n"]}
@@ -1,21 +1,39 @@
1
- import type { Task } from '../types/Task.js';
2
1
  import type { DataBus } from '@ms-cloudpack/data-bus';
2
+ import type { Task } from '../types/Task.js';
3
+ import type { TaskStats } from '../types/TaskStats.js';
3
4
  /**
4
5
  * TaskRunner tracks the status of tasks, manages concurrency, allows reusing task results,
5
6
  * and sends notifications about task status to the data bus (currently just used for `start`).
6
7
  *
7
8
  * NOTE: To enable data bus notifications, you must call `connectToBus()`.
8
9
  * `createApiContext` does this with the `taskRunner` passed in.
10
+ * (`createPartialApiContext` does not create or connect a data bus.)
9
11
  */
10
12
  export declare class TaskRunner {
11
13
  private _bus;
12
- private _queue;
13
- private _taskStats;
14
- private _pendingTasks;
15
- private _completedTasks;
16
- private _requiresRerun;
17
- private _prevTasks;
14
+ private readonly _queue;
15
+ /** Stats about task errors/warnings, only updated if a bus is connected */
16
+ private _taskIssues;
17
+ /**
18
+ * Tasks that are currently either running or waiting. (Note that `PQeueue`'s definition of
19
+ * "pending" is slightly different: it only counts tasks that are currently running.)
20
+ */
21
+ private readonly _pendingTasks;
22
+ /** Tasks that have completed */
23
+ private readonly _completedTasks;
24
+ /**
25
+ * Task IDs where a re-run was requested while the task was running.
26
+ * We let the current task finish, and then re-run it.
27
+ */
28
+ private readonly _requiresRerun;
29
+ /** All previously-seen tasks (regardless of state) */
30
+ private readonly _allTasks;
18
31
  constructor();
32
+ /**
33
+ * Get current task stats. Public for testing.
34
+ * @internal
35
+ */
36
+ get _taskStats(): Readonly<TaskStats>;
19
37
  /**
20
38
  * Connects the TaskRunner to the data bus. Tasks will still run without this, but they won't
21
39
  * send any notifications to a client (which only matters if a client is listening, e.g.
@@ -27,29 +45,43 @@ export declare class TaskRunner {
27
45
  *
28
46
  * If a task with the same `id` was already added, it returns either the previous result
29
47
  * (if completed) or the promise (if pending). Pass `options.rerun` to force re-running.
48
+ *
49
+ * (Note that any re-runs will use the *original* task function, not the new one.
50
+ * If something has changed that requires a new task function, you should incorporate this
51
+ * into the `id`.)
30
52
  */
31
53
  add<TReturn>(task: Task<TReturn>, options?: {
32
54
  rerun?: boolean;
33
55
  priority?: number;
34
56
  }): Promise<TReturn>;
35
57
  /**
36
- * The remove method disposes a task if available
37
- * and then removes it from the TaskRunner.
38
- *
39
- * This is useful when the state of a task needs to be cleared.
58
+ * Dispose in-memory resources of all tasks and clear the TaskRunner's state.
59
+ */
60
+ dispose(): void;
61
+ /**
62
+ * Clear the result of a specific task (could involve deleting files from disk) and remove
63
+ * it from the TaskRunner's task records.
64
+ */
65
+ clearResult(id: string): Promise<void>;
66
+ /**
67
+ * Clear the results of all tasks (might include deleting files on disk) and clear the
68
+ * TaskRunner's task records.
40
69
  *
41
- * It is intended to be used by the api server
42
- * to clear the TaskRunner's state before reloading the page.
70
+ * (To only dispose in-memory resources, use `dispose()`.)
43
71
  */
44
- remove(id: string): void;
72
+ clearAllResults(): Promise<void>;
45
73
  /**
46
- * The clear method disposes all tasks and clears the TaskRunner.
74
+ * Pauses the TaskRunner (for testing).
75
+ * @internal
47
76
  */
48
- clear(): void;
49
- /** Pauses the TaskRunner (for testing). */
50
77
  _pause(): void;
51
- /** Starts or resumes the TaskRunner (for testing). */
78
+ /**
79
+ * Starts or resumes the TaskRunner (for testing).
80
+ * @internal
81
+ */
52
82
  _start(): void;
83
+ /** Remove any records of previous issues with this task from the totals */
84
+ private _removeTaskIssues;
53
85
  /**
54
86
  * Internal method to report the start of a task to the bus.
55
87
  */
@@ -58,5 +90,11 @@ export declare class TaskRunner {
58
90
  * Internal method to report the end of a task to the bus.
59
91
  */
60
92
  private _reportEnd;
93
+ /** Get the task list from the data bus, and find the task's index. */
94
+ private _findFromTaskList;
95
+ /**
96
+ * Publish tasks and/or stats to the data bus.
97
+ */
98
+ private _publishUpdates;
61
99
  }
62
100
  //# sourceMappingURL=TaskRunner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TaskRunner.d.ts","sourceRoot":"","sources":["../../src/utilities/TaskRunner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAK7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD;;;;;;GAMG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,IAAI,CAAsB;IAClC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,aAAa,CAAgC;IACrD,OAAO,CAAC,eAAe,CAAuB;IAC9C,OAAO,CAAC,cAAc,CAAc;IACpC,OAAO,CAAC,UAAU,CAA6B;;IAW/C;;;;OAIG;IACI,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI;IAIvC;;;;;OAKG;IACH,GAAG,CAAC,OAAO,EACT,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,EACnB,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GACA,OAAO,CAAC,OAAO,CAAC;IAiEnB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAgBxB;;OAEG;IACH,KAAK,IAAI,IAAI;IASb,2CAA2C;IAC3C,MAAM,IAAI,IAAI;IAId,sDAAsD;IACtD,MAAM,IAAI,IAAI;IAId;;OAEG;IACH,OAAO,CAAC,YAAY;IAoCpB;;OAEG;IACH,OAAO,CAAC,UAAU;CA8BnB"}
1
+ {"version":3,"file":"TaskRunner.d.ts","sourceRoot":"","sources":["../../src/utilities/TaskRunner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAGtD,OAAO,KAAK,EAAE,IAAI,EAAsB,MAAM,kBAAkB,CAAC;AAGjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AASvD;;;;;;;GAOG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,IAAI,CAAsB;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,2EAA2E;IAC3E,OAAO,CAAC,WAAW,CAAiB;IACpC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgC;IAC9D,gCAAgC;IAChC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAuB;IACvD;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAc;IAC7C,sDAAsD;IACtD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6B;;IAWvD;;;OAGG;IACH,IAAI,UAAU,IAAI,QAAQ,CAAC,SAAS,CAAC,CAQpC;IAED;;;;OAIG;IACI,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI;IAIvC;;;;;;;;;OASG;IACH,GAAG,CAAC,OAAO,EACT,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,EACnB,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GACA,OAAO,CAAC,OAAO,CAAC;IAyEnB;;OAEG;IAGH,OAAO,IAAI,IAAI;IAYf;;;OAGG;IACG,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB5C;;;;;OAKG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IActC;;;OAGG;IACH,MAAM,IAAI,IAAI;IAId;;;OAGG;IACH,MAAM,IAAI,IAAI;IAId,2EAA2E;IAC3E,OAAO,CAAC,iBAAiB;IAOzB;;OAEG;IACH,OAAO,CAAC,YAAY;IAqBpB;;OAEG;IACH,OAAO,CAAC,UAAU;IA0ClB,sEAAsE;IACtE,OAAO,CAAC,iBAAiB;IAMzB;;OAEG;IACH,OAAO,CAAC,eAAe;CAMxB"}
@@ -1,27 +1,52 @@
1
1
  import PQueue from 'p-queue';
2
- import { taskListSource, taskStatsSource } from '../index.browser.js';
2
+ import { taskListSource, taskStatsSource } from '../data/busSources.js';
3
3
  /**
4
4
  * TaskRunner tracks the status of tasks, manages concurrency, allows reusing task results,
5
5
  * and sends notifications about task status to the data bus (currently just used for `start`).
6
6
  *
7
7
  * NOTE: To enable data bus notifications, you must call `connectToBus()`.
8
8
  * `createApiContext` does this with the `taskRunner` passed in.
9
+ * (`createPartialApiContext` does not create or connect a data bus.)
9
10
  */
10
11
  export class TaskRunner {
11
12
  _bus;
12
13
  _queue;
13
- _taskStats;
14
+ /** Stats about task errors/warnings, only updated if a bus is connected */
15
+ _taskIssues;
16
+ /**
17
+ * Tasks that are currently either running or waiting. (Note that `PQeueue`'s definition of
18
+ * "pending" is slightly different: it only counts tasks that are currently running.)
19
+ */
14
20
  _pendingTasks;
21
+ /** Tasks that have completed */
15
22
  _completedTasks;
23
+ /**
24
+ * Task IDs where a re-run was requested while the task was running.
25
+ * We let the current task finish, and then re-run it.
26
+ */
16
27
  _requiresRerun;
17
- _prevTasks;
28
+ /** All previously-seen tasks (regardless of state) */
29
+ _allTasks;
18
30
  constructor() {
19
31
  this._queue = new PQueue({ concurrency: 10 });
20
- this._taskStats = getDefaultTaskStats();
32
+ this._taskIssues = { totalErrors: 0, totalWarnings: 0, taskWarnings: {}, taskErrors: {} };
21
33
  this._pendingTasks = new Map();
22
34
  this._completedTasks = new Map();
23
35
  this._requiresRerun = new Set();
24
- this._prevTasks = new Map();
36
+ this._allTasks = new Map();
37
+ }
38
+ /**
39
+ * Get current task stats. Public for testing.
40
+ * @internal
41
+ */
42
+ get _taskStats() {
43
+ return {
44
+ status: this._pendingTasks.size ? 'pending' : 'idle',
45
+ remainingTasks: this._pendingTasks.size,
46
+ totalTasks: this._allTasks.size,
47
+ totalErrors: this._taskIssues.totalErrors,
48
+ totalWarnings: this._taskIssues.totalWarnings,
49
+ };
25
50
  }
26
51
  /**
27
52
  * Connects the TaskRunner to the data bus. Tasks will still run without this, but they won't
@@ -36,12 +61,16 @@ export class TaskRunner {
36
61
  *
37
62
  * If a task with the same `id` was already added, it returns either the previous result
38
63
  * (if completed) or the promise (if pending). Pass `options.rerun` to force re-running.
64
+ *
65
+ * (Note that any re-runs will use the *original* task function, not the new one.
66
+ * If something has changed that requires a new task function, you should incorporate this
67
+ * into the `id`.)
39
68
  */
40
69
  add(task, options) {
41
70
  const { name, id, execute } = task;
42
71
  const { rerun, priority } = options || {};
43
- if (!this._prevTasks.has(id)) {
44
- this._prevTasks.set(id, task);
72
+ if (!this._allTasks.has(id)) {
73
+ this._allTasks.set(id, task);
45
74
  }
46
75
  // Check if we are already completed the task with that id.
47
76
  const action = this._completedTasks.get(id);
@@ -58,18 +87,26 @@ export class TaskRunner {
58
87
  }
59
88
  const resultPromise = (async () => {
60
89
  let taskResult;
61
- do {
62
- // Delete from rerun list (if present).
63
- this._requiresRerun.delete(id);
64
- taskResult = await this._queue.add(execute,
65
- // Removes void from return type.
66
- // Read more on: https://github.com/sindresorhus/p-queue/issues/175
67
- { throwOnTimeout: true, priority });
68
- } while (this._requiresRerun.has(id));
69
- // Delete from pending list.
70
- this._pendingTasks.delete(id);
71
- if (task.getEndDescription) {
72
- this._reportEnd(id, task.getEndDescription(taskResult));
90
+ let taskError;
91
+ try {
92
+ do {
93
+ // Delete from rerun list (if present).
94
+ this._requiresRerun.delete(id);
95
+ taskResult = await this._queue.add(execute,
96
+ // Removes void from return type.
97
+ // Read more on: https://github.com/sindresorhus/p-queue/issues/175
98
+ { throwOnTimeout: true, priority });
99
+ } while (this._requiresRerun.has(id));
100
+ }
101
+ catch (error) {
102
+ taskError = error;
103
+ // Re-throw the error, but `finally` will handle completion
104
+ throw error;
105
+ }
106
+ finally {
107
+ // Delete from pending list.
108
+ this._pendingTasks.delete(id);
109
+ this._reportEnd(task, taskResult, taskError);
73
110
  }
74
111
  // Extra check to ensure that the task returned a value.
75
112
  // It should never throw, if it does we have a bug.
@@ -81,124 +118,165 @@ export class TaskRunner {
81
118
  return taskResult;
82
119
  })();
83
120
  this._pendingTasks.set(id, resultPromise);
84
- this._completedTasks.delete(id);
85
- if (task.getStartDescription) {
86
- this._reportStart(id, task.getStartDescription());
121
+ const wasCompleted = this._completedTasks.delete(id);
122
+ if (wasCompleted) {
123
+ this._removeTaskIssues(task.id);
87
124
  }
125
+ this._reportStart(task);
88
126
  return resultPromise;
89
127
  }
90
128
  /**
91
- * The remove method disposes a task if available
92
- * and then removes it from the TaskRunner.
93
- *
94
- * This is useful when the state of a task needs to be cleared.
95
- *
96
- * It is intended to be used by the api server
97
- * to clear the TaskRunner's state before reloading the page.
129
+ * Dispose in-memory resources of all tasks and clear the TaskRunner's state.
98
130
  */
99
- remove(id) {
100
- this._prevTasks
101
- .get(id)
102
- ?.dispose?.()
103
- .catch(() => {
104
- console.debug(`Error disposing task: ${id}`);
105
- });
106
- this._prevTasks.get(id)?.onDispose?.();
107
- this._prevTasks.delete(id);
108
- this._requiresRerun.delete(id);
109
- if (this._pendingTasks.has(id)) {
110
- this._pendingTasks.delete(id);
111
- this._taskStats.remainingTasks = this._pendingTasks.size;
131
+ // NOTE: This is also used by clearAllResults(), so if it's updated to do anything that
132
+ // renders the TaskRunner unusable/finished, the common parts should be refactored out.
133
+ dispose() {
134
+ this._queue.clear();
135
+ for (const task of this._allTasks.values()) {
136
+ task.dispose?.();
112
137
  }
138
+ this._allTasks.clear();
139
+ this._pendingTasks.clear();
140
+ this._completedTasks.clear();
141
+ this._requiresRerun.clear();
142
+ this._taskIssues = { totalErrors: 0, totalWarnings: 0, taskWarnings: {}, taskErrors: {} };
143
+ }
144
+ /**
145
+ * Clear the result of a specific task (could involve deleting files from disk) and remove
146
+ * it from the TaskRunner's task records.
147
+ */
148
+ async clearResult(id) {
149
+ const task = this._allTasks.get(id);
150
+ task?.dispose?.();
151
+ await task?.clear?.();
152
+ this._allTasks.delete(id);
153
+ this._requiresRerun.delete(id);
154
+ this._pendingTasks.delete(id);
113
155
  this._completedTasks.delete(id);
156
+ this._removeTaskIssues(id);
157
+ if (this._bus) {
158
+ const { tasks, index } = this._findFromTaskList(id);
159
+ if (index !== -1) {
160
+ tasks.splice(index, 1);
161
+ this._publishUpdates({ tasks, stats: true });
162
+ }
163
+ }
114
164
  }
115
165
  /**
116
- * The clear method disposes all tasks and clears the TaskRunner.
166
+ * Clear the results of all tasks (might include deleting files on disk) and clear the
167
+ * TaskRunner's task records.
168
+ *
169
+ * (To only dispose in-memory resources, use `dispose()`.)
117
170
  */
118
- clear() {
119
- this._taskStats = getDefaultTaskStats();
120
- this._bus?.publish(taskListSource, { tasks: [] });
121
- for (const id of this._prevTasks.keys()) {
122
- this.remove(id);
171
+ async clearAllResults() {
172
+ // Publish the empty task list first since deleting things might take awhile.
173
+ this._publishUpdates({ tasks: [] });
174
+ for (const task of this._allTasks.values()) {
175
+ task.dispose?.();
176
+ await task.clear?.();
123
177
  }
178
+ this.dispose();
179
+ // Publish new stats after clearing everything (otherwise the calculated values will be wrong)
180
+ this._publishUpdates({ stats: true });
124
181
  }
125
- /** Pauses the TaskRunner (for testing). */
182
+ /**
183
+ * Pauses the TaskRunner (for testing).
184
+ * @internal
185
+ */
126
186
  _pause() {
127
187
  this._queue.pause();
128
188
  }
129
- /** Starts or resumes the TaskRunner (for testing). */
189
+ /**
190
+ * Starts or resumes the TaskRunner (for testing).
191
+ * @internal
192
+ */
130
193
  _start() {
131
194
  this._queue.start();
132
195
  }
196
+ /** Remove any records of previous issues with this task from the totals */
197
+ _removeTaskIssues(id) {
198
+ this._taskIssues.totalErrors -= this._taskIssues.taskErrors[id] || 0;
199
+ this._taskIssues.totalWarnings -= this._taskIssues.taskWarnings[id] || 0;
200
+ delete this._taskIssues.taskErrors[id];
201
+ delete this._taskIssues.taskWarnings[id];
202
+ }
133
203
  /**
134
204
  * Internal method to report the start of a task to the bus.
135
205
  */
136
- _reportStart(id, description) {
137
- if (!this._bus)
206
+ _reportStart(task) {
207
+ if (!this._bus || !task.getStartDescription)
138
208
  return;
139
- const bus = this._bus;
140
- const { tasks } = bus.getData(taskListSource.path) || { tasks: [] };
141
- const index = tasks.findIndex((t) => t.id === id);
142
- const previousDescription = tasks[index];
143
- const now = new Date().getTime();
144
- if (!previousDescription) {
145
- this._taskStats.totalTasks++;
146
- }
147
- if (previousDescription?.status === 'complete') {
148
- this._taskStats.totalErrors -= previousDescription.errors?.length || 0;
149
- this._taskStats.totalWarnings -= previousDescription.warnings?.length || 0;
150
- }
151
- this._taskStats.remainingTasks = this._pendingTasks.size;
152
- this._taskStats.status = 'pending';
153
- const task = {
154
- ...description,
209
+ const { tasks, index } = this._findFromTaskList(task.id);
210
+ const taskDesc = {
211
+ id: task.id,
212
+ name: task.name,
213
+ ...task.getStartDescription(),
155
214
  status: 'pending',
156
- startTime: now,
215
+ startTime: Date.now(),
157
216
  };
158
217
  if (index === -1) {
159
- tasks.push(task);
218
+ tasks.push(taskDesc);
160
219
  }
161
220
  else {
162
- tasks[index] = task;
221
+ tasks[index] = taskDesc;
163
222
  }
164
- bus.publish(taskStatsSource, this._taskStats);
165
- bus.publish(taskListSource, { tasks });
223
+ this._publishUpdates({ tasks, stats: true });
166
224
  }
167
225
  /**
168
226
  * Internal method to report the end of a task to the bus.
169
227
  */
170
- _reportEnd(id, description) {
171
- if (!this._bus)
228
+ _reportEnd(task, taskResult, taskError) {
229
+ if (!this._bus || !task.getEndDescription)
172
230
  return;
173
- const bus = this._bus;
174
- const { tasks } = bus.getData(taskListSource.path) || { tasks: [] };
175
- const index = tasks.findIndex((t) => t.id === id);
176
- const previousDescription = tasks[index];
177
- const now = new Date().getTime();
178
- if (previousDescription) {
179
- this._taskStats.remainingTasks = this._pendingTasks.size;
180
- this._taskStats.totalErrors += description?.errors?.length || 0;
181
- this._taskStats.totalWarnings += description?.warnings?.length || 0;
231
+ // Replace the usual description with an error if relevant
232
+ const description = taskError
233
+ ? {
234
+ errors: [
235
+ {
236
+ source: 'running task',
237
+ text: taskError instanceof Error ? taskError.stack || taskError.message : String(taskError),
238
+ },
239
+ ],
240
+ }
241
+ : task.getEndDescription(taskResult);
242
+ const errorCount = description.errors?.length || 0;
243
+ const warningCount = description.warnings?.length || 0;
244
+ if (errorCount) {
245
+ this._taskIssues.taskErrors[task.id] = errorCount;
246
+ this._taskIssues.totalErrors += errorCount;
247
+ }
248
+ if (warningCount) {
249
+ this._taskIssues.taskWarnings[task.id] = warningCount;
250
+ this._taskIssues.totalWarnings += warningCount;
251
+ }
252
+ const { tasks, index } = this._findFromTaskList(task.id);
253
+ const startDescription = tasks[index];
254
+ if (startDescription) {
255
+ const now = Date.now();
182
256
  tasks[index] = {
183
- ...previousDescription,
257
+ ...startDescription,
184
258
  ...description,
185
259
  status: 'complete',
186
- durationMilliseconds: now - previousDescription.startTime,
260
+ duration: now - startDescription.startTime,
187
261
  lastUpdated: now,
188
262
  };
189
- if (this._taskStats.remainingTasks === 0) {
190
- this._taskStats.status = 'idle';
191
- }
192
- bus.publish(taskStatsSource, this._taskStats);
193
- bus.publish(taskListSource, { tasks });
263
+ this._publishUpdates({ tasks, stats: true });
194
264
  }
195
265
  }
266
+ /** Get the task list from the data bus, and find the task's index. */
267
+ _findFromTaskList(id) {
268
+ const tasks = this._bus?.getData(taskListSource.path)?.tasks || [];
269
+ const index = tasks.findIndex((t) => t.id === id);
270
+ return { tasks, index };
271
+ }
272
+ /**
273
+ * Publish tasks and/or stats to the data bus.
274
+ */
275
+ _publishUpdates(params) {
276
+ const { tasks, stats } = params;
277
+ // Publish using .path for easier testing
278
+ stats && this._bus?.publish(taskStatsSource.path, this._taskStats);
279
+ tasks && this._bus?.publish(taskListSource.path, { tasks });
280
+ }
196
281
  }
197
- const getDefaultTaskStats = () => ({
198
- status: 'idle',
199
- remainingTasks: 0,
200
- totalTasks: 0,
201
- totalErrors: 0,
202
- totalWarnings: 0,
203
- });
204
282
  //# sourceMappingURL=TaskRunner.js.map