@ms-cloudpack/api-server 0.46.0 → 0.46.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"openConfigEditor.d.ts","sourceRoot":"","sources":["../../src/apis/openConfigEditor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,iBAExE;yBAFqB,gBAAgB"}
1
+ {"version":3,"file":"openConfigEditor.d.ts","sourceRoot":"","sources":["../../src/apis/openConfigEditor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,iBAExE;yBAFqB,gBAAgB;;;;;;;;;iCAMgkG,cAAmB;kCAAqD,cAAmB;kCAAqD,cAAmB;mCAAsD,cAAmB"}
@@ -1 +1 @@
1
- {"version":3,"file":"restartAllTasks.d.ts","sourceRoot":"","sources":["../../src/apis/restartAllTasks.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,wBAAsB,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,EAAE,SAAS,GAAG,KAAK,GAAG,YAAY,GAAG,iBAAiB,CAAC,iBAiBlH;yBAjBqB,eAAe"}
1
+ {"version":3,"file":"restartAllTasks.d.ts","sourceRoot":"","sources":["../../src/apis/restartAllTasks.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,wBAAsB,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,EAAE,SAAS,GAAG,KAAK,GAAG,YAAY,GAAG,iBAAiB,CAAC,iBAiBlH;yBAjBqB,eAAe;;;;;;;;;iCAoB6kF,cAAmB;kCAAqD,cAAmB;kCAAqD,cAAmB;mCAAsD,cAAmB"}
@@ -58,9 +58,6 @@ export declare const taskListSource: import("@ms-cloudpack/data-bus").DataBusPat
58
58
  }>, {
59
59
  id: z.ZodString;
60
60
  errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
61
- /**
62
- * Used for tracking the reload count.
63
- */
64
61
  text: z.ZodString;
65
62
  source: z.ZodString;
66
63
  location: z.ZodOptional<z.ZodObject<{
@@ -140,9 +137,6 @@ export declare const taskListSource: import("@ms-cloudpack/data-bus").DataBusPat
140
137
  }[] | undefined;
141
138
  }>, "many">>;
142
139
  warnings: z.ZodOptional<z.ZodArray<z.ZodObject<{
143
- /**
144
- * Used for tracking the reload count.
145
- */
146
140
  text: z.ZodString;
147
141
  source: z.ZodString;
148
142
  location: z.ZodOptional<z.ZodObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"busSources.d.ts","sourceRoot":"","sources":["../../src/data/busSources.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAMpB;;GAEG;AACH,eAAO,MAAM,iBAAiB,2DAG5B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;GAG1B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAnB3B;;eAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAFH;;eAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoBD,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,2DAG3B,CAAC"}
1
+ {"version":3,"file":"busSources.d.ts","sourceRoot":"","sources":["../../src/data/busSources.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAMpB;;GAEG;AACH,eAAO,MAAM,iBAAiB,2DAG5B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;GAG1B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAGzB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,2DAG3B,CAAC"}
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type { TaskReporter } from '@ms-cloudpack/task-reporter';
3
2
  import type { BundleRequest } from '../types/BundleRequest.js';
4
3
  export declare const require: NodeRequire;
@@ -1 +1 @@
1
- {"version":3,"file":"TaskScheduler.d.ts","sourceRoot":"","sources":["../../src/task-scheduler/TaskScheduler.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAM/D,eAAO,MAAM,OAAO,aAAiC,CAAC;AAEtD,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,YAAY,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,qBAAa,aAAa;;gBAGZ,OAAO,EAAE,oBAAoB;IAMnC,YAAY,CAAC,CAAC,SAAS,aAAa,EACxC,aAAa,EAAE,CAAC,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,OAAO,EAAE;QACP,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CAcJ"}
1
+ {"version":3,"file":"TaskScheduler.d.ts","sourceRoot":"","sources":["../../src/task-scheduler/TaskScheduler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAM/D,eAAO,MAAM,OAAO,aAAiC,CAAC;AAEtD,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,YAAY,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,qBAAa,aAAa;;gBAGZ,OAAO,EAAE,oBAAoB;IAMnC,YAAY,CAAC,CAAC,SAAS,aAAa,EACxC,aAAa,EAAE,CAAC,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,OAAO,EAAE;QACP,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CAcJ"}
@@ -1,9 +1,9 @@
1
1
  /** Reusable TRPC router helper. */
2
2
  export declare const router: <TProcRouterRecord extends import("@trpc/server").ProcedureRouterRecord>(procedures: TProcRouterRecord) => import("@trpc/server").CreateRouterInner<import("@trpc/server").RootConfig<{
3
- ctx: import("../index.js").Context;
4
- meta: object;
3
+ ctx: import("../index.js").Context extends object ? import("../index.js").Context : object;
4
+ meta: unknown extends object ? object : object;
5
5
  errorShape: import("@trpc/server").DefaultErrorShape;
6
- transformer: import("@trpc/server").DefaultDataTransformer;
6
+ transformer: import("@trpc/server").DataTransformerOptions | undefined extends import("@trpc/server").DataTransformerOptions ? import("@trpc/server").DataTransformerOptions & (import("@trpc/server").DataTransformerOptions | undefined) : import("@trpc/server").DefaultDataTransformer;
7
7
  }>, TProcRouterRecord>;
8
8
  /** Reusable TRPC procedure helper. */
9
9
  export declare const publicProcedure: import("@trpc/server").ProcedureBuilder<{
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/trpc/common.ts"],"names":[],"mappings":"AAMA,mCAAmC;AACnC,eAAO,MAAM,MAAM;;;;;sBAAW,CAAC;AAE/B,sCAAsC;AACtC,eAAO,MAAM,eAAe;;;;;;;;;;;;;EAAc,CAAC"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/trpc/common.ts"],"names":[],"mappings":"AAMA,mCAAmC;AACnC,eAAO,MAAM,MAAM,oCAIioL,cAAU,kEAAkE,cAAU;;;;;sBAJ5sL,CAAC;AAE/B,sCAAsC;AACtC,eAAO,MAAM,eAAe;;;;;;;;6BACsoG,cAAmB;8BAAqD,cAAmB;8BAAqD,cAAmB;+BAAsD,cAAmB;;EADp2G,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"createAppRouter.d.ts","sourceRoot":"","sources":["../../src/trpc/createAppRouter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AAGzC,wBAAgB,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK9B;AAED,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,QAAQ,CAAC,CAAC"}
1
+ {"version":3,"file":"createAppRouter.d.ts","sourceRoot":"","sources":["../../src/trpc/createAppRouter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AAGzC,wBAAgB,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCAQyuG,cAAmB;sCAAqD,cAAmB;sCAAqD,cAAmB;uCAAsD,cAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAHn/G;AAED,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,QAAQ,CAAC,CAAC"}
@@ -8,54 +8,49 @@ export declare function createCloudpackServer(context: Context): Promise<{
8
8
  importPath: string;
9
9
  version?: string | undefined;
10
10
  issuerUrl?: string | undefined;
11
- }) => Promise<boolean>;
12
- ensurePackageBundled: (options: import("../index.js").EnsurePackageBundledInput) => Promise<import("../index.js").EnsurePackageBundledOutput>;
11
+ }) => ReturnType<typeof import("../index.js").addPackageOverride>;
12
+ ensurePackageBundled: (options: import("../index.js").EnsurePackageBundledInput) => ReturnType<typeof import("../index.js").ensurePackageBundled>;
13
13
  getData: (options: {
14
14
  path: string[];
15
- }) => any;
16
- getSessionId: (options: void) => string | undefined;
15
+ }) => ReturnType<typeof import("../index.js").getData>;
16
+ getSessionId: (options: void) => ReturnType<typeof import("../index.js").getSessionId>;
17
17
  linkPath: (options: {
18
18
  linkedPath: import("@ms-cloudpack/package-utilities").LinkedPath;
19
- }) => Promise<{
20
- resolveMap: Record<string, import("@ms-cloudpack/package-utilities").ResolveMapEntry>;
21
- linkedPaths: import("@ms-cloudpack/package-utilities").LinkedPath[];
22
- }>;
19
+ }) => ReturnType<typeof import("../index.js").linkPath>;
23
20
  onDataChanged: (options: {
24
21
  path: string[];
25
- }) => any;
22
+ }) => ReturnType<typeof import("../index.js").onDataChanged>;
26
23
  openCodeEditor: (options: {
27
24
  rootPath: string;
28
25
  line?: number | undefined;
29
26
  column?: number | undefined;
30
27
  relativePath?: string | undefined;
31
- }) => Promise<void>;
32
- openConfigEditor: (options: void) => Promise<void>;
28
+ }) => ReturnType<typeof import("../index.js").openCodeEditor>;
29
+ openConfigEditor: (options: void) => ReturnType<typeof import("../index.js").openConfigEditor>;
33
30
  openFilePath: (options: {
34
31
  rootPath: string;
35
32
  relativePath?: string | undefined;
36
- }) => Promise<void>;
33
+ }) => ReturnType<typeof import("../index.js").openFilePath>;
37
34
  reportMetric: (options: {
38
35
  value: number;
39
36
  metric: string;
40
- }) => void;
37
+ }) => ReturnType<typeof import("../index.js").reportMetric>;
41
38
  syncDownload: (options: {
42
39
  loginMethod: "interactive" | "azure-cli" | "device-code";
43
- }) => Promise<void>;
40
+ }) => ReturnType<typeof import("../index.js").syncDownload>;
44
41
  syncUpload: (options: {
45
42
  loginMethod: "interactive" | "azure-cli" | "device-code";
46
- }) => Promise<void>;
43
+ }) => ReturnType<typeof import("../index.js").syncUpload>;
47
44
  validatePackageOverride: (options: {
48
45
  packageName: string;
49
46
  importPath: string;
50
47
  issuerUrl?: string | undefined;
51
- }) => Promise<{
52
- fixable: boolean;
53
- }>;
54
- restartAllTasks: (options: void) => Promise<void>;
48
+ }) => ReturnType<typeof import("../index.js").validatePackageOverride>;
49
+ restartAllTasks: (options: void) => ReturnType<typeof import("../apis/restartAllTasks.js").restartAllTasks>;
55
50
  restartTask: (options: {
56
51
  id: string;
57
52
  inputPath: string;
58
- }) => void;
53
+ }) => ReturnType<typeof import("../apis/restartTask.js").restartTask>;
59
54
  }>;
60
55
  export type CloudpackServer = ReturnType<typeof createCloudpackServer>;
61
56
  //# sourceMappingURL=createCloudpackServer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createCloudpackServer.d.ts","sourceRoot":"","sources":["../../src/trpc/createCloudpackServer.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyC3D;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
1
+ {"version":3,"file":"createCloudpackServer.d.ts","sourceRoot":"","sources":["../../src/trpc/createCloudpackServer.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,OAAO;;;;;;;;;UA0DuB,UAAU,iDAAY;wFAAtB,UAAU,mDAAY;;;UAAtB,UAAU,sCAAY;qCAAtB,UAAU,2CAAY;;;UAAtB,UAAU,uCAAY;;;UAAtB,UAAU,4CAAY;;;;;;UAAtB,UAAU,6CAAY;yCAAtB,UAAU,+CAAY;;;;UAAtB,UAAU,2CAAY;;;;UAAtB,UAAU,2CAAY;;;UAAtB,UAAU,2CAAY;;;UAAtB,UAAU,yCAAY;;;;;UAAtB,UAAU,sDAAY;wCAAtB,UAAU,6DAAY;;;;UAAtB,UAAU,qDAAY;GAjBxG;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"createRouterFromApis.d.ts","sourceRoot":"","sources":["../../src/trpc/createRouterFromApis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,wBAAgB,oBAAoB,CAAC,KAAK,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,SAAS,EAAE,YAAY,CAAA;KAAE,CAAA;CAAE,EAAE,IAAI,EAAE,KAAK;;;;;wDAU7G"}
1
+ {"version":3,"file":"createRouterFromApis.d.ts","sourceRoot":"","sources":["../../src/trpc/createRouterFromApis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,wBAAgB,oBAAoB,CAAC,KAAK,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,SAAS,EAAE,YAAY,CAAA;KAAE,CAAA;CAAE,EAAE,IAAI,EAAE,KAAK;;;;;OAMjG,GAAG,8CAIf"}
@@ -1,5 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
1
  import type { HttpsConfig } from '@ms-cloudpack/common-types';
4
2
  import type { AnyRouter } from '@trpc/server';
5
3
  import { type NodeHTTPCreateContextFnOptions, type NodeHTTPHandlerOptions } from '@trpc/server/adapters/node-http';
@@ -1 +1 @@
1
- {"version":3,"file":"httpAdapter.d.ts","sourceRoot":"","sources":["../../src/trpc/httpAdapter.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAEL,KAAK,8BAA8B,EACnC,KAAK,sBAAsB,EAC5B,MAAM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IACH,OAAO,CAAC,YAAY;IAmCpB;;OAEG;IACH,OAAO,CAAC,UAAU;CA6BnB"}
1
+ {"version":3,"file":"TaskRunner.d.ts","sourceRoot":"","sources":["../../src/utilities/TaskRunner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAOvE;;;GAGG;AACH,qBAAa,UAAU;IAGrB,OAAO,CAAC,QAAQ,CAAgC;IAChD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAY;IAE9B,OAAO,CAAC,aAAa,CAA4B;IAEjD,OAAO,CAAC,eAAe,CAAmB;IAC1C,OAAO,CAAC,cAAc,CAAc;IAEpC,OAAO,CAAC,UAAU,CAAyB;gBAE/B,OAAO,CAAC,EAAE,iBAAiB;IAevC;;;;;OAKG;IACH,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAmE1E;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAkBxB;;OAEG;IACH,KAAK,IAAI,IAAI;IAYb,2CAA2C;IAC3C,MAAM,IAAI,IAAI;IAId,sDAAsD;IACtD,MAAM,IAAI,IAAI;IAId;;OAEG;IACH,OAAO,CAAC,YAAY;IAmCpB;;OAEG;IACH,OAAO,CAAC,UAAU;CA6BnB"}
@@ -50,22 +50,16 @@ export class TaskRunner {
50
50
  do {
51
51
  // Delete from rerun list (if present).
52
52
  this._requiresRerun.delete(id);
53
- taskResult = await this._queue.add(async () => {
54
- if (task.getStartDescription) {
55
- this._reportStart(id, task.getStartDescription());
56
- }
57
- const result = await execute();
58
- if (task.getEndDescription) {
59
- this._reportEnd(id, task.getEndDescription(result));
60
- }
61
- return result;
62
- },
53
+ taskResult = await this._queue.add(execute,
63
54
  // Removes void from return type.
64
55
  // Read more on: https://github.com/sindresorhus/p-queue/issues/175
65
56
  { throwOnTimeout: true, priority });
66
57
  } while (this._requiresRerun.has(id));
67
58
  // Delete from pending list.
68
59
  this._pendingTasks.delete(id);
60
+ if (task.getEndDescription) {
61
+ this._reportEnd(id, task.getEndDescription(taskResult));
62
+ }
69
63
  // Extra check to ensure that the task returned a value.
70
64
  // It should never throw, if it does we have a bug.
71
65
  if (taskResult === undefined) {
@@ -77,6 +71,9 @@ export class TaskRunner {
77
71
  })();
78
72
  this._pendingTasks.set(id, resultPromise);
79
73
  this._completedTasks.delete(id);
74
+ if (task.getStartDescription) {
75
+ this._reportStart(id, task.getStartDescription());
76
+ }
80
77
  return resultPromise;
81
78
  }
82
79
  /**
@@ -99,10 +96,10 @@ export class TaskRunner {
99
96
  this._prevTasks.delete(id);
100
97
  this._requiresRerun.delete(id);
101
98
  if (this._pendingTasks.has(id)) {
102
- this._taskStats.remainingTasks = Math.max(0, this._taskStats.remainingTasks - 1);
99
+ this._pendingTasks.delete(id);
100
+ this._taskStats.remainingTasks = this._pendingTasks.size;
103
101
  const { bus, session } = this._context || {};
104
102
  bus && session && bus.publish([session.id, 'status'], this._taskStats);
105
- this._pendingTasks.delete(id);
106
103
  }
107
104
  this._completedTasks.delete(id);
108
105
  }
@@ -146,7 +143,7 @@ export class TaskRunner {
146
143
  this._taskStats.totalErrors -= previousDescription.errors?.length || 0;
147
144
  this._taskStats.totalWarnings -= previousDescription.warnings?.length || 0;
148
145
  }
149
- this._taskStats.remainingTasks++;
146
+ this._taskStats.remainingTasks = this._pendingTasks.size;
150
147
  this._taskStats.status = 'pending';
151
148
  const task = {
152
149
  ...description,
@@ -174,7 +171,7 @@ export class TaskRunner {
174
171
  const previousDescription = tasks[index];
175
172
  const now = new Date().getTime();
176
173
  if (previousDescription) {
177
- this._taskStats.remainingTasks--;
174
+ this._taskStats.remainingTasks = this._pendingTasks.size;
178
175
  this._taskStats.totalErrors += description?.errors?.length || 0;
179
176
  this._taskStats.totalWarnings += description?.warnings?.length || 0;
180
177
  tasks[index] = {
@@ -1 +1 @@
1
- {"version":3,"file":"TaskRunner.js","sourceRoot":"","sources":["../../src/utilities/TaskRunner.ts"],"names":[],"mappings":"AAOA,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAwB,MAAM,qBAAqB,CAAC;AAE5F;;;GAGG;AACH,MAAM,OAAO,UAAU;IAcrB,YAAY,OAA2B;QACrC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,UAAU,GAAG,mBAAmB,EAAE,CAAC;QACxC,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;QAC/B,IAAI,CAAC,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,EAAE,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;QAE5B,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC;YACvC,GAAG,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAU,IAAmB,EAAE,OAAqB;QACrD,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QACnC,MAAM,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,UAAU;gBAClB,oBAAoB,EAAE,GAAG,GAAG,mBAAmB,CAAC,SAAS;gBACzD,WAAW,EAAE,GAAG;aACjB,CAAC;YAEF,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,KAAK,CAAC,EAAE,CAAC;gBACzC,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC;YAClC,CAAC;YAED,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YAC9C,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { TaskStartDescription } from '../types/TaskStartDescription.js';\nimport type { TaskEndDescription } from '../types/TaskEndDescription.js';\nimport type { TaskOptions } from '../types/TaskOptions.js';\nimport type { Task } from '../types/Task.js';\nimport type { TaskRunnerContext } from '../types/TaskRunnerContext.js';\nimport type { TaskStats } from '../types/TaskStats.js';\nimport type { TaskList } from '../types/TaskList.js';\nimport PQueue from 'p-queue';\nimport { getDefaultTaskStats } from './getDefaultTaskStats.js';\nimport { taskListSource, taskStatsSource, type TaskDescription } from '../index.browser.js';\n\n/**\n * TaskRunner class manages the state of Tasks.\n * This class is to be called by the api server.\n */\nexport class TaskRunner {\n // Context is used to publish task status to the bus,\n // so it is optional, as it is not needed during init or testing.\n private _context: TaskRunnerContext | undefined;\n private _queue: PQueue;\n private _taskStats: TaskStats;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _pendingTasks: Map<string, Promise<any>>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _completedTasks: Map<string, any>;\n private _requiresRerun: Set<string>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _prevTasks: Map<string, Task<any>>;\n\n constructor(context?: TaskRunnerContext) {\n this._context = context;\n this._queue = new PQueue({ concurrency: 10 });\n this._taskStats = getDefaultTaskStats();\n this._pendingTasks = new Map();\n this._completedTasks = new Map();\n this._requiresRerun = new Set();\n this._prevTasks = new Map();\n\n if (this._context) {\n const { bus, session } = this._context;\n bus.publish([session.id, 'status'], this._taskStats);\n }\n }\n\n /**\n * The add method enqueues a Task and returns its Promise.\n * If a Task with the same id has already been processed,\n * it returns either the result or the promise.\n * Rerun flag forces the Task to be run again.\n */\n add<TReturn>(task: Task<TReturn>, options?: TaskOptions): Promise<TReturn> {\n const { name, id, execute } = task;\n const { rerun, watch, priority } = options || {};\n\n watch?.();\n\n if (!this._prevTasks.get(id)) {\n this._prevTasks.set(id, task);\n }\n\n // Check if we are already completed the task with that id.\n const action = this._completedTasks.get(id) as TReturn | undefined;\n if (action !== undefined && !rerun) {\n return Promise.resolve(action);\n }\n\n // Check if we are already running the task with that id.\n const pending = this._pendingTasks.get(id) as Promise<TReturn> | undefined;\n if (pending !== undefined) {\n if (rerun) {\n this._requiresRerun.add(id);\n }\n return pending;\n }\n\n const resultPromise = (async () => {\n let taskResult: TReturn | undefined;\n\n do {\n // Delete from rerun list (if present).\n this._requiresRerun.delete(id);\n\n taskResult = await this._queue.add(\n async () => {\n if (task.getStartDescription) {\n this._reportStart(id, task.getStartDescription());\n }\n\n const result = await execute();\n\n if (task.getEndDescription) {\n this._reportEnd(id, task.getEndDescription(result));\n }\n return result;\n },\n // Removes void from return type.\n // Read more on: https://github.com/sindresorhus/p-queue/issues/175\n { throwOnTimeout: true, priority },\n );\n } while (this._requiresRerun.has(id));\n\n // Delete from pending list.\n this._pendingTasks.delete(id);\n\n // Extra check to ensure that the task returned a value.\n // It should never throw, if it does we have a bug.\n if (taskResult === undefined) {\n throw new Error(`Task \"${name}:${id}\" returned undefined, without throwing an error, which was unexpected.`);\n }\n\n // Update finished Tasks.\n this._completedTasks.set(id, taskResult);\n\n return taskResult;\n })();\n\n this._pendingTasks.set(id, resultPromise);\n this._completedTasks.delete(id);\n\n return resultPromise;\n }\n\n /**\n * The remove method disposes a task if available\n * and then removes it from the TaskRunner.\n *\n * This is useful when the state of a task needs to be cleared.\n *\n * It is intended to be used by the api server\n * to clear the TaskRunner's state before reloading the page.\n */\n remove(id: string): void {\n this._prevTasks\n .get(id)\n ?.dispose?.()\n .catch(() => {\n console.debug(`Error disposing task: ${id}`);\n });\n this._prevTasks.get(id)?.onDispose?.();\n this._prevTasks.delete(id);\n this._requiresRerun.delete(id);\n if (this._pendingTasks.has(id)) {\n this._taskStats.remainingTasks = Math.max(0, this._taskStats.remainingTasks - 1);\n const { bus, session } = this._context || {};\n bus && session && bus.publish([session.id, 'status'], this._taskStats);\n this._pendingTasks.delete(id);\n }\n this._completedTasks.delete(id);\n }\n /**\n * The clear method disposes all tasks and clears the TaskRunner.\n */\n clear(): void {\n this._taskStats = getDefaultTaskStats();\n if (this._context) {\n const { bus, session } = this._context;\n bus.publish([session.id, 'status'], this._taskStats);\n bus.publish(taskListSource, { tasks: [] });\n }\n for (const id of this._prevTasks.keys()) {\n this.remove(id);\n }\n }\n\n /** Pauses the TaskRunner (for testing). */\n _pause(): void {\n this._queue.pause();\n }\n\n /** Starts or resumes the TaskRunner (for testing). */\n _start(): void {\n this._queue.start();\n }\n\n /**\n * Internal method to report the start of a task to the bus.\n */\n private _reportStart(id: string, description: TaskStartDescription): void {\n if (!this._context) return;\n const { bus } = this._context;\n const { tasks } = bus.getData<TaskList>(taskListSource.path) || { tasks: [] };\n const index = tasks.findIndex((t) => t.id === id);\n const previousDescription = tasks[index];\n const now = new Date().getTime();\n\n if (!previousDescription) {\n this._taskStats.totalTasks++;\n }\n\n if (previousDescription?.status === 'complete') {\n this._taskStats.totalErrors -= previousDescription.errors?.length || 0;\n this._taskStats.totalWarnings -= previousDescription.warnings?.length || 0;\n }\n\n this._taskStats.remainingTasks++;\n this._taskStats.status = 'pending';\n\n const task: TaskDescription = {\n ...description,\n status: 'pending',\n startTime: now,\n };\n if (index === -1) {\n tasks.push(task);\n } else {\n tasks[index] = task;\n }\n\n bus.publish(taskStatsSource, this._taskStats);\n bus.publish(taskListSource, { tasks });\n }\n\n /**\n * Internal method to report the end of a task to the bus.\n */\n private _reportEnd(id: string, description: TaskEndDescription): void {\n if (!this._context) return;\n const { bus } = this._context;\n const { tasks } = bus.getData<TaskList>(taskListSource.path) || { tasks: [] };\n const index = tasks.findIndex((t) => t.id === id);\n const previousDescription = tasks[index];\n const now = new Date().getTime();\n\n if (previousDescription) {\n this._taskStats.remainingTasks--;\n this._taskStats.totalErrors += description?.errors?.length || 0;\n this._taskStats.totalWarnings += description?.warnings?.length || 0;\n\n tasks[index] = {\n ...previousDescription,\n ...description,\n status: 'complete',\n durationMilliseconds: now - previousDescription.startTime,\n lastUpdated: now,\n };\n\n if (this._taskStats.remainingTasks === 0) {\n this._taskStats.status = 'idle';\n }\n\n bus.publish(taskStatsSource, this._taskStats);\n bus.publish(taskListSource, { tasks });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"TaskRunner.js","sourceRoot":"","sources":["../../src/utilities/TaskRunner.ts"],"names":[],"mappings":"AAOA,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAwB,MAAM,qBAAqB,CAAC;AAE5F;;;GAGG;AACH,MAAM,OAAO,UAAU;IAcrB,YAAY,OAA2B;QACrC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,UAAU,GAAG,mBAAmB,EAAE,CAAC;QACxC,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;QAC/B,IAAI,CAAC,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,EAAE,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;QAE5B,IAAI,IAAI,CAAC,QA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AC,UAAU,CAAC,WAAW,IAAI,WAAW,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC,CAAC;YAChE,IAAI,CAAC,UAAU,CAAC,aAAa,IAAI,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC,CAAC;YAEpE,KAAK,CAAC,KAAK,CAAC,GAAG;gBACb,GAAG,mBAAmB;gBACtB,GAAG,WAAW;gBACd,MAAM,EAAE,UAAU;gBAClB,oBAAoB,EAAE,GAAG,GAAG,mBAAmB,CAAC,SAAS;gBACzD,WAAW,EAAE,GAAG;aACjB,CAAC;YAEF,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,KAAK,CAAC,EAAE,CAAC;gBACzC,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC;YAClC,CAAC;YAED,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YAC9C,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { TaskStartDescription } from '../types/TaskStartDescription.js';\nimport type { TaskEndDescription } from '../types/TaskEndDescription.js';\nimport type { TaskOptions } from '../types/TaskOptions.js';\nimport type { Task } from '../types/Task.js';\nimport type { TaskRunnerContext } from '../types/TaskRunnerContext.js';\nimport type { TaskStats } from '../types/TaskStats.js';\nimport type { TaskList } from '../types/TaskList.js';\nimport PQueue from 'p-queue';\nimport { getDefaultTaskStats } from './getDefaultTaskStats.js';\nimport { taskListSource, taskStatsSource, type TaskDescription } from '../index.browser.js';\n\n/**\n * TaskRunner class manages the state of Tasks.\n * This class is to be called by the api server.\n */\nexport class TaskRunner {\n // Context is used to publish task status to the bus,\n // so it is optional, as it is not needed during init or testing.\n private _context: TaskRunnerContext | undefined;\n private _queue: PQueue;\n private _taskStats: TaskStats;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _pendingTasks: Map<string, Promise<any>>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _completedTasks: Map<string, any>;\n private _requiresRerun: Set<string>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _prevTasks: Map<string, Task<any>>;\n\n constructor(context?: TaskRunnerContext) {\n this._context = context;\n this._queue = new PQueue({ concurrency: 10 });\n this._taskStats = getDefaultTaskStats();\n this._pendingTasks = new Map();\n this._completedTasks = new Map();\n this._requiresRerun = new Set();\n this._prevTasks = new Map();\n\n if (this._context) {\n const { bus, session } = this._context;\n bus.publish([session.id, 'status'], this._taskStats);\n }\n }\n\n /**\n * The add method enqueues a Task and returns its Promise.\n * If a Task with the same id has already been processed,\n * it returns either the result or the promise.\n * Rerun flag forces the Task to be run again.\n */\n add<TReturn>(task: Task<TReturn>, options?: TaskOptions): Promise<TReturn> {\n const { name, id, execute } = task;\n const { rerun, watch, priority } = options || {};\n\n watch?.();\n\n if (!this._prevTasks.get(id)) {\n this._prevTasks.set(id, task);\n }\n\n // Check if we are already completed the task with that id.\n const action = this._completedTasks.get(id) as TReturn | undefined;\n if (action !== undefined && !rerun) {\n return Promise.resolve(action);\n }\n\n // Check if we are already running the task with that id.\n const pending = this._pendingTasks.get(id) as Promise<TReturn> | undefined;\n if (pending !== undefined) {\n if (rerun) {\n this._requiresRerun.add(id);\n }\n return pending;\n }\n\n const resultPromise = (async () => {\n let taskResult: TReturn | undefined;\n\n do {\n // Delete from rerun list (if present).\n this._requiresRerun.delete(id);\n\n taskResult = await this._queue.add(\n execute,\n // Removes void from return type.\n // Read more on: https://github.com/sindresorhus/p-queue/issues/175\n { throwOnTimeout: true, priority },\n );\n } while (this._requiresRerun.has(id));\n\n // Delete from pending list.\n this._pendingTasks.delete(id);\n if (task.getEndDescription) {\n this._reportEnd(id, task.getEndDescription(taskResult));\n }\n\n // Extra check to ensure that the task returned a value.\n // It should never throw, if it does we have a bug.\n if (taskResult === undefined) {\n throw new Error(`Task \"${name}:${id}\" returned undefined, without throwing an error, which was unexpected.`);\n }\n\n // Update finished Tasks.\n this._completedTasks.set(id, taskResult);\n\n return taskResult;\n })();\n\n this._pendingTasks.set(id, resultPromise);\n this._completedTasks.delete(id);\n if (task.getStartDescription) {\n this._reportStart(id, task.getStartDescription());\n }\n\n return resultPromise;\n }\n\n /**\n * The remove method disposes a task if available\n * and then removes it from the TaskRunner.\n *\n * This is useful when the state of a task needs to be cleared.\n *\n * It is intended to be used by the api server\n * to clear the TaskRunner's state before reloading the page.\n */\n remove(id: string): void {\n this._prevTasks\n .get(id)\n ?.dispose?.()\n .catch(() => {\n console.debug(`Error disposing task: ${id}`);\n });\n this._prevTasks.get(id)?.onDispose?.();\n this._prevTasks.delete(id);\n this._requiresRerun.delete(id);\n if (this._pendingTasks.has(id)) {\n this._pendingTasks.delete(id);\n this._taskStats.remainingTasks = this._pendingTasks.size;\n const { bus, session } = this._context || {};\n bus && session && bus.publish([session.id, 'status'], this._taskStats);\n }\n this._completedTasks.delete(id);\n }\n /**\n * The clear method disposes all tasks and clears the TaskRunner.\n */\n clear(): void {\n this._taskStats = getDefaultTaskStats();\n if (this._context) {\n const { bus, session } = this._context;\n bus.publish([session.id, 'status'], this._taskStats);\n bus.publish(taskListSource, { tasks: [] });\n }\n for (const id of this._prevTasks.keys()) {\n this.remove(id);\n }\n }\n\n /** Pauses the TaskRunner (for testing). */\n _pause(): void {\n this._queue.pause();\n }\n\n /** Starts or resumes the TaskRunner (for testing). */\n _start(): void {\n this._queue.start();\n }\n\n /**\n * Internal method to report the start of a task to the bus.\n */\n private _reportStart(id: string, description: TaskStartDescription): void {\n if (!this._context) return;\n const { bus } = this._context;\n const { tasks } = bus.getData<TaskList>(taskListSource.path) || { tasks: [] };\n const index = tasks.findIndex((t) => t.id === id);\n const previousDescription = tasks[index];\n const now = new Date().getTime();\n\n if (!previousDescription) {\n this._taskStats.totalTasks++;\n }\n\n if (previousDescription?.status === 'complete') {\n this._taskStats.totalErrors -= previousDescription.errors?.length || 0;\n this._taskStats.totalWarnings -= previousDescription.warnings?.length || 0;\n }\n\n this._taskStats.remainingTasks = this._pendingTasks.size;\n this._taskStats.status = 'pending';\n\n const task: TaskDescription = {\n ...description,\n status: 'pending',\n startTime: now,\n };\n if (index === -1) {\n tasks.push(task);\n } else {\n tasks[index] = task;\n }\n\n bus.publish(taskStatsSource, this._taskStats);\n bus.publish(taskListSource, { tasks });\n }\n\n /**\n * Internal method to report the end of a task to the bus.\n */\n private _reportEnd(id: string, description: TaskEndDescription): void {\n if (!this._context) return;\n const { bus } = this._context;\n const { tasks } = bus.getData<TaskList>(taskListSource.path) || { tasks: [] };\n const index = tasks.findIndex((t) => t.id === id);\n const previousDescription = tasks[index];\n const now = new Date().getTime();\n\n if (previousDescription) {\n this._taskStats.remainingTasks = this._pendingTasks.size;\n this._taskStats.totalErrors += description?.errors?.length || 0;\n this._taskStats.totalWarnings += description?.warnings?.length || 0;\n\n tasks[index] = {\n ...previousDescription,\n ...description,\n status: 'complete',\n durationMilliseconds: now - previousDescription.startTime,\n lastUpdated: now,\n };\n\n if (this._taskStats.remainingTasks === 0) {\n this._taskStats.status = 'idle';\n }\n\n bus.publish(taskStatsSource, this._taskStats);\n bus.publish(taskListSource, { tasks });\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ensureFieldsExist.d.ts","sourceRoot":"","sources":["../../src/utilities/ensureFieldsExist.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,2CAY7G"}
1
+ {"version":3,"file":"ensureFieldsExist.d.ts","sourceRoot":"","sources":["../../src/utilities/ensureFieldsExist.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAW5F,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CACxD"}
@@ -7,6 +7,6 @@ import type { CloudpackConfig } from '@ms-cloudpack/common-types';
7
7
  export declare function ensureRemoteCacheEnabled({ remoteCache }: CloudpackConfig): {
8
8
  storageAccount: string;
9
9
  container: string;
10
- tenantId?: string | undefined;
10
+ tenantId?: string;
11
11
  };
12
12
  //# sourceMappingURL=ensureRemoteCacheEnabled.d.ts.map
@@ -9,6 +9,6 @@ type MatchingZodShape<T extends object> = {
9
9
  /**
10
10
  * Get a Zod object that strictly matches the expected type, including any optional properties.
11
11
  */
12
- export declare function matchingZodObject<Expected extends object>(shape: MatchingZodShape<Expected>): z.ZodObject<MatchingZodShape<Expected>, "strict", z.ZodTypeAny, Expected, Expected>;
12
+ export declare function matchingZodObject<Expected extends object>(shape: MatchingZodShape<Expected>): z.ZodObject<typeof shape, "strict", z.ZodTypeAny, Expected, Expected>;
13
13
  export {};
14
14
  //# sourceMappingURL=matchingZodObject.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"matchingZodObject.d.ts","sourceRoot":"","sources":["../../src/utilities/matchingZodObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,KAAK,gBAAgB,CAAC,CAAC,SAAS,MAAM,IAAI;KACvC,CAAC,IAAI,MAAM,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC1C,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,SAAS,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,QAAQ,CAAC,uFAG3F"}
1
+ {"version":3,"file":"matchingZodObject.d.ts","sourceRoot":"","sources":["../../src/utilities/matchingZodObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,KAAK,gBAAgB,CAAC,CAAC,SAAS,MAAM,IAAI;KACvC,CAAC,IAAI,MAAM,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC1C,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,SAAS,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GAEvD,CAAC,CAAC,SAAS,CAAC,OAAO,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC,CACzG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/api-server",
3
- "version": "0.46.0",
3
+ "version": "0.46.1",
4
4
  "description": "An implementation of the API server that does interacts with a task scheduler.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "@lage-run/logger": "^1.3.0",
28
28
  "@lage-run/scheduler": "^1.2.1",
29
29
  "@lage-run/target-graph": "^0.8.9",
30
- "@ms-cloudpack/bundler": "^0.21.3",
30
+ "@ms-cloudpack/bundler": "^0.21.4",
31
31
  "@ms-cloudpack/common-types": "^0.9.0",
32
32
  "@ms-cloudpack/config": "^0.22.0",
33
33
  "@ms-cloudpack/create-express-app": "^1.6.24",
@@ -39,9 +39,9 @@
39
39
  "@ms-cloudpack/package-utilities": "^7.7.1",
40
40
  "@ms-cloudpack/path-string-parsing": "^1.2.3",
41
41
  "@ms-cloudpack/path-utilities": "^2.7.21",
42
- "@ms-cloudpack/remote-cache": "^0.7.9",
42
+ "@ms-cloudpack/remote-cache": "^0.8.0",
43
43
  "@ms-cloudpack/task-reporter": "^0.14.1",
44
- "@ms-cloudpack/telemetry": "^0.5.3",
44
+ "@ms-cloudpack/telemetry": "^0.6.0",
45
45
  "@trpc/client": "^10.45.0",
46
46
  "@trpc/server": "^10.45.0",
47
47
  "cors": "^2.8.5",
@@ -51,7 +51,7 @@
51
51
  "get-port": "^7.0.0",
52
52
  "p-queue": "^8.0.1",
53
53
  "source-map": "^0.7.0",
54
- "uuid": "^9.0.0",
54
+ "uuid": "^10.0.0",
55
55
  "ws": "^8.16.0",
56
56
  "zod": "^3.21.4"
57
57
  },
@@ -60,7 +60,7 @@
60
60
  "@ms-cloudpack/scripts": "^0.0.1",
61
61
  "@ms-cloudpack/test-utilities": "^0.5.0",
62
62
  "@types/cors": "^2.8.13",
63
- "@types/uuid": "^9.0.8",
63
+ "@types/uuid": "^10.0.0",
64
64
  "@types/ws": "^8.5.5"
65
65
  },
66
66
  "scripts": {