@ms-cloudpack/api-server 0.21.10 → 0.23.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 (74) hide show
  1. package/lib/apis/ensurePackageBundled.d.ts +16 -16
  2. package/lib/apis/ensurePackageBundled.d.ts.map +1 -1
  3. package/lib/apis/ensurePackageBundled.js +1 -2
  4. package/lib/apis/ensurePackageBundled.js.map +1 -1
  5. package/lib/apis/syncDownload.d.ts.map +1 -1
  6. package/lib/apis/syncDownload.js +8 -12
  7. package/lib/apis/syncDownload.js.map +1 -1
  8. package/lib/apis/syncUpload.d.ts.map +1 -1
  9. package/lib/apis/syncUpload.js +9 -14
  10. package/lib/apis/syncUpload.js.map +1 -1
  11. package/lib/common/createPartialApiContext.d.ts.map +1 -1
  12. package/lib/common/createPartialApiContext.js +16 -2
  13. package/lib/common/createPartialApiContext.js.map +1 -1
  14. package/lib/index.d.ts +0 -1
  15. package/lib/index.d.ts.map +1 -1
  16. package/lib/index.js +0 -1
  17. package/lib/index.js.map +1 -1
  18. package/lib/startApiServer.d.ts +4 -2
  19. package/lib/startApiServer.d.ts.map +1 -1
  20. package/lib/startApiServer.js +6 -61
  21. package/lib/startApiServer.js.map +1 -1
  22. package/lib/trpc/createAppRouter.d.ts +8 -8
  23. package/lib/trpc/createCloudpackServer.d.ts +6 -4
  24. package/lib/trpc/createCloudpackServer.d.ts.map +1 -1
  25. package/lib/trpc/createCloudpackServer.js.map +1 -1
  26. package/lib/trpc/createContextFactory.d.ts +2 -0
  27. package/lib/trpc/createContextFactory.d.ts.map +1 -1
  28. package/lib/trpc/createContextFactory.js +3 -1
  29. package/lib/trpc/createContextFactory.js.map +1 -1
  30. package/lib/types/ApiServer.d.ts +0 -7
  31. package/lib/types/ApiServer.d.ts.map +1 -1
  32. package/lib/types/ApiServer.js.map +1 -1
  33. package/lib/types/BundleRequest.d.ts +2 -3
  34. package/lib/types/BundleRequest.d.ts.map +1 -1
  35. package/lib/types/BundleRequest.js.map +1 -1
  36. package/lib/types/Context.d.ts +2 -0
  37. package/lib/types/Context.d.ts.map +1 -1
  38. package/lib/types/Context.js.map +1 -1
  39. package/lib/utilities/TaskRunner.d.ts +3 -1
  40. package/lib/utilities/TaskRunner.d.ts.map +1 -1
  41. package/lib/utilities/TaskRunner.js +23 -2
  42. package/lib/utilities/TaskRunner.js.map +1 -1
  43. package/lib/utilities/bundleTask.d.ts.map +1 -1
  44. package/lib/utilities/bundleTask.js +31 -13
  45. package/lib/utilities/bundleTask.js.map +1 -1
  46. package/lib/utilities/createBundleRequestForPackage.d.ts +1 -1
  47. package/lib/utilities/createBundleRequestForPackage.d.ts.map +1 -1
  48. package/lib/utilities/createBundleRequestForPackage.js +5 -7
  49. package/lib/utilities/createBundleRequestForPackage.js.map +1 -1
  50. package/lib/utilities/createBundleTask.d.ts.map +1 -1
  51. package/lib/utilities/createBundleTask.js +8 -5
  52. package/lib/utilities/createBundleTask.js.map +1 -1
  53. package/lib/utilities/createRemoteCacheClient.d.ts +7 -0
  54. package/lib/utilities/createRemoteCacheClient.d.ts.map +1 -0
  55. package/lib/utilities/createRemoteCacheClient.js +20 -0
  56. package/lib/utilities/createRemoteCacheClient.js.map +1 -0
  57. package/lib/utilities/getBundleLocation.d.ts +10 -0
  58. package/lib/utilities/getBundleLocation.d.ts.map +1 -0
  59. package/lib/utilities/{getBundleDetails.js → getBundleLocation.js} +8 -13
  60. package/lib/utilities/getBundleLocation.js.map +1 -0
  61. package/lib/utilities/getPackagesToSync.d.ts.map +1 -1
  62. package/lib/utilities/getPackagesToSync.js +6 -5
  63. package/lib/utilities/getPackagesToSync.js.map +1 -1
  64. package/lib/utilities/isCachedResultValid.d.ts.map +1 -1
  65. package/lib/utilities/isCachedResultValid.js +5 -1
  66. package/lib/utilities/isCachedResultValid.js.map +1 -1
  67. package/package.json +5 -5
  68. package/lib/utilities/getBundleDetails.d.ts +0 -16
  69. package/lib/utilities/getBundleDetails.d.ts.map +0 -1
  70. package/lib/utilities/getBundleDetails.js.map +0 -1
  71. package/lib/utilities/startWatcher.d.ts +0 -9
  72. package/lib/utilities/startWatcher.d.ts.map +0 -1
  73. package/lib/utilities/startWatcher.js +0 -51
  74. package/lib/utilities/startWatcher.js.map +0 -1
@@ -1,51 +0,0 @@
1
- import chokidar from 'chokidar';
2
- export function startWatcher(addTask) {
3
- const watched = new Set();
4
- return {
5
- watch: (task, options) => {
6
- const { id, name, dir } = task;
7
- // Have a single watcher per bundle request.
8
- if (watched.has(id) || !dir) {
9
- return;
10
- }
11
- watched.add(id);
12
- console.debug(`Initializing file watcher for ${name}`);
13
- // TODO: This is a bit of a hack. We should be able to use the watch API, but it doesn't seem to work.
14
- const watcher = chokidar.watch(dir).on('change', (event) => {
15
- console.debug(`Detected change "${event}", rebuilding "${name}"`);
16
- (async () => {
17
- // Start tracking work.
18
- let rebuilt = false;
19
- try {
20
- await addTask(task, { rerun: true });
21
- rebuilt = true;
22
- }
23
- catch (err) {
24
- console.error(`Error rebuilding "${name}":`, err?.stack || err);
25
- }
26
- const errors = task.getErrors?.();
27
- if (rebuilt && !errors?.length) {
28
- console.debug(`Notifying rebuild: ${name}`);
29
- options?.onSuccess?.();
30
- }
31
- else if (errors) {
32
- console.debug(`${name} ${errors.length} errors`);
33
- }
34
- })().catch(() => {
35
- // no-op
36
- });
37
- });
38
- task.dispose = async () => {
39
- try {
40
- await watcher.close();
41
- }
42
- catch {
43
- // ignore
44
- }
45
- task.onDispose?.();
46
- watched.delete(id);
47
- };
48
- },
49
- };
50
- }
51
- //# sourceMappingURL=startWatcher.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"startWatcher.js","sourceRoot":"","sources":["../../src/utilities/startWatcher.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAIhC,MAAM,UAAU,YAAY,CAAC,OAA6B;IACxD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAElC,OAAO;QACL,KAAK,EAAE,CA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D;gBACH,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;oBACd,QAAQ;gBACV,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,OAAO,GAAG,KAAK,IAAI,EAAE;gBACxB,IAAI;oBACF,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;iBACvB;gBAAC,MAAM;oBACN,SAAS;iBACV;gBAED,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;gBAEnB,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACrB,CAAC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import chokidar from 'chokidar';\nimport type { Task } from '../types/Task.js';\nimport type { ApiServer } from '../types/ApiServer.js';\n\nexport function startWatcher(addTask: ApiServer['addTask']) {\n const watched = new Set<string>();\n\n return {\n watch: <TReturn>(task: Task<TReturn>, options?: { onSuccess?: () => void; onDispose?: () => void }) => {\n const { id, name, dir } = task;\n // Have a single watcher per bundle request.\n if (watched.has(id) || !dir) {\n return;\n }\n\n watched.add(id);\n\n console.debug(`Initializing file watcher for ${name}`);\n\n // TODO: This is a bit of a hack. We should be able to use the watch API, but it doesn't seem to work.\n const watcher = chokidar.watch(dir).on('change', (event: string) => {\n console.debug(`Detected change \"${event}\", rebuilding \"${name}\"`);\n\n (async () => {\n // Start tracking work.\n let rebuilt = false;\n try {\n await addTask(task, { rerun: true });\n rebuilt = true;\n } catch (err) {\n console.error(`Error rebuilding \"${name}\":`, (err as Error)?.stack || err);\n }\n const errors = task.getErrors?.();\n if (rebuilt && !errors?.length) {\n console.debug(`Notifying rebuild: ${name}`);\n options?.onSuccess?.();\n } else if (errors) {\n console.debug(`${name} ${errors.length} errors`);\n }\n })().catch(() => {\n // no-op\n });\n });\n\n task.dispose = async () => {\n try {\n await watcher.close();\n } catch {\n // ignore\n }\n\n task.onDispose?.();\n\n watched.delete(id);\n };\n },\n };\n}\n"]}