@kamilio/wire 0.1.55 → 0.1.57

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 (138) hide show
  1. package/README.md +44 -1
  2. package/dist/adapters/codesignal.d.ts +10 -0
  3. package/dist/adapters/codesignal.d.ts.map +1 -0
  4. package/dist/adapters/codesignal.js +165 -0
  5. package/dist/adapters/codesignal.js.map +1 -0
  6. package/dist/adapters/document-shell.d.ts +7 -0
  7. package/dist/adapters/document-shell.d.ts.map +1 -0
  8. package/dist/adapters/document-shell.js +51 -0
  9. package/dist/adapters/document-shell.js.map +1 -0
  10. package/dist/adapters/root.d.ts.map +1 -1
  11. package/dist/adapters/root.js +74 -8
  12. package/dist/adapters/root.js.map +1 -1
  13. package/dist/auth.d.ts +2 -1
  14. package/dist/auth.d.ts.map +1 -1
  15. package/dist/auth.js +4 -2
  16. package/dist/auth.js.map +1 -1
  17. package/dist/cli.d.ts.map +1 -1
  18. package/dist/cli.js +10 -4
  19. package/dist/cli.js.map +1 -1
  20. package/dist/document-shell-engine.mjs +1880 -0
  21. package/dist/executable.d.ts.map +1 -1
  22. package/dist/executable.js +3 -2
  23. package/dist/executable.js.map +1 -1
  24. package/dist/hooks.d.ts.map +1 -1
  25. package/dist/hooks.js +19 -19
  26. package/dist/hooks.js.map +1 -1
  27. package/node_modules/provider-asana/dist/asana-project.d.ts +7 -1
  28. package/node_modules/provider-asana/dist/asana-project.d.ts.map +1 -1
  29. package/node_modules/provider-asana/dist/asana-task.d.ts +7 -1
  30. package/node_modules/provider-asana/dist/asana-task.d.ts.map +1 -1
  31. package/node_modules/provider-asana/dist/index.d.ts +14 -2
  32. package/node_modules/provider-asana/dist/index.d.ts.map +1 -1
  33. package/node_modules/provider-chatgpt/dist/chatgpt.d.ts +7 -1
  34. package/node_modules/provider-chatgpt/dist/chatgpt.d.ts.map +1 -1
  35. package/node_modules/provider-chatgpt/dist/index.d.ts +7 -1
  36. package/node_modules/provider-chatgpt/dist/index.d.ts.map +1 -1
  37. package/node_modules/provider-gmail/dist/gmail.d.ts +7 -1
  38. package/node_modules/provider-gmail/dist/gmail.d.ts.map +1 -1
  39. package/node_modules/provider-gmail/dist/index.d.ts +7 -1
  40. package/node_modules/provider-gmail/dist/index.d.ts.map +1 -1
  41. package/node_modules/provider-google-docs/dist/doc-blocks.d.ts.map +1 -1
  42. package/node_modules/provider-google-docs/dist/doc-blocks.js +6 -2
  43. package/node_modules/provider-google-docs/dist/doc-blocks.js.map +1 -1
  44. package/node_modules/provider-google-docs/dist/google-docs.d.ts +7 -1
  45. package/node_modules/provider-google-docs/dist/google-docs.d.ts.map +1 -1
  46. package/node_modules/provider-google-docs/dist/google-docs.js +31 -10
  47. package/node_modules/provider-google-docs/dist/google-docs.js.map +1 -1
  48. package/node_modules/provider-google-docs/dist/google-forms.d.ts +7 -1
  49. package/node_modules/provider-google-docs/dist/google-forms.d.ts.map +1 -1
  50. package/node_modules/provider-google-docs/dist/index.d.ts +14 -2
  51. package/node_modules/provider-google-docs/dist/index.d.ts.map +1 -1
  52. package/node_modules/provider-google-docs/src/doc-blocks.ts +8 -2
  53. package/node_modules/provider-google-docs/src/google-docs.ts +26 -10
  54. package/node_modules/provider-lattice/dist/index.d.ts +14 -2
  55. package/node_modules/provider-lattice/dist/index.d.ts.map +1 -1
  56. package/node_modules/provider-notion/dist/index.d.ts +7 -1
  57. package/node_modules/provider-notion/dist/index.d.ts.map +1 -1
  58. package/node_modules/provider-notion/dist/notion-sync.d.ts +2 -2
  59. package/node_modules/provider-notion/dist/notion-sync.d.ts.map +1 -1
  60. package/node_modules/provider-notion/dist/notion-sync.js +24 -15
  61. package/node_modules/provider-notion/dist/notion-sync.js.map +1 -1
  62. package/node_modules/provider-notion/dist/notion.d.ts +7 -1
  63. package/node_modules/provider-notion/dist/notion.d.ts.map +1 -1
  64. package/node_modules/provider-notion/dist/notion.js +1 -1
  65. package/node_modules/provider-notion/dist/notion.js.map +1 -1
  66. package/node_modules/provider-notion/src/notion-sync.ts +23 -15
  67. package/node_modules/provider-notion/src/notion.ts +1 -1
  68. package/node_modules/provider-slack/dist/index.d.ts +7 -1
  69. package/node_modules/provider-slack/dist/index.d.ts.map +1 -1
  70. package/node_modules/provider-slack/dist/slack.d.ts +7 -1
  71. package/node_modules/provider-slack/dist/slack.d.ts.map +1 -1
  72. package/node_modules/provider-zoom/dist/index.d.ts +7 -1
  73. package/node_modules/provider-zoom/dist/index.d.ts.map +1 -1
  74. package/node_modules/provider-zoom/dist/zoom-hub.d.ts +7 -1
  75. package/node_modules/provider-zoom/dist/zoom-hub.d.ts.map +1 -1
  76. package/node_modules/wire-core/dist/core/editor-receipts.d.ts +5 -0
  77. package/node_modules/wire-core/dist/core/editor-receipts.d.ts.map +1 -0
  78. package/node_modules/wire-core/dist/core/editor-receipts.js +9 -0
  79. package/node_modules/wire-core/dist/core/editor-receipts.js.map +1 -0
  80. package/node_modules/wire-core/dist/core/model.d.ts +4 -1
  81. package/node_modules/wire-core/dist/core/model.d.ts.map +1 -1
  82. package/node_modules/wire-core/dist/core/owner.d.ts +3 -0
  83. package/node_modules/wire-core/dist/core/owner.d.ts.map +1 -0
  84. package/node_modules/wire-core/dist/core/owner.js +16 -0
  85. package/node_modules/wire-core/dist/core/owner.js.map +1 -0
  86. package/node_modules/wire-core/dist/core/source.d.ts +4 -1
  87. package/node_modules/wire-core/dist/core/source.d.ts.map +1 -1
  88. package/node_modules/wire-core/dist/core/source.js +12 -2
  89. package/node_modules/wire-core/dist/core/source.js.map +1 -1
  90. package/node_modules/wire-core/dist/index.d.ts +1 -1
  91. package/node_modules/wire-core/dist/index.d.ts.map +1 -1
  92. package/node_modules/wire-core/dist/index.js +1 -1
  93. package/node_modules/wire-core/dist/index.js.map +1 -1
  94. package/node_modules/wire-core/dist/operations.d.ts +11 -2
  95. package/node_modules/wire-core/dist/operations.d.ts.map +1 -1
  96. package/node_modules/wire-core/dist/operations.js +399 -31
  97. package/node_modules/wire-core/dist/operations.js.map +1 -1
  98. package/node_modules/wire-core/dist/runtime/cookies.js +1 -1
  99. package/node_modules/wire-core/dist/runtime/cookies.js.map +1 -1
  100. package/node_modules/wire-core/dist/storage/editor-receipts.d.ts +17 -0
  101. package/node_modules/wire-core/dist/storage/editor-receipts.d.ts.map +1 -0
  102. package/node_modules/wire-core/dist/storage/editor-receipts.js +27 -0
  103. package/node_modules/wire-core/dist/storage/editor-receipts.js.map +1 -0
  104. package/node_modules/wire-core/dist/storage/history-integrity.d.ts +4 -0
  105. package/node_modules/wire-core/dist/storage/history-integrity.d.ts.map +1 -0
  106. package/node_modules/wire-core/dist/storage/history-integrity.js +32 -0
  107. package/node_modules/wire-core/dist/storage/history-integrity.js.map +1 -0
  108. package/node_modules/wire-core/dist/storage/history.d.ts +93 -0
  109. package/node_modules/wire-core/dist/storage/history.d.ts.map +1 -0
  110. package/node_modules/wire-core/dist/storage/history.js +450 -0
  111. package/node_modules/wire-core/dist/storage/history.js.map +1 -0
  112. package/node_modules/wire-core/dist/storage/registry.d.ts +2 -2
  113. package/node_modules/wire-core/dist/storage/registry.d.ts.map +1 -1
  114. package/node_modules/wire-core/dist/storage/registry.js +34 -14
  115. package/node_modules/wire-core/dist/storage/registry.js.map +1 -1
  116. package/node_modules/wire-core/dist/storage/workspace.d.ts.map +1 -1
  117. package/node_modules/wire-core/dist/storage/workspace.js +183 -40
  118. package/node_modules/wire-core/dist/storage/workspace.js.map +1 -1
  119. package/node_modules/wire-core/src/core/editor-receipts.ts +8 -0
  120. package/node_modules/wire-core/src/core/model.ts +4 -1
  121. package/node_modules/wire-core/src/core/owner.ts +16 -0
  122. package/node_modules/wire-core/src/core/source.ts +13 -1
  123. package/node_modules/wire-core/src/index.ts +1 -1
  124. package/node_modules/wire-core/src/operations.ts +339 -33
  125. package/node_modules/wire-core/src/runtime/cookies.ts +1 -1
  126. package/node_modules/wire-core/src/storage/editor-receipts.ts +27 -0
  127. package/node_modules/wire-core/src/storage/history-integrity.ts +25 -0
  128. package/node_modules/wire-core/src/storage/history.ts +331 -0
  129. package/node_modules/wire-core/src/storage/registry.ts +22 -15
  130. package/node_modules/wire-core/src/storage/workspace.ts +129 -34
  131. package/package.json +6 -2
  132. package/src/adapters/codesignal.ts +244 -0
  133. package/src/adapters/document-shell.ts +43 -0
  134. package/src/adapters/root.ts +76 -8
  135. package/src/auth.ts +6 -3
  136. package/src/cli.ts +10 -4
  137. package/src/executable.ts +3 -2
  138. package/src/hooks.ts +19 -18
package/src/hooks.ts CHANGED
@@ -7,7 +7,7 @@ import { promisify } from "node:util";
7
7
  import type { Resource, Wire, WireResult } from "wire-core";
8
8
  import { configuredWireRoot, loadWireConfig, openWireRegistry, wireRelativePath } from "wire-core";
9
9
  import type { WireWatchSyncHook } from "wire-core/internal/operations";
10
- import { wireWatchHooks } from "wire-core/internal/operations";
10
+ import { sourceLock, wireWatchHooks, withHistoryLock } from "wire-core/internal/operations";
11
11
 
12
12
  const execFileAsync = promisify(execFile);
13
13
 
@@ -106,21 +106,22 @@ function outputEnvironment(stdout: string): Record<string, string> {
106
106
  return values;
107
107
  }
108
108
 
109
- async function updateMovedResult(options: WireHookOptions, wireRoot: string, result: WireResult, movedPath: string): Promise<WireResult> {
109
+ async function updateMovedResult(options: WireHookOptions, wireRoot: string, result: WireResult, movedPath: string, tracked: boolean): Promise<WireResult> {
110
110
  const workspace = dirname(wireRoot);
111
111
  const outputPath = isAbsolute(movedPath) ? movedPath : resolve(workspace, movedPath);
112
112
  const relativePath = wireRelativePath(outputPath, wireRoot);
113
113
  const primary = primaryFilesystemLink(result.resource);
114
- const resource = {
115
- ...result.resource,
116
- filesystem_links: [
117
- ...result.resource.filesystem_links.filter((link) => !(link.path === primary.path && link.role === "primary")),
118
- { ...primary, path: relativePath },
119
- ],
120
- };
121
- if (result.summary.action !== "detached") {
122
- const registry = await openWireRegistry(wireRoot, options.home);
123
- if ((await registry.listResources()).some((item) => item.id === result.resource.id)) await registry.put(resource);
114
+ const moveLink = (r: Resource): Resource => ({ ...r, filesystem_links: r.filesystem_links.map(link =>
115
+ link.role === "primary" && link.path === primary.path ? { ...link, path: relativePath } : link) });
116
+ let resource = moveLink(result.resource);
117
+ if (result.summary.action !== "detached" && tracked) {
118
+ const source = result.resource.identifiers.find(i => i.service + ":" + i.identifier === result.resource.id)!;
119
+ resource = await withHistoryLock(wireRoot, sourceLock({ ...source, type: result.resource.type }), async () => {
120
+ const registry = await openWireRegistry(wireRoot, options.home);
121
+ const latest = await registry.get(result.resource.id);
122
+ if (primaryFilesystemLink(latest).path !== primary.path) throw new Error("The registered path changed while the hook was running. Wire kept the newer path.");
123
+ return registry.put(moveLink(latest));
124
+ });
124
125
  }
125
126
  return { ...result, resource, path: outputPath, summary: { ...result.summary, local: outputPath } };
126
127
  }
@@ -139,7 +140,7 @@ async function runHookCommands(wireRoot: string, event: WireHookEvent, environme
139
140
  return current;
140
141
  }
141
142
 
142
- async function runResourceHooks(options: WireHookOptions, command: string, result: WireResult): Promise<HookState> {
143
+ async function runResourceHooks(options: WireHookOptions, command: string, result: WireResult, tracked = true): Promise<HookState> {
143
144
  const wireRoot = await configuredWireRoot(result.path, options.home);
144
145
  if (wireRoot === null) return { result, environment: {} };
145
146
  let currentResult = result;
@@ -153,7 +154,7 @@ async function runResourceHooks(options: WireHookOptions, command: string, resul
153
154
  environment = { ...environment, ...output };
154
155
  const outputPath = output["WIRE_PATH"];
155
156
  if (outputPath !== undefined && resolve(dirname(wireRoot), outputPath) !== currentResult.path) {
156
- currentResult = await updateMovedResult(options, wireRoot, currentResult, outputPath);
157
+ currentResult = await updateMovedResult(options, wireRoot, currentResult, outputPath, tracked);
157
158
  environment = { ...environment, ...resourceEnvironment(command, options.currentDirectory, wireRoot, currentResult) };
158
159
  }
159
160
  }
@@ -170,8 +171,8 @@ async function runSummaryHooks(options: WireHookOptions, event: WireHookEvent, c
170
171
  });
171
172
  }
172
173
 
173
- async function runSingleResultHooks(options: WireHookOptions, command: string, result: WireResult): Promise<WireResult> {
174
- const state = result.summary.action === "failed" ? { result, environment: {} } : await runResourceHooks(options, command, result);
174
+ async function runSingleResultHooks(options: WireHookOptions, command: string, result: WireResult, tracked = true): Promise<WireResult> {
175
+ const state = result.summary.action === "failed" ? { result, environment: {} } : await runResourceHooks(options, command, result, tracked);
175
176
  await runSummaryHooks(options, "post-command", command, state.result.path, [state.result], state.environment);
176
177
  return state.result;
177
178
  }
@@ -198,10 +199,10 @@ export function withWireHooks(wire: Wire, options: WireHookOptions): Wire {
198
199
  const watchSyncHook: WireWatchSyncHook = (command, result) => runSingleResultHooks(options, command, result);
199
200
  return Object.freeze({
200
201
  ...wire,
201
- attach: async (url, path) => runSingleResultHooks(options, "attach", await wire.attach(url, path)),
202
+ attach: async (url, path, editorReceipts) => runSingleResultHooks(options, "attach", await wire.attach(url, path, editorReceipts)),
202
203
  create: async (url, path) => runSingleResultHooks(options, "attach", await wire.create(url, path)),
203
204
  sync: async (value, path) => runSingleResultHooks(options, "sync", await wire.sync(value, path)),
204
- downloadSource: async (url, path) => runSingleResultHooks(options, "download", await wire.downloadSource(url, path)),
205
+ downloadSource: async (url, path) => runSingleResultHooks(options, "download", await wire.downloadSource(url, path), false),
205
206
  download: async (value, path) => runSingleResultHooks(options, "download", await wire.download(value, path)),
206
207
  detach: async (value, path) => runSingleResultHooks(options, "detach", await wire.detach(value, path)),
207
208
  unlink: async (value, path) => runSingleResultHooks(options, "detach", await wire.unlink(value, path)),