@highstate/backend 0.9.16 → 0.9.18

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 (125) hide show
  1. package/dist/chunk-NAAIDR4U.js +8499 -0
  2. package/dist/chunk-NAAIDR4U.js.map +1 -0
  3. package/dist/chunk-OU5OQBLB.js +74 -0
  4. package/dist/chunk-OU5OQBLB.js.map +1 -0
  5. package/dist/{chunk-WHALQHEZ.js → chunk-Y7DXREVO.js} +502 -774
  6. package/dist/chunk-Y7DXREVO.js.map +1 -0
  7. package/dist/highstate.manifest.json +4 -4
  8. package/dist/index.js +2979 -2233
  9. package/dist/index.js.map +1 -1
  10. package/dist/library/package-resolution-worker.js +7 -5
  11. package/dist/library/package-resolution-worker.js.map +1 -1
  12. package/dist/library/worker/main.js +40 -41
  13. package/dist/library/worker/main.js.map +1 -1
  14. package/dist/magic-string.es-5ABAC4JN.js +1292 -0
  15. package/dist/magic-string.es-5ABAC4JN.js.map +1 -0
  16. package/dist/shared/index.js +3 -216
  17. package/dist/shared/index.js.map +1 -1
  18. package/package.json +9 -6
  19. package/src/artifact/encryption.ts +47 -7
  20. package/src/artifact/factory.ts +2 -2
  21. package/src/artifact/local.ts +2 -6
  22. package/src/business/__traces__/secret/update-instance-secrets/create-and-delete-secrets-simultaneously.md +356 -0
  23. package/src/business/__traces__/secret/update-instance-secrets/create-new-secrets-for-instance.md +274 -0
  24. package/src/business/__traces__/secret/update-instance-secrets/delete-existing-secrets.md +223 -0
  25. package/src/business/__traces__/secret/update-instance-secrets/no-op-when-no-changes.md +147 -0
  26. package/src/business/__traces__/secret/update-instance-secrets/update-existing-secrets.md +280 -0
  27. package/src/business/__traces__/worker/update-unit-registrations/add-new-unit-registration-when-other-exists.md +360 -0
  28. package/src/business/__traces__/worker/update-unit-registrations/add-new-unit-registration.md +215 -0
  29. package/src/business/__traces__/worker/update-unit-registrations/create-multiple-workers-with-different-identities.md +427 -0
  30. package/src/business/__traces__/worker/update-unit-registrations/handle-nonexistent-registration-id-gracefully.md +217 -0
  31. package/src/business/__traces__/worker/update-unit-registrations/no-op-when-no-changes.md +132 -0
  32. package/src/business/__traces__/worker/update-unit-registrations/recreate-worker-when-image-changes.md +454 -0
  33. package/src/business/__traces__/worker/update-unit-registrations/recreate-worker-when-image-version-changes.md +426 -0
  34. package/src/business/__traces__/worker/update-unit-registrations/recreate-worker-with-same-identity-reuses-service-account.md +372 -0
  35. package/src/business/__traces__/worker/update-unit-registrations/remove-one-of-multiple-unit-registrations.md +383 -0
  36. package/src/business/__traces__/worker/update-unit-registrations/remove-unit-registration.md +245 -0
  37. package/src/business/__traces__/worker/update-unit-registrations/update-existing-unit-registration-when-params-change.md +174 -0
  38. package/src/business/__traces__/worker/update-unit-registrations/update-params-and-image-simultaneously.md +432 -0
  39. package/src/business/__traces__/worker/update-unit-registrations/worker-with-multiple-registrations-not-deleted-when-one-removed.md +220 -0
  40. package/src/business/artifact.ts +2 -1
  41. package/src/business/index.ts +1 -0
  42. package/src/business/instance-lock.ts +3 -2
  43. package/src/business/instance-state.ts +202 -60
  44. package/src/business/project-unlock.ts +41 -23
  45. package/src/business/project.ts +299 -0
  46. package/src/business/secret.test.ts +178 -0
  47. package/src/business/secret.ts +139 -45
  48. package/src/business/worker.test.ts +614 -0
  49. package/src/business/worker.ts +289 -52
  50. package/src/common/clock.ts +18 -0
  51. package/src/common/index.ts +3 -0
  52. package/src/common/random.ts +68 -0
  53. package/src/common/test/index.ts +2 -0
  54. package/src/common/test/render.ts +98 -0
  55. package/src/common/test/tracer.ts +359 -0
  56. package/src/config.ts +5 -1
  57. package/src/hotstate/manager.ts +8 -8
  58. package/src/hotstate/validation.ts +0 -1
  59. package/src/library/abstractions.ts +20 -11
  60. package/src/library/local.ts +6 -13
  61. package/src/library/worker/evaluator.ts +30 -34
  62. package/src/library/worker/loader.lite.ts +13 -0
  63. package/src/library/worker/main.ts +8 -8
  64. package/src/library/worker/protocol.ts +0 -11
  65. package/src/lock/index.ts +1 -0
  66. package/src/lock/manager.ts +17 -2
  67. package/src/lock/test.ts +108 -0
  68. package/src/orchestrator/manager.ts +17 -36
  69. package/src/orchestrator/operation-workset.ts +34 -37
  70. package/src/orchestrator/operation.ts +129 -74
  71. package/src/project/abstractions.ts +27 -51
  72. package/src/project/evaluation.ts +248 -0
  73. package/src/project/index.ts +1 -1
  74. package/src/project/local.ts +75 -127
  75. package/src/pubsub/manager.ts +21 -13
  76. package/src/runner/abstractions.ts +29 -9
  77. package/src/runner/artifact-env.ts +3 -3
  78. package/src/runner/local.ts +29 -19
  79. package/src/runner/pulumi.ts +4 -1
  80. package/src/services.ts +77 -24
  81. package/src/shared/models/backend/library.ts +4 -4
  82. package/src/shared/models/backend/project.ts +25 -6
  83. package/src/shared/models/backend/unlock-method.ts +1 -1
  84. package/src/shared/models/base.ts +1 -84
  85. package/src/shared/models/project/api-key.ts +5 -2
  86. package/src/shared/models/project/artifact.ts +3 -33
  87. package/src/shared/models/project/index.ts +1 -2
  88. package/src/shared/models/project/lock.ts +3 -3
  89. package/src/shared/models/project/model.ts +14 -0
  90. package/src/shared/models/project/operation.ts +3 -3
  91. package/src/shared/models/project/page.ts +3 -3
  92. package/src/shared/models/project/secret.ts +4 -18
  93. package/src/shared/models/project/service-account.ts +2 -2
  94. package/src/shared/models/project/state.ts +32 -15
  95. package/src/shared/models/project/terminal.ts +4 -5
  96. package/src/shared/models/project/trigger.ts +1 -1
  97. package/src/shared/models/project/unlock-method.ts +9 -2
  98. package/src/shared/models/project/worker.ts +9 -7
  99. package/src/shared/resolvers/graph-resolver.ts +41 -26
  100. package/src/shared/resolvers/input.ts +47 -5
  101. package/src/shared/resolvers/validation.ts +23 -7
  102. package/src/shared/utils/args.ts +25 -0
  103. package/src/shared/utils/index.ts +1 -0
  104. package/src/state/abstractions.ts +98 -259
  105. package/src/state/encryption.ts +39 -0
  106. package/src/state/index.ts +1 -0
  107. package/src/state/local/backend.ts +29 -222
  108. package/src/state/local/collection.ts +105 -86
  109. package/src/state/manager.ts +358 -287
  110. package/src/state/memory/backend.ts +70 -0
  111. package/src/state/memory/collection.ts +270 -0
  112. package/src/state/memory/index.ts +2 -0
  113. package/src/state/repository/repository.index.ts +1 -1
  114. package/src/state/repository/repository.ts +71 -22
  115. package/src/state/test.ts +457 -0
  116. package/src/unlock/abstractions.ts +49 -0
  117. package/src/unlock/index.ts +2 -0
  118. package/src/unlock/memory.ts +32 -0
  119. package/src/worker/manager.ts +28 -0
  120. package/dist/chunk-RCB4AFGD.js +0 -159
  121. package/dist/chunk-RCB4AFGD.js.map +0 -1
  122. package/dist/chunk-WHALQHEZ.js.map +0 -1
  123. package/src/project/manager.ts +0 -574
  124. package/src/shared/models/project/component.ts +0 -45
  125. package/src/shared/models/project/instance.ts +0 -74
@@ -1,159 +0,0 @@
1
- // src/common/utils.ts
2
- import { z } from "zod";
3
- async function runWithRetryOnError(runner, tryHandleError, maxRetries = 1) {
4
- let lastError;
5
- for (let i = 0; i < maxRetries + 1; i++) {
6
- try {
7
- return await runner();
8
- } catch (e) {
9
- lastError = e;
10
- if (await tryHandleError(e)) {
11
- continue;
12
- }
13
- throw e;
14
- }
15
- }
16
- throw lastError;
17
- }
18
- var AbortError = class extends Error {
19
- constructor(options) {
20
- super("Operation aborted", options);
21
- }
22
- };
23
- function isAbortError(error) {
24
- return error instanceof Error && error.name === "AbortError";
25
- }
26
- var abortMessagePatterns = [
27
- "Operation aborted",
28
- "This operation was aborted",
29
- "Command was killed with SIGINT"
30
- ];
31
- function isAbortErrorLike(error) {
32
- if (isAbortError(error)) {
33
- return true;
34
- }
35
- if (error instanceof Error) {
36
- return abortMessagePatterns.some((pattern) => error.message.includes(pattern));
37
- }
38
- if (typeof error === "string") {
39
- return abortMessagePatterns.some((pattern) => error.includes(pattern));
40
- }
41
- return false;
42
- }
43
- var stringArrayType = z.string().transform((args) => args.split(",").map((arg) => arg.trim()));
44
- function errorToString(error) {
45
- if (error instanceof Error) {
46
- return error.stack || error.message;
47
- }
48
- return JSON.stringify(error);
49
- }
50
- function valueToString(value) {
51
- if (typeof value === "string") {
52
- return value;
53
- }
54
- return JSON.stringify(value);
55
- }
56
- function stringToValue(value) {
57
- try {
58
- return JSON.parse(value);
59
- } catch {
60
- return value;
61
- }
62
- }
63
- function waitForAbort(signal) {
64
- return new Promise((resolve) => {
65
- if (signal.aborted) {
66
- resolve();
67
- return;
68
- }
69
- signal.addEventListener("abort", () => resolve(), { once: true });
70
- });
71
- }
72
-
73
- // src/common/local.ts
74
- import { basename } from "node:path";
75
- import { findWorkspaceDir, readPackageJSON } from "pkg-types";
76
- async function resolveMainLocalProject(projectPath, projectName) {
77
- if (!projectPath) {
78
- projectPath = await findWorkspaceDir();
79
- }
80
- if (!projectName) {
81
- const packageJson = await readPackageJSON(projectPath);
82
- projectName = packageJson.name;
83
- }
84
- if (!projectName) {
85
- projectName = basename(projectPath);
86
- }
87
- return [projectPath, projectName];
88
- }
89
-
90
- // src/common/tree.ts
91
- function renderTree(node) {
92
- const lines = [];
93
- function renderNode(node2, prefix = "", isLast = true) {
94
- lines.push(prefix + (isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ") + node2.text);
95
- const childPrefix = prefix + (isLast ? " " : "\u2502 ");
96
- node2.children.forEach((child, index) => {
97
- const isLastChild = index === node2.children.length - 1;
98
- renderNode(child, childPrefix, isLastChild);
99
- });
100
- }
101
- lines.push(node.text);
102
- node.children.forEach((child, index) => {
103
- const isLastChild = index === node.children.length - 1;
104
- renderNode(child, "", isLastChild);
105
- });
106
- return lines.join("\n");
107
- }
108
-
109
- // src/common/performance.ts
110
- var PerformanceLogger = class _PerformanceLogger {
111
- constructor(logger) {
112
- this.logger = logger;
113
- this.start = Date.now();
114
- this.last = this.start;
115
- this.logger.child({});
116
- }
117
- start;
118
- last;
119
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
120
- log(message, ...args) {
121
- const now = Date.now();
122
- const diff = now - this.last;
123
- const absDiff = now - this.start;
124
- this.last = now;
125
- this.logger.debug(
126
- {
127
- message,
128
- diff: _PerformanceLogger.msToHumanReadable(diff),
129
- absDiff: _PerformanceLogger.msToHumanReadable(absDiff)
130
- },
131
- message,
132
- ...args
133
- );
134
- }
135
- static msToHumanReadable(ms) {
136
- const seconds = Math.floor(ms / 1e3);
137
- const msPart = ms % 1e3;
138
- if (seconds > 0) {
139
- return `${seconds}s ${msPart}ms`;
140
- } else {
141
- return `${msPart}ms`;
142
- }
143
- }
144
- };
145
-
146
- export {
147
- runWithRetryOnError,
148
- AbortError,
149
- isAbortErrorLike,
150
- stringArrayType,
151
- errorToString,
152
- valueToString,
153
- stringToValue,
154
- waitForAbort,
155
- resolveMainLocalProject,
156
- renderTree,
157
- PerformanceLogger
158
- };
159
- //# sourceMappingURL=chunk-RCB4AFGD.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/common/utils.ts","../src/common/local.ts","../src/common/tree.ts","../src/common/performance.ts"],"sourcesContent":["import { z } from \"zod\"\n\nexport async function runWithRetryOnError<T>(\n runner: () => T | Promise<T>,\n tryHandleError: (error: unknown) => boolean | Promise<boolean>,\n maxRetries: number = 1,\n): Promise<T> {\n let lastError: unknown\n\n for (let i = 0; i < maxRetries + 1; i++) {\n try {\n return await runner()\n } catch (e) {\n lastError = e\n\n if (await tryHandleError(e)) {\n continue\n }\n\n throw e\n }\n }\n\n throw lastError\n}\n\nexport class AbortError extends Error {\n constructor(options?: ErrorOptions) {\n super(\"Operation aborted\", options)\n }\n}\n\nexport function isAbortError(error: unknown): boolean {\n return error instanceof Error && error.name === \"AbortError\"\n}\n\nconst abortMessagePatterns = [\n \"Operation aborted\",\n \"This operation was aborted\",\n \"Command was killed with SIGINT\",\n]\n\nexport function isAbortErrorLike(error: unknown): boolean {\n if (isAbortError(error)) {\n return true\n }\n\n if (error instanceof Error) {\n return abortMessagePatterns.some(pattern => error.message.includes(pattern))\n }\n\n if (typeof error === \"string\") {\n return abortMessagePatterns.some(pattern => error.includes(pattern))\n }\n\n return false\n}\n\nexport function tryWrapAbortErrorLike(error: unknown): unknown {\n if (isAbortErrorLike(error)) {\n return new AbortError({ cause: error })\n }\n\n return error\n}\n\nexport const stringArrayType = z.string().transform(args => args.split(\",\").map(arg => arg.trim()))\n\nexport function errorToString(error: unknown): string {\n if (error instanceof Error) {\n return error.stack || error.message\n }\n\n return JSON.stringify(error)\n}\n\nexport function valueToString(value: unknown): string {\n if (typeof value === \"string\") {\n return value\n }\n\n return JSON.stringify(value)\n}\n\nexport function stringToValue(value: string): unknown {\n try {\n return JSON.parse(value)\n } catch {\n return value\n }\n}\n\nexport function waitForAbort(signal: AbortSignal): Promise<void> {\n return new Promise(resolve => {\n if (signal.aborted) {\n resolve()\n return\n }\n\n signal.addEventListener(\"abort\", () => resolve(), { once: true })\n })\n}\n","import { basename } from \"node:path\"\nimport { findWorkspaceDir, readPackageJSON } from \"pkg-types\"\n\nexport async function resolveMainLocalProject(\n projectPath?: string,\n projectName?: string,\n): Promise<[projecPath: string, projectName: string]> {\n if (!projectPath) {\n projectPath = await findWorkspaceDir()\n }\n\n if (!projectName) {\n const packageJson = await readPackageJSON(projectPath)\n projectName = packageJson.name\n }\n\n if (!projectName) {\n projectName = basename(projectPath)\n }\n\n return [projectPath, projectName]\n}\n","export type TreeNode = {\n text: string\n children: TreeNode[]\n}\n\n/**\n * Renders a tree structure similar to the Linux tree command output.\n * Uses box-drawing characters to create visual hierarchy.\n */\nexport function renderTree(node: TreeNode): string {\n const lines: string[] = []\n\n function renderNode(node: TreeNode, prefix: string = \"\", isLast: boolean = true): void {\n // Add current node\n lines.push(prefix + (isLast ? \"└── \" : \"├── \") + node.text)\n\n // Add children\n const childPrefix = prefix + (isLast ? \" \" : \"│ \")\n node.children.forEach((child, index) => {\n const isLastChild = index === node.children.length - 1\n renderNode(child, childPrefix, isLastChild)\n })\n }\n\n // Start with root node (no prefix)\n lines.push(node.text)\n node.children.forEach((child, index) => {\n const isLastChild = index === node.children.length - 1\n renderNode(child, \"\", isLastChild)\n })\n\n return lines.join(\"\\n\")\n}\n","import type { Logger } from \"pino\"\n\nexport class PerformanceLogger {\n private readonly start: number\n private last: number\n\n constructor(private readonly logger: Logger) {\n this.start = Date.now()\n this.last = this.start\n\n this.logger.child({})\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n log(message: string, ...args: any[]): void {\n const now = Date.now()\n const diff = now - this.last\n const absDiff = now - this.start\n\n this.last = now\n\n this.logger.debug(\n {\n message,\n diff: PerformanceLogger.msToHumanReadable(diff),\n absDiff: PerformanceLogger.msToHumanReadable(absDiff),\n },\n message,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n ...args,\n )\n }\n\n private static msToHumanReadable(ms: number): string {\n const seconds = Math.floor(ms / 1000)\n const msPart = ms % 1000\n\n if (seconds > 0) {\n return `${seconds}s ${msPart}ms`\n } else {\n return `${msPart}ms`\n }\n }\n}\n"],"mappings":";AAAA,SAAS,SAAS;AAElB,eAAsB,oBACpB,QACA,gBACA,aAAqB,GACT;AACZ,MAAI;AAEJ,WAAS,IAAI,GAAG,IAAI,aAAa,GAAG,KAAK;AACvC,QAAI;AACF,aAAO,MAAM,OAAO;AAAA,IACtB,SAAS,GAAG;AACV,kBAAY;AAEZ,UAAI,MAAM,eAAe,CAAC,GAAG;AAC3B;AAAA,MACF;AAEA,YAAM;AAAA,IACR;AAAA,EACF;AAEA,QAAM;AACR;AAEO,IAAM,aAAN,cAAyB,MAAM;AAAA,EACpC,YAAY,SAAwB;AAClC,UAAM,qBAAqB,OAAO;AAAA,EACpC;AACF;AAEO,SAAS,aAAa,OAAyB;AACpD,SAAO,iBAAiB,SAAS,MAAM,SAAS;AAClD;AAEA,IAAM,uBAAuB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AACF;AAEO,SAAS,iBAAiB,OAAyB;AACxD,MAAI,aAAa,KAAK,GAAG;AACvB,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,OAAO;AAC1B,WAAO,qBAAqB,KAAK,aAA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GAAG,MAAM;AAAA,IAClB;AAAA,EACF;AACF;","names":["node"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/shared/models/base.ts","../src/shared/models/backend/project.ts","../src/shared/models/project/instance.ts","../src/shared/models/project/state.ts","../src/shared/models/project/operation.ts","../src/shared/models/project/terminal.ts","../src/shared/models/project/artifact.ts","../src/shared/models/project/page.ts","../src/shared/models/project/trigger.ts","../src/shared/models/project/unlock-method.ts","../src/shared/models/project/secret.ts","../src/shared/models/project/lock.ts","../src/shared/models/project/component.ts","../src/shared/models/project/service-account.ts","../src/shared/models/project/worker.ts","../src/shared/models/project/api-key.ts","../src/shared/models/backend/library.ts","../src/shared/models/backend/unlock-method.ts","../src/shared/models/errors.ts","../src/shared/resolvers/graph-resolver.ts","../src/shared/resolvers/state.ts","../src/shared/resolvers/input.ts","../src/shared/resolvers/input-hash.ts","../src/shared/utils/promise-tracker.ts","../src/shared/utils/async-batcher.ts","../src/shared/utils/hash.ts","../src/shared/resolvers/validation.ts","../src/shared/resolvers/registry.ts"],"sourcesContent":["import { z } from \"zod\"\n\nexport const userObjectMetaSchema = z.object({\n /**\n * Human-readable name of the object.\n *\n * Used in UI components for better user experience.\n */\n title: z.string().optional(),\n\n /**\n * The title used globally for the object.\n *\n * For example, the title of an instance secret is \"Password\" which is okay\n * to display in the instance secret list, but when the secret is displayed in a\n * global secret list the name should be more descriptive, like \"Proxmox Password\".\n */\n globalTitle: z.string().optional(),\n\n /**\n * Description of the object.\n *\n * Provides additional context for users and developers.\n */\n description: z.string().optional(),\n\n /**\n * The color of the object.\n *\n * Used in UI components to visually distinguish objects.\n */\n color: z.string().optional(),\n\n /**\n * Primary icon identifier.\n *\n * Should reference a iconify icon name, like \"mdi:server\" or \"gg:remote\".\n */\n icon: z.string().optional(),\n\n /**\n * The color of the primary icon.\n */\n iconColor: z.string().optional(),\n\n /**\n * The secondary icon identifier.\n *\n * Used to provide additional context or actions related to the object.\n *\n * Should reference a iconify icon name, like \"mdi:edit\" or \"mdi:delete\".\n */\n secondaryIcon: z.string().optional(),\n\n /**\n * The color of the secondary icon.\n */\n secondaryIconColor: z.string().optional(),\n})\n\nexport const objectMetaSchema = userObjectMetaSchema.extend({\n /**\n * Creation timestamp in milliseconds.\n *\n * Managed automatically by the system.\n */\n createdAt: z.number().optional(),\n\n /**\n * Last update timestamp in milliseconds.\n *\n * Managed automatically by the system.\n */\n updatedAt: z.number().optional(),\n\n /**\n * The optional version of the document to support optimistic concurrency control.\n *\n * Managed automatically by the system.\n */\n version: z.number().optional(),\n})\n\nexport type UserObjectMeta = z.infer<typeof userObjectMetaSchema>\nexport type ObjectMeta = z.infer<typeof objectMetaSchema>\n\nexport function hasObjectMeta(value: unknown): value is { meta: ObjectMeta } {\n return typeof value === \"object\" && value !== null && \"meta\" in value\n}\n\nexport const collectionQuerySchema = z.object({\n /**\n * The search string to filter documents by display name, description, or other text fields.\n *\n * Not implemented yet.\n */\n search: z.string().optional(),\n\n /**\n * The skip count for pagination.\n *\n * Cannot be used with `cursor`.\n */\n skip: z.number().int().nonnegative().optional(),\n\n /**\n * The sorting order for the results.\n *\n * By default, \"asc\" is used.\n */\n sort: z.enum([\"asc\", \"desc\"]).default(\"asc\"),\n\n /**\n * The ID of the document to start the query from.\n *\n * If \"asc\" sorting is used, this will return results after this ID.\n * Otherwise, it will return results before this ID.\n *\n * Cannot be used with `skip`.\n */\n cursor: z.string().optional(),\n\n /**\n * The count of documents to return.\n *\n * Defaults to 20 if not specified.\n * Maximum value is 100.\n */\n count: z.number().int().nonnegative().max(100).optional(),\n})\n\nexport type CollectionQuery = z.infer<typeof collectionQuerySchema>\n\nexport type CollectionQueryResult<T> = {\n /**\n * The list of objects matching the query.\n */\n items: T[]\n\n /**\n * The total number of documents matching the query.\n */\n total: number\n\n /**\n * The cursor for the next page of results.\n *\n * If undefined, there are no more results.\n */\n nextCursor?: string\n}\n","import { z } from \"zod\"\nimport { hubModelSchema, instanceModelSchema } from \"../project\"\nimport { objectMetaSchema } from \"../base\"\n\nexport const projectSchema = z.object({\n /**\n * The identifier of the project unique across the backend.\n */\n id: z.string(),\n\n /**\n * The metadata of the project.\n */\n meta: objectMetaSchema,\n\n /**\n * The identifier of the library used by the project.\n */\n libraryId: z.string(),\n})\n\nexport type Project = z.infer<typeof projectSchema>\n\nexport const projectModelSchema = z.object({\n instances: z.array(instanceModelSchema),\n hubs: z.array(hubModelSchema),\n})\n\nexport type ProjectModel = z.infer<typeof projectModelSchema>\n\n/**\n * The project unlock suite is something that the frontend\n * needs to unlock the project and provide the backend\n * with the necessary information to decrypt the master key.\n */\nexport const projectUnlockSuiteSchema = z.object({\n /**\n * The list of encrypted AGE identities that can be used to decrypt the master key of the project.\n *\n * The frontend should try to decrypt at least one of these identities\n * using the password or passkey.\n */\n encryptedIdentities: z.array(z.string()),\n\n /**\n * Whether one of the identities is a passkey and user should be asked to use it.\n */\n hasPasskey: z.boolean(),\n})\n\nexport type ProjectUnlockSuite = z.infer<typeof projectUnlockSuiteSchema>\n\nexport const projectUnlockStateSchema = z.discriminatedUnion(\"type\", [\n z.object({\n type: z.literal(\"locked\"),\n unlockSuite: projectUnlockSuiteSchema.optional(),\n }),\n z.object({\n type: z.literal(\"unlocked\"),\n }),\n])\n\nexport type ProjectUnlockState = z.infer<typeof projectUnlockStateSchema>\n","import { z } from \"zod\"\n\nexport const positionSchema = z.object({\n x: z.number(),\n y: z.number(),\n})\n\nexport const instanceInputSchema = z.object({\n instanceId: z.string(),\n output: z.string(),\n})\n\nexport const hubInstanceInputSchema = z.object({\n hubId: z.string(),\n})\n\nexport const instanceModelPatchSchema = z.object({\n args: z.record(z.unknown()).optional(),\n inputs: z.record(z.array(instanceInputSchema)).optional(),\n hubInputs: z.record(z.array(hubInstanceInputSchema)).optional(),\n injectionInputs: z.array(hubInstanceInputSchema).optional(),\n position: positionSchema.optional(),\n})\n\nexport const instanceModelSchema = z.object({\n id: z.string(),\n type: z.string(),\n name: z.string(),\n\n ...instanceModelPatchSchema.shape,\n resolvedInputs: z.record(z.array(instanceInputSchema)).optional(),\n\n parentId: z.string().optional(),\n outputs: z.record(z.array(instanceInputSchema)).optional(),\n resolvedOutputs: z.record(z.array(instanceInputSchema)).optional(),\n})\n\nexport const compositeInstanceSchema = z.object({\n instance: instanceModelSchema,\n children: z.array(instanceModelSchema),\n childCompositeInstanceIds: z.array(z.string()).optional(),\n inputHash: z.string().optional(),\n})\n\nexport type CompositeInstance = z.infer<typeof compositeInstanceSchema>\n\nexport const compositeInstanceEventSchema = z.discriminatedUnion(\"type\", [\n z.object({\n type: z.literal(\"updated\"),\n instance: compositeInstanceSchema,\n }),\n z.object({\n type: z.literal(\"deleted\"),\n instanceId: z.string(),\n }),\n])\n\nexport const hubModelPatchSchema = z.object({\n position: positionSchema.optional(),\n inputs: z.array(instanceInputSchema).optional(),\n injectionInputs: z.array(hubInstanceInputSchema).optional(),\n})\n\nexport const hubModelSchema = z.object({\n id: z.string().nanoid(),\n position: positionSchema,\n\n inputs: z.array(instanceInputSchema).optional(),\n injectionInputs: z.array(hubInstanceInputSchema).optional(),\n})\n\nexport type InstanceModelPatch = z.infer<typeof instanceModelPatchSchema>\nexport type HubModel = z.infer<typeof hubModelSchema>\nexport type HubModelPatch = z.infer<typeof hubModelPatchSchema>\n","/* eslint-disable @typescript-eslint/no-unsafe-argument */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { z } from \"zod\"\nimport { objectMetaSchema, userObjectMetaSchema } from \"../base\"\n\nexport const instanceOperationStatusEnumSchema = z.enum([\n // transient statuses\n \"updating\",\n \"processing-triggers\",\n \"previewing\",\n \"destroying\",\n \"refreshing\",\n \"pending\",\n \"cancelling\",\n\n // stable statuses\n \"created\",\n \"error\",\n])\n\nexport const instanceOperationStatusSchema = z.object({\n /**\n * The enum representing the current status of the instance from the operation perspective.\n */\n status: instanceOperationStatusEnumSchema,\n\n /**\n * The ID of the latest operation that this instance is associated with.\n */\n latestOperationId: z.string(),\n\n /**\n * The IDs of the instances that this instance depends on at the moment of latest operation.\n */\n dependencyIds: z.array(z.string()),\n\n /**\n * The some human-readable message describing the current status.\n * Typically used to show the error message if the status is \"error\".\n */\n message: z.string().optional(),\n\n /**\n * The current count of the Pulumi resources being managed by this instance.\n */\n currentResourceCount: z.number().optional(),\n\n /**\n * The total count of the Pulumi resources that this instance is expected to manage.\n */\n totalResourceCount: z.number().optional(),\n\n /**\n * The calculated instance CRC32 input hash at the moment of latest operation completion.\n *\n * This hash covers:\n * - the instance's configuration (name, args, secret hashes);\n * - the component definition hash;\n * - the unit's source hash (if applicable);\n * - the input hashes and output hashes of all input instances.\n */\n inputHash: z.number().optional(),\n\n /**\n * The random 32-bit nonce used in input hash calculation.\n *\n * It is changed every time the instance secrets are updated,\n * to invalidate the input hash and force running the instance again.\n */\n inputHashNonce: z.number().optional(),\n\n /**\n * The sha256 of the output produced by the instance at the moment of latest operation completion.\n *\n * Does not depend on anything except the instance's output.\n */\n outputHash: z.string().optional(),\n\n /**\n * The calculated sha256 dependency output hash at the moment of latest operation completion.\n *\n * This hash is calculated as combination of output hashes of all input instances and nothing else.\n *\n * The primary use case of this hash is to \"short-circuit\" execution:\n * if the outputs of input instances have not changed, dependent instances can skip execution,\n * even if their input hashes changed due to upstream config changes.\n * This prevents unnecessary re-execution of the entire dependency graph when only non-output-affecting inputs are modified.\n */\n dependencyOutputHash: z.string().optional(),\n\n /**\n * The arguments of the instances at the moment of latest operation start.\n */\n args: z.record(z.unknown()).optional(),\n})\n\nexport const instanceEvaludationStatusEnumSchema = z.enum([\n // transient statuses\n \"evaluating\",\n\n // stable statuses\n \"evaluated\",\n \"error\",\n])\n\nexport const instanceEvaluationStatusSchema = z.object({\n /**\n * The enum representing the current status of the instance from the evaluation perspective.\n *\n * The stable status when instance is not evaludated is forbidden.\n */\n status: instanceEvaludationStatusEnumSchema,\n\n /**\n * The message describing the evaluation status.\n * Typically used to show the error message if the status is \"error\".\n */\n message: z.string().optional(),\n})\n\nexport enum WellKnownInstanceCustomStatus {\n /**\n * The instance is in a healthy state.\n */\n Healthy = \"healthy\",\n\n /**\n * The instance is in a degraded state.\n */\n Degraded = \"degraded\",\n\n /**\n * The instance is in a down state/completely broken.\n */\n Down = \"down\",\n\n /**\n * The instance is in a warning state.\n */\n Warning = \"warning\",\n\n /**\n * The instance is progressing with some external sync operation,\n * such as a deployment or a data migration.\n */\n Progressing = \"progressing\",\n\n /**\n * The instance is in an error state.\n */\n Error = \"error\",\n}\n\nexport const instanceCustomStatusSchema = z.object({\n /**\n * The name of the instance's extra status.\n *\n * Must be unique within the instance state.\n */\n name: z.string(),\n\n /**\n * The enum value of the instance's extra status.\n *\n * May be on of the `WellKnownExtraInstanceStatus` values or a custom value.\n */\n status: z.string(),\n\n /**\n * The display name of the instance's extra status.\n */\n displayName: z.string(),\n\n /**\n * The `iconify` icon representing the instance's extra status.\n *\n * If not provided and status is a well-known value, the icon will be derived from the status.\n */\n icon: z.string().optional(),\n\n /**\n * The HEX color of the status badge.\n *\n * If not provided and status is a well-known value, the color will be derived from the status.\n */\n color: z.string().optional(),\n\n /**\n * The message describing the instance's extra status.\n *\n * Can be used to provide additional context or information about the status.\n *\n * The message will be displayed in the 800x600 ANSI terminal in the UI,\n * so differenet TUI elements should be drawn within this area.\n */\n message: z.string().optional(),\n\n /**\n * The order of the status in the list of statuses.\n *\n * Must be in the range from `0` to `100`, lower values are displayed first.\n *\n * If not provided, the default is `50`.\n */\n order: z.number().min(0).max(100).optional(),\n})\n\nexport const instanceStatusFieldValueSchema = z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.array(z.string()),\n])\n\nexport const instanceStatusFieldSchema = z.object({\n name: z.string(),\n meta: objectMetaSchema,\n\n complementaryTo: z.string().optional(),\n\n value: instanceStatusFieldValueSchema.optional(),\n})\n\nexport const unitInstanceStatusFieldSchema = instanceStatusFieldSchema.omit({ meta: true }).extend({\n meta: userObjectMetaSchema,\n})\n\nexport const instanceStateExtraSchema = z.object({\n /**\n * The status fields reported by the unit or attached via the API.\n *\n * Do not confuse with `customStatuses`.\n *\n * These fields are used to store additional information about the instance,\n * such as URLs, display names, and other metadata.\n */\n statusFields: z.array(instanceStatusFieldSchema).optional(),\n\n /**\n * The extra statuses of the instance reported by the unit or attached via the API.\n *\n * Do not confuse with `statusFields.\n */\n customStatuses: z.array(instanceCustomStatusSchema).optional(),\n\n /**\n * The IDs of the pages that are owned by this instance.\n *\n * The keys are the local page names, and the values are the page IDs.\n */\n pageIds: z.record(z.string()).optional(),\n\n /**\n * The IDs of the terminals that are owned by this instance.\n *\n * The keys are the local terminal names, and the values are the terminal IDs.\n */\n terminalIds: z.record(z.string()).optional(),\n\n /**\n * The IDs of the triggers that are owned by this instance.\n *\n * The keys are the local trigger names, and the values are the trigger IDs.\n */\n triggerIds: z.record(z.string()).optional(),\n\n /**\n * The IDs of the artifacts that are owned by this instance.\n *\n * The keys are the output keys, and the values are the artifact IDs.\n */\n ownedArtifactIds: z.record(z.array(z.string())).optional(),\n\n /**\n * The IDs of the artifacts that are used by this instance.\n *\n * This is a flat list of artifact IDs, not grouped by output keys.\n */\n usedArtifactIds: z.array(z.string()).optional(),\n\n /**\n * The IDs of the worker registrations that are associated with this instance.\n */\n workerRegistrationIds: z.array(z.string()).optional(),\n})\n\nexport const instanceStateSchema = z.object({\n /**\n * The unique identifier of the instance.\n * The format is `{componentType}:{instanceName}`, so each instance must have a unique name within its component type.\n */\n id: z.string(),\n\n /**\n * The ID of the parent instance, if this instance is a child of another composite instance.\n */\n parentId: z.string().optional(),\n\n /**\n * The names of the secrets that has values in this instance.\n */\n secretNames: z.array(z.string()).optional(),\n\n /**\n * The current status of the instance from the operation perspective.\n *\n * This status persists in the storage only when the operation is completed.\n *\n * If the operation was interrupted, the status will be \"error\" with corresponding error message.\n *\n * If the instance was not created or was successfully destroyed, the whole \"operationStatus\" field will be undefined.\n */\n operationStatus: instanceOperationStatusSchema.optional(),\n\n /**\n * The current status of the instance from the evaluation perspective.\n *\n * Only applies to composite instances, will always be `undefined` for unit instances.\n */\n evaluationStatus: instanceEvaluationStatusSchema.optional(),\n\n /**\n * The extra components of the instance.\n *\n * Applies to both unit and composite instances.\n */\n extra: instanceStateExtraSchema.optional(),\n})\n\nexport type InstanceStatusFieldValue = z.infer<typeof instanceStatusFieldValueSchema>\nexport type InstanceStatusField = z.infer<typeof instanceStatusFieldSchema>\nexport type UnitInstanceStatusField = z.infer<typeof unitInstanceStatusFieldSchema>\n\nexport type InstanceOperationStatus = z.infer<typeof instanceOperationStatusSchema>\nexport type InstanceOperataionStatusEnum = z.infer<typeof instanceOperationStatusEnumSchema>\n\nexport type InstanceEvaluationStatus = z.infer<typeof instanceEvaluationStatusSchema>\nexport type InstanceEvaluationStatusEnum = z.infer<typeof instanceEvaludationStatusEnumSchema>\n\nexport type InstanceCustomStatus = z.infer<typeof instanceCustomStatusSchema>\n\nexport type InstanceState = z.infer<typeof instanceStateSchema>\n\nexport type NullableRecord<T extends Record<string, any>> = {\n [K in keyof T]: T[K] | null\n}\n\nexport const instanceStatePatchSchema = z.object({\n id: z.string(),\n parentId: z.string().nullish(),\n secretNames: z.array(z.string()).nullish(),\n operationStatus: instanceOperationStatusSchema.partial().nullish(),\n evaluationStatus: instanceEvaluationStatusSchema.partial().nullish(),\n extra: instanceStateExtraSchema.partial().nullish(),\n})\n\nexport type InstanceStatePatch = z.infer<typeof instanceStatePatchSchema>\n\nexport function applyStatePatch(\n existingState: InstanceState | null | undefined,\n patch: InstanceStatePatch,\n): InstanceState {\n const state: any = existingState ? { ...existingState } : { id: patch.id }\n\n const anyPatch = patch as any\n\n // merge the patch with the existing state with 2-level deep merge\n // (merge objects nested in the state, but replace objects inside these nested objects)\n for (const key of Object.keys(patch)) {\n if (typeof anyPatch[key] === \"undefined\") {\n // ignore undefined values\n continue\n }\n\n if (\n typeof anyPatch[key] !== \"object\" ||\n anyPatch[key] === null ||\n Array.isArray(anyPatch[key])\n ) {\n // if the value is not an object, just replace it\n // transform null to undefined\n state[key] = anyPatch[key] === null ? undefined : anyPatch[key]\n continue\n }\n\n // if the value is an object, merge it with the existing state\n const existingValue = state[key] ? { ...state[key] } : {}\n\n for (const subKey of Object.keys(anyPatch[key])) {\n existingValue[subKey] = anyPatch[key][subKey]\n }\n\n state[key] = existingValue\n }\n\n return state as InstanceState\n}\n\nexport function isStateEmpty(state: InstanceState): boolean {\n return (\n !state.operationStatus &&\n !state.evaluationStatus &&\n (!state.extra || Object.keys(state.extra).length === 0) &&\n (!state.secretNames || state.secretNames.length === 0)\n )\n}\n\nexport function isTransientOperationStatus(status: InstanceOperataionStatusEnum): boolean {\n return status !== \"created\" && status !== \"error\"\n}\n\nexport function isStableOperationStatus(status: InstanceOperataionStatusEnum): boolean {\n return status === \"created\" || status === \"error\"\n}\n\nexport const instanceStateEventSchema = z.discriminatedUnion(\"type\", [\n z.object({\n type: z.literal(\"patched\"),\n patch: instanceStatePatchSchema,\n }),\n z.object({\n type: z.literal(\"updated\"),\n state: instanceStateSchema,\n }),\n z.object({\n type: z.literal(\"deleted\"),\n instanceId: z.string(),\n }),\n])\n","import { z } from \"zod\"\nimport { objectMetaSchema } from \"../base\"\n\nexport const operationTypeSchema = z.enum([\"update\", \"preview\", \"destroy\", \"recreate\", \"refresh\"])\n\nexport const operationStatusSchema = z.enum([\n \"pending\",\n \"running\",\n \"completed\",\n \"failed\",\n \"cancelled\",\n \"failing\",\n])\n\nexport const operationOptionsSchema = z.object({\n /**\n * Whether to force update all dependencies of the instances even if they are not changed.\n *\n * Only applicable for `update`, `preview`, `recreate`, and `refresh` operations.\n *\n * By default, `false`.\n */\n forceUpdateDependencies: z.boolean().default(false),\n\n /**\n * Whether to force update all children of the composite instances even if they are not changed.\n *\n * Only applicable for `update`, `preview`, `recreate`, and `refresh` operations.\n *\n * By default, `false`.\n */\n forceUpdateChildren: z.boolean().default(false),\n\n /**\n * Whether to destroy all dependents of the instances when destroying them.\n *\n * Only applicable for `destroy` and `recreate` operations.\n *\n * By default, `true`.\n */\n destroyDependentInstances: z.boolean().default(true),\n\n /**\n * Whether to invoke destroy triggers when destroying the instances.\n *\n * Only applicable for `destroy`.\n *\n * By default, `true`.\n */\n invokeDestroyTriggers: z.boolean().default(true),\n\n /**\n * Whether to delete unreachable resources when updating or destroying the instances.\n * This is potentially dangerous and should be used with caution.\n *\n * By default, `false`.\n */\n deleteUnreachableResources: z.boolean().default(false),\n\n /**\n * Whether to delete the stack state even if the destroy operation fails.\n * This is very dangerous and should be used only when the stack is unrecoverable.\n *\n * By default, `false`.\n */\n forceDeleteState: z.boolean().default(false),\n\n /**\n * Whether to allow partial updates of composite instances when updating, destroying or recreating them.\n *\n * If `true`, the operation will only update/destroy composite instance children that are directly referenced by other affected instances.\n * If `false`, the operation will update/destroy all children at of the composite instances at all levels if at least one of them is referenced by affected instances.\n *\n * By default, `false`.\n */\n allowPartialCompositeInstanceUpdates: z.boolean().default(false),\n\n /**\n * Whether to refresh the state before running the operation.\n *\n * By default, `false`.\n */\n refresh: z.boolean().default(false),\n})\n\nexport const operationRequestSchema = z.object({\n projectId: z.string(),\n type: operationTypeSchema,\n instanceIds: z.array(z.string()),\n options: operationOptionsSchema.partial().optional(),\n})\n\nexport const operationSchema = z.object({\n id: z.string().uuid(),\n meta: objectMetaSchema,\n status: operationStatusSchema,\n\n error: z.string().nullable(),\n\n type: operationTypeSchema,\n\n requestedInstanceIds: z.array(z.string()),\n\n instanceIdsToUpdate: z.array(z.string()).default(() => []),\n instanceIdsToDestroy: z.array(z.string()).default(() => []),\n\n options: operationOptionsSchema,\n\n startedAt: z.number(),\n completedAt: z.number().nullable(),\n})\n\nexport type OperationType = z.infer<typeof operationTypeSchema>\nexport type OperationStatus = z.infer<typeof operationStatusSchema>\nexport type Operation = z.infer<typeof operationSchema>\nexport type OperationRequest = z.infer<typeof operationRequestSchema>\nexport type OperationOptions = z.infer<typeof operationOptionsSchema>\n\nexport function isFinalOperationStatus(status: OperationStatus): boolean {\n return status === \"completed\" || status === \"failed\" || status === \"cancelled\"\n}\n\nexport const operationLogEntrySchema = z.tuple([\n z.string().uuid(), // UUIDv7\n z.string(), // The log message\n])\n\nexport type OperationLogEntry = z.infer<typeof operationLogEntrySchema>\n\nexport const operationEventSchema = z.discriminatedUnion(\"type\", [\n z.object({\n type: z.literal(\"updated\"),\n operation: operationSchema,\n }),\n z.object({\n type: z.literal(\"deleted\"),\n operationId: z.string(),\n }),\n])\n","import { z } from \"zod\"\nimport { objectMetaSchema, userObjectMetaSchema } from \"../base\"\nimport { fileSchema } from \"./artifact\"\n\nconst metaFields = {\n title: true,\n globalTitle: true,\n description: true,\n icon: true,\n iconColor: true,\n} as const\n\nconst requiredMetaFields = {\n title: true,\n description: true,\n} as const\n\n/**\n * The basic information about a terminal.\n * The spec of the terminal is stored separately and defined in `terminalSpecSchema`.\n */\nexport const terminalSchema = z.object({\n id: z.string().uuid(), // UUIDv7\n\n meta: objectMetaSchema\n .pick({\n ...metaFields,\n createdAt: true,\n updatedAt: true,\n })\n .required(requiredMetaFields),\n\n /**\n * The ID of the instance produced the terminal if applicable.\n */\n instanceId: z.string().optional(),\n})\n\nexport type Terminal = z.infer<typeof terminalSchema>\n\n/**\n * Contains all the information needed to run a terminal,\n * including the image, command, working directory, environment variables, and files.\n */\nexport const terminalSpecSchema = z.object({\n image: z.string(),\n command: z.string().array(),\n cwd: z.string().optional(),\n env: z.record(z.string()).optional(),\n files: z.record(fileSchema).optional(),\n})\n\nexport type TerminalSpec = z.infer<typeof terminalSpecSchema>\n\n/**\n * Terminal schema for unit API.\n */\nexport const unitTerminalSchema = z.object({\n name: z.string(),\n meta: userObjectMetaSchema.pick(metaFields).required(requiredMetaFields),\n spec: terminalSpecSchema,\n})\n\nexport type UnitTerminal = z.infer<typeof unitTerminalSchema>\n\n/**\n * Terminal session schema for database storage and frontend display.\n * Contains all terminal session information.\n */\nexport const terminalSessionSchema = z.object({\n id: z.string().uuid(), // UUIDv7\n\n meta: objectMetaSchema\n .pick({ ...metaFields, createdAt: true, updatedAt: true })\n .required(requiredMetaFields)\n .extend({\n /**\n * The time when the session was finished.\n */\n finishedAt: z.number().optional(),\n }),\n\n /**\n * The ID of the project this session belongs to.\n */\n projectId: z.string(),\n\n /**\n * References the terminal this session is based on.\n */\n terminalId: z.string(),\n\n /**\n * References the instance produced the terminal if applicable.\n */\n instanceId: z.string().optional(),\n})\n\nexport type TerminalSession = z.infer<typeof terminalSessionSchema>\n","import { z } from \"zod\"\nimport {\n HighstateSignature,\n type File,\n type FileContent,\n type FileMeta,\n type UnitArtifact,\n} from \"@highstate/contract\"\nimport { objectMetaSchema, userObjectMetaSchema } from \"../base\"\n\nexport const artifactUsageSchema = z.discriminatedUnion(\"type\", [\n z.object({\n type: z.literal(\"instance\"),\n instanceId: z.string(),\n }),\n z.object({\n type: z.literal(\"terminal\"),\n terminalId: z.string(),\n }),\n z.object({\n type: z.literal(\"service-account\"),\n serviceAccountId: z.string(),\n }),\n])\n\nexport type ArtifactUsage = z.infer<typeof artifactUsageSchema>\n\nexport function compareArtifactUsage(a: ArtifactUsage, b: ArtifactUsage): boolean {\n if (a.type === \"instance\" && b.type === \"instance\") {\n return a.instanceId === b.instanceId\n }\n\n if (a.type === \"terminal\" && b.type === \"terminal\") {\n return a.terminalId === b.terminalId\n }\n\n if (a.type === \"service-account\" && b.type === \"service-account\") {\n return a.serviceAccountId === b.serviceAccountId\n }\n\n return false\n}\n\n/**\n * File metadata schema.\n */\nexport const fileMetaSchema = z.object({\n name: z.string(),\n size: z.number().optional(),\n isBinary: z.boolean().optional(),\n mode: z.number().optional(),\n}) satisfies z.ZodType<FileMeta>\n\n/**\n * Complete artifact schema for database storage.\n * Contains all artifact information.\n */\nexport const artifactSchema = z.object({\n /**\n * The UUIDv7 of the artifact generated when the artifact with unique content is first stored.\n */\n id: z.string().uuid(),\n\n meta: objectMetaSchema,\n\n /**\n * The SHA-256 hash of the artifact content before encryption.\n */\n hash: z.string(),\n\n /**\n * The list of usages of this artifact.\n *\n * When became empty, the artifact is garbage collected.\n */\n usages: artifactUsageSchema.array(),\n\n /**\n * The size of the unencrypted artifact archive in bytes.\n */\n size: z.number(),\n\n /**\n * The size of each chunk of the artifact which independently encrypted.\n */\n chunkSize: z.number(),\n})\n\nexport type Artifact = z.infer<typeof artifactSchema>\n\n/**\n * Artifact schema for unit API.\n */\nexport const unitArtifactSchema = z.object({\n hash: z.string(),\n meta: userObjectMetaSchema.optional(),\n}) satisfies z.ZodType<UnitArtifact>\n\nexport const fileContentSchema = z.union([\n z.object({\n type: z.literal(\"embedded\"),\n value: z.string(),\n }),\n z.object({\n type: z.literal(\"artifact\"),\n [HighstateSignature.Artifact]: unitArtifactSchema,\n }),\n]) satisfies z.ZodType<FileContent>\n\nexport const fileSchema = z.object({\n meta: fileMetaSchema,\n content: fileContentSchema,\n}) satisfies z.ZodType<File>\n","import { z } from \"zod\"\nimport { objectMetaSchema, userObjectMetaSchema } from \"../base\"\nimport { fileSchema } from \"./artifact\"\n\n/**\n * Page block schema for database storage and unit API.\n */\nexport const pageBlockSchema = z.union([\n z.object({\n type: z.literal(\"markdown\"),\n content: z.string(),\n }),\n z.object({\n type: z.literal(\"qr\"),\n content: z.string(),\n showContent: z.coerce.boolean(),\n language: z.string().optional(),\n }),\n fileSchema.extend({\n type: z.literal(\"file\"),\n }),\n])\n\nexport type PageBlock = z.infer<typeof pageBlockSchema>\n\n/**\n * Page info for frontend display.\n * Contains only basic information visible to the frontend.\n */\nexport const pageSchema = z.object({\n id: z.string(),\n instanceId: z.string().optional(),\n meta: objectMetaSchema,\n})\n\nexport type Page = z.infer<typeof pageSchema>\n\n/**\n * The content of a page separated from the page info.\n */\nexport const pageContentSchema = z.object({\n id: z.string(),\n content: z.array(pageBlockSchema),\n})\n\nexport type PageContent = z.infer<typeof pageContentSchema>\n\n/**\n * Page schema for unit API.\n * This is what units provide - excludes id, instanceId and some fields from meta since those are set by the system.\n */\nexport const unitPageSchema = pageContentSchema.omit({ id: true }).extend({\n name: z.string(),\n meta: userObjectMetaSchema,\n})\n\nexport type UnitPage = z.infer<typeof unitPageSchema>\n","import { z } from \"zod\"\nimport { objectMetaSchema, userObjectMetaSchema } from \"../base\"\n\n/**\n * Trigger specification schema.\n */\nexport const triggerSpecSchema = z.union([\n z.object({\n type: z.literal(\"before-destroy\"),\n }),\n z.object({\n type: z.literal(\"schedule\"),\n schedule: z.string(),\n }),\n])\n\nexport type TriggerSpec = z.infer<typeof triggerSpecSchema>\n\n/**\n * Trigger info for frontend display.\n * Contains only basic information visible to the frontend.\n */\nexport const triggerSchema = z.object({\n id: z.string(),\n instanceId: z.string(),\n meta: objectMetaSchema,\n spec: triggerSpecSchema,\n})\n\nexport type Trigger = z.infer<typeof triggerSchema>\n\n/**\n * Trigger schema for unit API.\n * This is what units provide - excludes id since it's set by the system.\n */\nexport const unitTriggerSchema = triggerSchema\n .omit({ id: true, instanceId: true, meta: true })\n .extend({\n name: z.string(),\n meta: userObjectMetaSchema.optional(),\n })\n .extend({\n name: z.string(),\n meta: userObjectMetaSchema.optional(),\n })\n\nexport type UnitTrigger = z.infer<typeof unitTriggerSchema>\n\n/**\n * Trigger invocation schema.\n */\nexport const triggerInvocationSchema = z.object({\n name: z.string(),\n})\n\nexport type TriggerInvocation = z.infer<typeof triggerInvocationSchema>\n","import { z } from \"zod\"\nimport { objectMetaSchema } from \"../base\"\n\nexport const unlockMethodType = z.enum([\"password\", \"passkey\"])\n\n/**\n * Complete unlock method schema for database storage.\n * Contains all unlock method information including encryption details.\n */\nexport const unlockMethodSchema = z.object({\n id: z.string(),\n meta: objectMetaSchema,\n\n /**\n * The type of unlock method (password or passkey).\n */\n type: unlockMethodType,\n\n /**\n * The encrypted identity used to decrypt the master key.\n */\n encryptedIdentity: z.string(),\n\n /**\n * The recipient of the unlock method to use to encrypt the master key for this unlock method.\n */\n recipient: z.string(),\n})\n\nexport type UnlockMethod = z.infer<typeof unlockMethodSchema>\nexport type UnlockMethodType = z.infer<typeof unlockMethodType>\n","import { z } from \"zod\"\nimport { objectMetaSchema } from \"../base\"\n\nexport const secretDescriptorSchema = z.discriminatedUnion(\"type\", [\n z.object({\n type: z.literal(\"system\"),\n secretName: z.string(),\n }),\n z.object({\n type: z.literal(\"instance\"),\n instanceId: z.string(),\n secretName: z.string(),\n }),\n z.object({\n type: z.literal(\"custom\"),\n secretPath: z.string(),\n }),\n])\n\n/**\n * Secret info for frontend display.\n * Contains only basic information visible to the frontend without the actual secret value.\n */\nexport const secretSchema = z.object({\n /**\n * The UUIDv7 of the secret generated when the secret is first created.\n */\n id: z.string().uuid(),\n\n /**\n * The metadata of the secret object.\n */\n meta: objectMetaSchema,\n\n /**\n * The real descriptor of the secret in the object form, which follows one of these formats when serialized:\n * - `system:<secretName>`\n * - `instance:<instanceId>:<secretName>`\n * - `custom:<secretPath>`\n */\n descriptor: secretDescriptorSchema,\n})\n\nexport type SecretDescriptor = z.infer<typeof secretDescriptorSchema>\nexport type Secret = z.infer<typeof secretSchema>\n\n/**\n * Formats a SecretDescriptor into a string representation.\n *\n * @param descriptor The SecretDescriptor to format.\n * @returns The formatted secret descriptor string.\n */\nexport function formatSecretDescriptor(descriptor: SecretDescriptor): string {\n switch (descriptor.type) {\n case \"system\":\n return `system:${descriptor.secretName}`\n case \"instance\":\n return `instance:${descriptor.instanceId}:${descriptor.secretName}`\n case \"custom\":\n return `custom:${descriptor.secretPath}`\n }\n}\n\n/**\n * Parses a secret descriptor string into a structured SecretDescriptor object.\n *\n * @param descriptorString The secret descriptor string to parse.\n * @returns The parsed SecretDescriptor object.\n * @throws Error if the secret descriptor format is invalid.\n */\nexport function parseSecretDescriptor(descriptorString: string): SecretDescriptor {\n const parts = descriptorString.split(\":\")\n if (parts.length < 2) {\n throw new Error(`Invalid secret descriptor format: ${descriptorString}`)\n }\n\n switch (parts[0]) {\n case \"system\": {\n if (parts.length !== 2) {\n throw new Error(`Invalid system secret descriptor: ${descriptorString}`)\n }\n return { type: \"system\", secretName: parts[1] }\n }\n\n case \"instance\": {\n // instance format is \"instance:<instanceId>:<secretName>\" where instanceId may contain colons\n const secretName = parts[parts.length - 1]\n const instanceId = parts.slice(1, -1).join(\":\")\n if (!instanceId || !secretName) {\n throw new Error(`Invalid instance secret descriptor: ${descriptorString}`)\n }\n return { type: \"instance\", instanceId, secretName }\n }\n\n case \"custom\": {\n if (parts.length !== 2) {\n throw new Error(`Invalid custom secret descriptor: ${descriptorString}`)\n }\n return { type: \"custom\", secretPath: parts[1] }\n }\n\n default:\n throw new Error(`Unknown secret descriptor type: ${parts[0]}`)\n }\n}\n\nexport const WellKnownSecretDescriptors = {\n PulumiPassword: {\n type: \"system\",\n secretName: \"pulumi-password\",\n },\n} satisfies Record<string, SecretDescriptor>\n","import { z } from \"zod\"\nimport { objectMetaSchema } from \"../base\"\n\nexport const instanceLockSpecSchema = z.union([\n z.object({\n type: z.literal(\"operation\"),\n\n /**\n * The operation ID. Will be used to fetch the operation and detect whether it is still running or lost.\n */\n operationId: z.string(),\n }),\n z.object({\n type: z.literal(\"evaluation\"),\n\n /**\n * The internal evaluation ID that is used to detect lost evaluations and restart them.\n */\n evaluationId: z.string(),\n }),\n z.object({\n type: z.literal(\"custom\"),\n\n /**\n * The ID of the party that holds the lock.\n *\n * Each locker must only manage the locks it has created.\n */\n lockerId: z.string(),\n\n /**\n * The ID of the lock provided by the locker.\n *\n * Must be unique across all locks in the locker system.\n */\n lockId: z.string(),\n\n /**\n * The optional payload provided by the locker.\n *\n * Can be used to store additional information about the lock,\n * like the ID of the lock in the locker system,\n * or any other metadata that is relevant to the lock.\n */\n payload: z.record(z.string()).optional(),\n }),\n])\n\nexport const instanceLockSchema = z.object({\n id: z.string(),\n meta: objectMetaSchema,\n spec: instanceLockSpecSchema,\n})\n\nexport type InstanceLock = z.infer<typeof instanceLockSchema>\nexport type InstanceLockSpec = z.infer<typeof instanceLockSpecSchema>\n\n/**\n * Compares two instance lock specifications for equality.\n *\n * @param a The first instance lock specification to compare.\n * @param b The second instance lock specification to compare.\n *\n * @returns True if both specifications are of the same type and have matching identifiers, false otherwise.\n */\nexport function compareInstanceLockSpecs(a: InstanceLockSpec, b: InstanceLockSpec): boolean {\n if (a.type === \"operation\" && b.type === \"operation\") {\n return a.operationId === b.operationId\n }\n\n if (a.type === \"evaluation\" && b.type === \"evaluation\") {\n return a.evaluationId === b.evaluationId\n }\n\n if (a.type === \"custom\" && b.type === \"custom\") {\n return a.lockerId === b.lockerId && a.lockId === b.lockId\n }\n\n return false\n}\n\nexport const instanceLockEventSchema = z.discriminatedUnion(\"type\", [\n z.object({\n type: z.literal(\"locked\"),\n locks: z.array(instanceLockSchema),\n }),\n z.object({\n type: z.literal(\"unlocked\"),\n instanceIds: z.array(z.string()),\n }),\n])\n","import { z } from \"zod\"\n\nexport const metaSchema = z.object({\n displayName: z.string().optional(),\n description: z.string().optional(),\n color: z.string().optional(),\n})\n\nexport const entitySchema = z.object({\n type: z.string(),\n schema: z.any(), // TSchema from TypeBox\n meta: metaSchema,\n definitionHash: z.string(),\n})\n\nexport const componentMetaSchema = metaSchema.extend({\n primaryIcon: z.string().optional(),\n primaryIconColor: z.string().optional(),\n secondaryIcon: z.string().optional(),\n secondaryIconColor: z.string().optional(),\n category: z.string().optional(),\n defaultNamePrefix: z.string().optional(),\n})\n\nexport const componentArgumentSchema = z.object({\n schema: z.any(), // ArgumentValueSchema from TypeBox\n required: z.boolean(),\n meta: componentMetaSchema,\n})\n\nexport const componentInputSchema = z.object({\n type: z.string(),\n required: z.boolean(),\n multiple: z.boolean(),\n meta: componentMetaSchema,\n})\n\nexport const componentModelSchema = z.object({\n type: z.string(),\n args: z.record(componentArgumentSchema),\n inputs: z.record(componentInputSchema),\n outputs: z.record(componentInputSchema),\n meta: componentMetaSchema,\n definitionHash: z.string(),\n})\n","import { z } from \"zod\"\nimport { objectMetaSchema } from \"../base\"\n\nexport const serviceAccountSchema = z.object({\n id: z.string().uuid(), // UUIDv7\n\n meta: objectMetaSchema.pick({\n title: true,\n description: true,\n icon: true,\n iconColor: true,\n createdAt: true,\n updatedAt: true,\n }),\n\n /**\n * The ID of the artifact that stores the avatar image for this service account.\n */\n avatarArtifactId: z.string().optional(),\n})\n\nexport type ServiceAccount = z.infer<typeof serviceAccountSchema>\n","import { z } from \"zod\"\nimport { objectMetaSchema } from \"../base\"\n\nexport const workerStatus = z.enum([\n // transient statuses\n \"running\",\n \"starting\",\n])\n\nexport const workerSchema = z.object({\n id: z.uuidv7(),\n\n meta: objectMetaSchema.pick({\n title: true,\n description: true,\n icon: true,\n iconColor: true,\n createdAt: true,\n updatedAt: true,\n }),\n\n /**\n * The status of the worker.\n */\n status: workerStatus,\n\n /**\n * The number of failed attempts to start the worker. When a worker fails to start,\n * this count is incremented.\n * If the worker fails to start more than 5 times in a row, it is\n * considered unhealthy and will not be started again\n *\n * This count is reset when the worker is successfully started and connected.\n */\n failedStartAttempts: z.number(),\n\n /**\n * The fully qualified base docker image without tag and digest.\n *\n * It serves as the identity of the worker and can be shared across workers.\n *\n * Multiple workers sharing the same identity also share the same service accoun\n * and have equal access to all its resources.\n *\n * Example: `ghcr.io/highstate-io/kubernetes-worker`\n */\n identity: z.string(),\n\n /**\n * The fully qualified docker image name for this worker.\n *\n * Example: `ghcr.io/highstate-io/kubernetes-worker:v1.0.0@sha256:abc123...`\n */\n image: z.string(),\n\n /**\n * The ID of the service account owned by this worker.\n */\n serviceAccountId: z.string().uuid(),\n\n /**\n * The ID of the API key used to authenticate this worker with the system.\n *\n * Will be generated on the first run of the worker and will be rotated every time the worker is restarted.\n */\n apiKeyId: z.string().uuid().optional(),\n})\n\nexport const workerUnitRegistrationSchema = z.object({\n id: z.string().uuid(), // UUIDv7\n\n meta: objectMetaSchema.pick({ createdAt: true, updatedAt: true }),\n\n workerId: z.string().uuid(), // UUIDv7\n instanceId: z.string(),\n\n /**\n * The fully qualified base docker image with tag and digest.\n */\n image: z.string(),\n\n /**\n * The parameters to pass to the worker.\n */\n params: z.record(z.string(), z.unknown()).optional(),\n})\n\nexport const unitWorkerSchema = z.object({\n name: z.string(),\n image: z.string(),\n params: z.record(z.string(), z.unknown()).optional(),\n})\n\nexport type Worker = z.infer<typeof workerSchema>\nexport type WorkerUnitRegistration = z.infer<typeof workerUnitRegistrationSchema>\nexport type UnitWorker = z.infer<typeof unitWorkerSchema>\n\nexport function getWorkerIdentity(image: string): string {\n const parts = image.split(\":\")\n if (parts.length < 2) {\n throw new Error(`Invalid image format: ${image}`)\n }\n\n return parts.slice(0, -1).join(\":\") // Remove the tag and digest\n}\n","import { z } from \"zod\"\nimport { objectMetaSchema } from \"../base\"\n\nexport const instanceActionSchema = z.enum([\"read\", \"write\"])\nexport const serviceAccountActionSchema = z.enum([\"full\"])\n\nexport const projectAccessScope = z.discriminatedUnion(\"type\", [\n z.object({\n type: z.literal(\"instance\"),\n actions: instanceActionSchema.array(),\n instanceIds: z.string().array(),\n }),\n z.object({\n type: z.literal(\"service-account\"),\n actions: serviceAccountActionSchema.array(),\n serviceAccountIds: z.string().array(),\n }),\n])\n\nexport const projectApiKeySchema = z.object({\n id: z.string().ulid(),\n meta: objectMetaSchema,\n\n /**\n * The 256-bit random token used to authenticate API requests.\n */\n token: z.string(),\n\n scopes: z.array(projectAccessScope),\n})\n\nexport type InstanceAction = z.infer<typeof instanceActionSchema>\nexport type ProjectAccessScope = z.infer<typeof projectAccessScope>\nexport type ProjectApiKey = z.infer<typeof projectApiKeySchema>\n\nfunction hasAll<T>(array: T[], values: T[]): boolean {\n return values.every(value => array.includes(value))\n}\n\nexport function validateInstanceAccess(\n apiKey: ProjectApiKey,\n actions: InstanceAction[],\n instanceIds: string[],\n): boolean {\n return apiKey.scopes\n .filter(scope => scope.type === \"instance\")\n .some(scope => hasAll(scope.actions, actions) && hasAll(scope.instanceIds, instanceIds))\n}\n\ntype ActionDescriptionMap<TType extends ProjectAccessScope[\"type\"] = ProjectAccessScope[\"type\"]> = {\n [K in TType]: Record<(ProjectAccessScope & { type: K })[\"actions\"][number], string>\n}\n\nexport const projectAccessActionDescriptions: ActionDescriptionMap = {\n \"service-account\": {\n full: \"Full access to the service account and all resources owned by it and granted to it.\",\n },\n instance: {\n read: \"Read access to the instance, including its state all resources owned by it.\",\n write: \"Write access to the instance, including its state and all resources owned by it.\",\n },\n}\n","import type { ComponentModel, Entity } from \"@highstate/contract\"\n\nexport type LibraryModel = {\n components: Record<string, ComponentModel>\n entities: Record<string, Entity>\n}\n\nexport type LibraryUpdate =\n | {\n type: \"reload-started\" | \"reload-completed\"\n }\n | {\n type: \"component-updated\"\n component: ComponentModel\n }\n | {\n type: \"entity-updated\"\n entity: Entity\n }\n | {\n type: \"component-removed\"\n componentType: string\n }\n | {\n type: \"entity-removed\"\n entityType: string\n }\n\nexport function diffLibraries(oldLibrary: LibraryModel, newLibrary: LibraryModel): LibraryUpdate[] {\n const updates: LibraryUpdate[] = []\n\n for (const [componentType, newComponent] of Object.entries(newLibrary.components)) {\n const existingComponent = oldLibrary.components[componentType]\n if (existingComponent?.definitionHash !== newComponent.definitionHash) {\n updates.push({ type: \"component-updated\", component: newComponent })\n }\n }\n\n for (const componentType of Object.keys(oldLibrary.components)) {\n if (!newLibrary.components[componentType]) {\n updates.push({ type: \"component-removed\", componentType })\n }\n }\n\n for (const [entityType, newEntity] of Object.entries(newLibrary.entities)) {\n const existingEntity = oldLibrary.entities[entityType]\n if (existingEntity?.definitionHash !== newEntity.definitionHash) {\n updates.push({ type: \"entity-updated\", entity: newEntity })\n }\n }\n\n for (const entityType of Object.keys(oldLibrary.entities)) {\n if (!newLibrary.entities[entityType]) {\n updates.push({ type: \"entity-removed\", entityType })\n }\n }\n\n return updates\n}\n\nexport function applyLibraryUpdate(\n components: Record<string, ComponentModel>,\n entities: Record<string, Entity>,\n update: LibraryUpdate,\n): void {\n switch (update.type) {\n case \"component-updated\":\n components[update.component.type] = update.component\n break\n case \"entity-updated\":\n entities[update.entity.type] = update.entity\n break\n case \"component-removed\":\n delete components[update.componentType]\n break\n case \"entity-removed\":\n delete entities[update.entityType]\n break\n }\n}\n","import { z } from \"zod\"\nimport { objectMetaSchema } from \"../base\"\n\n/**\n * Complete unlock method schema for database storage.\n * Contains all unlock method information including encryption details.\n *\n * Do not confuse with the project unlock method schema.\n */\nexport const backendUnlockMethodSchema = z.object({\n id: z.string(),\n meta: objectMetaSchema,\n\n /**\n * The AGE recipient of the unlock method to use to encrypt the master key for this unlock method.\n */\n recipient: z.string(),\n})\n\nexport type BackendUnlockMethod = z.infer<typeof backendUnlockMethodSchema>\n","export class AccessError extends Error {\n constructor(message: string) {\n super(message)\n }\n}\n","import type { Logger } from \"pino\"\nimport { unique } from \"remeda\"\n\nexport type ResolverOutputHandler<TOutput> = (id: string, value: TOutput) => void\nexport type DependentSetHandler = (id: string, dependents: string[]) => void\n\nexport abstract class GraphResolver<TNode, TOutput> {\n private readonly workset: Set<string> = new Set()\n private readonly dependencyMap: Map<string, string[]> = new Map()\n private readonly dependentMap: Map<string, Set<string>> = new Map()\n private readonly outputMap: Map<string, TOutput> = new Map()\n\n constructor(\n private readonly nodes: ReadonlyMap<string, TNode>,\n protected readonly logger: Logger,\n private readonly outputHandler?: ResolverOutputHandler<TOutput>,\n private readonly dependentSetHandler?: DependentSetHandler,\n ) {}\n\n addToWorkset(nodeId: string): void {\n this.workset.add(nodeId)\n }\n\n addAllNodesToWorkset(): void {\n for (const nodeId of this.nodes.keys()) {\n this.workset.add(nodeId)\n }\n }\n\n /**\n * The map of calculated outputs.\n */\n get outputs(): ReadonlyMap<string, TOutput> {\n return this.outputMap\n }\n\n requireOutput(nodeId: string): TOutput {\n const output = this.outputMap.get(nodeId)\n if (!output) {\n throw new Error(`Output for node ${nodeId} is not available`)\n }\n\n return output\n }\n\n /**\n * Gets the list of the identifiers of the dependencies for the node.\n *\n * Used to produce the dependency graph.\n */\n protected abstract getNodeDependencies(node: TNode): string[]\n\n /**\n * Processes the node and returns the output.\n */\n protected abstract processNode(node: TNode, logger: Logger): TOutput | Promise<TOutput>\n\n /**\n * Gets all identifiers of the nodes that depend on the given node directly or indirectly.\n */\n getAllDependents(nodeId: string): string[] {\n const result = new Set<string>()\n const stack: string[] = [nodeId]\n\n while (stack.length > 0) {\n const dependents = this.dependentMap.get(stack.pop()!)\n if (!dependents) {\n continue\n }\n\n for (const dependentId of dependents) {\n if (!result.has(dependentId)) {\n result.add(dependentId)\n stack.push(dependentId)\n }\n }\n }\n\n return Array.from(result)\n }\n\n /**\n * Gets the identifiers of the nodes that depend on the given node directly.\n *\n * Returns an empty array if there are no dependents.\n */\n getDependents(nodeId: string): string[] {\n const dependents = this.dependentMap.get(nodeId)\n if (!dependents) {\n return []\n }\n\n return Array.from(dependents)\n }\n\n /**\n * Invalidates the node and all nodes that depend on it.\n *\n * Also adds the node to the work set for processing.\n */\n invalidate(nodeId: string): void {\n const stack = [nodeId]\n\n while (stack.length > 0) {\n const nodeId = stack.pop()!\n if (!this.nodes.has(nodeId)) {\n // it is ok to invalidate deleted nodes\n continue\n }\n\n // remove the node from the output map\n this.outputMap.delete(nodeId)\n this.workset.add(nodeId)\n\n const dependents = this.dependentMap.get(nodeId)\n if (!dependents) {\n continue\n }\n\n for (const dependentId of dependents) {\n if (this.outputMap.has(dependentId)) {\n // add the dependent to the stack for further processing\n stack.push(dependentId)\n }\n }\n }\n }\n\n /**\n * Resolves all not-resolved or invalidated nodes in the graph.\n *\n * The abort signal of the previous operation must be called before calling this method again.\n */\n async process(signal?: AbortSignal): Promise<void> {\n type StackItem = {\n nodeId: string\n resolved: boolean\n dependencies: string[]\n }\n\n while (this.workset.size > 0) {\n const rootNodeId = this.workset.values().next().value!\n const stack: StackItem[] = [{ nodeId: rootNodeId, resolved: false, dependencies: [] }]\n\n while (stack.length > 0) {\n const stackItem = stack[stack.length - 1]\n const { nodeId, resolved } = stackItem\n\n const node = this.nodes.get(nodeId)\n if (!node) {\n this.logger.warn({ nodeId }, \"node not found in the graph, skipping\")\n stack.pop()\n continue\n }\n\n if (this.outputMap.has(nodeId)) {\n // already processed\n stack.pop()\n continue\n }\n\n if (!resolved) {\n stackItem.dependencies = unique(this.getNodeDependencies(node))\n\n let hasUnresolvedDependencies = false\n\n for (const depId of stackItem.dependencies) {\n if (!this.nodes.has(depId)) {\n this.logger.warn({ depId, nodeId }, \"dependency not found in the graph, skipping\")\n continue\n }\n\n if (!this.outputMap.has(depId)) {\n stack.push({ nodeId: depId, resolved: false, dependencies: [] })\n hasUnresolvedDependencies = true\n }\n }\n\n if (hasUnresolvedDependencies) {\n // wait for dependencies to be resolved\n stackItem.resolved = true\n continue\n }\n }\n\n // all dependencies are resolved, process the node\n const output = await this.processNode(node, this.logger)\n\n if (signal?.aborted) {\n this.logger.warn({ nodeId }, \"processing aborted, skipping output\")\n return\n }\n\n const changedDependentMaps = new Set<string>()\n\n // remove all dependent nodes\n const oldDependencies = this.dependencyMap.get(nodeId) ?? []\n for (const depId of oldDependencies) {\n const dependantSet = this.dependentMap.get(depId)\n if (dependantSet) {\n dependantSet.delete(nodeId)\n changedDependentMaps.add(depId)\n if (dependantSet.size === 0) {\n this.dependentMap.delete(depId)\n }\n }\n }\n\n // add the new dependencies\n for (const depId of stackItem.dependencies) {\n let dependantSet = this.dependentMap.get(depId)\n if (!dependantSet) {\n dependantSet = new Set()\n this.dependentMap.set(depId, dependantSet)\n }\n\n dependantSet.add(nodeId)\n changedDependentMaps.add(depId)\n }\n\n // if the dependent map has changed, notify the handler\n if (this.dependentSetHandler) {\n for (const depId of changedDependentMaps) {\n const dependents = this.dependentMap.get(depId)\n this.dependentSetHandler(depId, dependents ? Array.from(dependents) : [])\n }\n }\n\n this.outputMap.set(nodeId, output)\n this.outputHandler?.(nodeId, output)\n this.dependencyMap.set(nodeId, stackItem.dependencies)\n\n stack.pop()\n }\n\n this.workset.delete(rootNodeId)\n }\n }\n}\n","import type { InstanceState } from \"../models/project\"\nimport { GraphResolver } from \"./graph-resolver\"\n\nexport class StateResolver extends GraphResolver<InstanceState, void> {\n protected getNodeDependencies(node: InstanceState): string[] {\n return node.operationStatus?.dependencyIds ?? []\n }\n\n protected processNode(): void {\n return\n }\n}\n","import type { HubModel } from \"../models/project\"\nimport {\n isUnitModel,\n type ComponentModel,\n type HubInput,\n type InstanceInput,\n type InstanceModel,\n} from \"@highstate/contract\"\nimport { fromEntries, mapValues } from \"remeda\"\nimport { GraphResolver } from \"./graph-resolver\"\n\nexport type InputResolverNode =\n | {\n kind: \"instance\"\n instance: InstanceModel\n component: ComponentModel\n }\n | {\n kind: \"hub\"\n hub: HubModel\n }\n\nexport type ResolvedInstanceInput = {\n input: InstanceInput\n type: string\n}\n\nexport type InputResolverOutput =\n | {\n kind: \"instance\"\n instance: InstanceModel\n component: ComponentModel\n resolvedInputs: Record<string, ResolvedInstanceInput[]>\n resolvedOutputs: Record<string, InstanceInput[]> | undefined\n resolvedInjectionInputs: ResolvedInstanceInput[]\n matchedInjectionInputs: ResolvedInstanceInput[]\n }\n | {\n kind: \"hub\"\n resolvedInputs: ResolvedInstanceInput[]\n }\n\n/**\n * Resolves the all recursive instance and hub inputs based on its direct inputs and injected inputs.\n */\nexport class InputResolver extends GraphResolver<InputResolverNode, InputResolverOutput> {\n getNodeDependencies(node: InputResolverNode): string[] {\n const dependencies: string[] = []\n\n if (node.kind === \"hub\") {\n for (const input of node.hub.inputs ?? []) {\n dependencies.push(`instance:${input.instanceId}`)\n }\n\n for (const input of node.hub.injectionInputs ?? []) {\n dependencies.push(`hub:${input.hubId}`)\n }\n\n return dependencies\n }\n\n for (const inputs of Object.values(node.instance.inputs ?? {})) {\n for (const input of inputs) {\n dependencies.push(`instance:${input.instanceId}`)\n }\n }\n\n for (const inputs of Object.values(node.instance.hubInputs ?? {})) {\n for (const input of inputs) {\n dependencies.push(`hub:${input.hubId}`)\n }\n }\n\n for (const input of node.instance.injectionInputs ?? []) {\n dependencies.push(`hub:${input.hubId}`)\n }\n\n return dependencies\n }\n\n processNode(node: InputResolverNode): InputResolverOutput {\n const getHubOutput = (input: HubInput) => {\n const output = this.outputs.get(`hub:${input.hubId}`)\n if (!output) {\n return { resolvedInputs: [] }\n }\n\n if (output.kind !== \"hub\") {\n throw new Error(\"Expected hub node\")\n }\n\n return output\n }\n\n const getInstanceOutput = (input: InstanceInput) => {\n const output = this.outputs.get(`instance:${input.instanceId}`)\n if (!output) {\n return {\n component: null,\n resolvedInputs: [] as ResolvedInstanceInput[],\n resolvedOutputs: [] as InstanceInput[],\n }\n }\n\n if (output.kind !== \"instance\") {\n throw new Error(\"Expected instance node\")\n }\n\n return {\n component: output.component,\n resolvedInputs: output.resolvedInputs[input.output] ?? [],\n resolvedOutputs: output.resolvedOutputs?.[input.output],\n }\n }\n\n // resolve inputs for hub\n if (node.kind === \"hub\") {\n const hubResult: Map<string, ResolvedInstanceInput> = new Map()\n\n const addHubResult = (input: ResolvedInstanceInput) => {\n hubResult.set(`${input.input.instanceId}:${input.input.output}`, input)\n }\n\n for (const input of node.hub.inputs ?? []) {\n const { component } = getInstanceOutput(input)\n const componentInput = component?.outputs[input.output]\n\n if (!componentInput) {\n this.logger.warn({ msg: \"output not found in the component\", input, component })\n continue\n }\n\n addHubResult({ input, type: componentInput.type })\n }\n\n for (const injectionInput of node.hub.injectionInputs ?? []) {\n const { resolvedInputs } = getHubOutput(injectionInput)\n\n for (const input of resolvedInputs) {\n addHubResult(input)\n }\n }\n\n return {\n kind: \"hub\",\n resolvedInputs: Array.from(hubResult.values()),\n }\n }\n\n // хуяк (which translates as \"lets reuse resolved inputs of level 2+ composite instances provided by the evaluator\")\n if (node.instance.resolvedInputs) {\n return {\n kind: \"instance\",\n instance: node.instance,\n component: node.component,\n resolvedInputs: mapValues(node.instance.resolvedInputs, (inputs, inputName) => {\n const componentInput = node.component.inputs[inputName]\n if (!componentInput) {\n this.logger.warn({\n msg: \"input not found in the component\",\n inputName,\n component: node.component,\n })\n return []\n }\n\n return inputs.map(input => ({ input, type: componentInput.type }))\n }),\n resolvedOutputs: node.instance.resolvedOutputs ?? {},\n resolvedInjectionInputs: [],\n matchedInjectionInputs: [],\n }\n }\n\n // resolve inputs for instance\n const resolvedInputsMap: Map<string, Map<string, ResolvedInstanceInput>> = new Map()\n\n const addInstanceResult = (inputName: string, input: ResolvedInstanceInput) => {\n let inputs = resolvedInputsMap.get(inputName)\n if (!inputs) {\n inputs = new Map()\n resolvedInputsMap.set(inputName, inputs)\n }\n\n inputs.set(`${input.input.instanceId}:${input.input.output}`, input)\n }\n\n const addInstanceInput = (inputName: string, input: InstanceInput) => {\n const componentInput = node.component.inputs[inputName]\n if (!componentInput) {\n this.logger.warn({\n msg: \"input not found in the component\",\n input,\n component: node.component,\n })\n return\n }\n\n const { component, resolvedOutputs } = getInstanceOutput(input)\n\n if (!component) {\n this.logger.warn({ instanceId: node.instance.id, input }, \"no output found for the input\")\n return\n }\n\n if (isUnitModel(component)) {\n addInstanceResult(inputName, { input, type: componentInput.type })\n return\n }\n\n if (resolvedOutputs) {\n for (const output of resolvedOutputs) {\n addInstanceResult(inputName, { input: output, type: componentInput.type })\n }\n } else {\n // if the instance is not evaluated, we a forced to use the input as is\n addInstanceResult(inputName, { input, type: componentInput.type })\n }\n }\n\n for (const [inputName, inputs] of Object.entries(node.instance.inputs ?? {})) {\n for (const input of inputs) {\n addInstanceInput(inputName, input)\n }\n }\n\n const injectionInputs: Map<string, ResolvedInstanceInput> = new Map()\n const matchedInjectionInputs: Map<string, ResolvedInstanceInput> = new Map()\n\n for (const injectionInput of node.instance.injectionInputs ?? []) {\n const { resolvedInputs } = getHubOutput(injectionInput)\n for (const input of resolvedInputs) {\n injectionInputs.set(`${input.input.instanceId}:${input.input.output}`, input)\n }\n }\n\n for (const [inputName, componentInput] of Object.entries(node.component.inputs ?? {})) {\n const allInputs = new Map<string, ResolvedInstanceInput>(injectionInputs)\n const hubInputs = node.instance.hubInputs?.[inputName] ?? []\n\n for (const hubInput of hubInputs) {\n const { resolvedInputs } = getHubOutput(hubInput)\n for (const input of resolvedInputs) {\n allInputs.set(`${input.input.instanceId}:${input.input.output}`, input)\n }\n }\n\n for (const input of allInputs.values()) {\n if (input.type === componentInput.type) {\n addInstanceInput(inputName, input.input)\n\n const key = `${input.input.instanceId}:${input.input.output}`\n if (injectionInputs.has(key)) {\n matchedInjectionInputs.set(key, input)\n }\n }\n }\n }\n\n const resolvedInputs = fromEntries(\n Array.from(resolvedInputsMap.entries()).map(([inputName, inputs]) => [\n inputName,\n Array.from(inputs.values()),\n ]),\n )\n\n return {\n kind: \"instance\",\n instance: node.instance,\n component: node.component,\n resolvedInputs,\n resolvedOutputs: node.instance.resolvedOutputs,\n resolvedInjectionInputs: Array.from(injectionInputs.values()),\n matchedInjectionInputs: Array.from(matchedInjectionInputs.values()),\n }\n }\n}\n\nexport function getResolvedHubInputs(output: InputResolverOutput): ResolvedInstanceInput[] {\n if (output.kind !== \"hub\") {\n throw new Error(\"Expected hub node\")\n }\n\n return output.resolvedInputs\n}\n\nexport function getResolvedInstanceInputs(\n output: InputResolverOutput,\n): Record<string, ResolvedInstanceInput[]> {\n if (output.kind !== \"instance\") {\n throw new Error(\"Expected instance node\")\n }\n\n return output.resolvedInputs\n}\n\nexport function getResolvedInjectionInstanceInputs(\n output: InputResolverOutput,\n): ResolvedInstanceInput[] {\n if (output.kind !== \"instance\") {\n throw new Error(\"Expected instance node\")\n }\n\n return output.resolvedInjectionInputs\n}\n\nexport function getMatchedInjectionInstanceInputs(\n output: InputResolverOutput,\n): ResolvedInstanceInput[] {\n if (output.kind !== \"instance\") {\n throw new Error(\"Expected instance node\")\n }\n\n return output.matchedInjectionInputs\n}\n","import type { ResolvedInstanceInput } from \"./input\"\nimport type { InstanceState } from \"../models/project\"\nimport { isUnitModel, type ComponentModel, type InstanceModel } from \"@highstate/contract\"\nimport { crc32 } from \"@aws-crypto/crc32\"\nimport { encode } from \"@msgpack/msgpack\"\nimport { sha256 } from \"@noble/hashes/sha2\"\nimport { bytesToHex } from \"@noble/ciphers/utils\"\nimport { int32ToBytes } from \"../utils\"\nimport { GraphResolver } from \"./graph-resolver\"\n\nexport type InputHashNode = {\n instance: InstanceModel\n component: ComponentModel\n resolvedInputs: Record<string, ResolvedInstanceInput[]>\n state: InstanceState | undefined\n sourceHash: number | undefined\n}\n\nexport type InputHashOutput = {\n inputHash: number\n dependencyOutputHash: string\n outputHash: string\n}\n\n/**\n * Resolves the hash of the instance based on its args, resolved input hashes, source hash, and the output hash.\n */\nexport class InputHashResolver extends GraphResolver<InputHashNode, InputHashOutput> {\n getNodeDependencies({ resolvedInputs }: InputHashNode): string[] {\n const dependencies: string[] = []\n\n for (const inputs of Object.values(resolvedInputs ?? {})) {\n for (const input of inputs) {\n dependencies.push(input.input.instanceId)\n }\n }\n\n return dependencies\n }\n\n processNode({\n instance,\n component,\n resolvedInputs,\n sourceHash,\n state,\n }: InputHashNode): InputHashOutput {\n const inputHashSink: Uint8Array[] = []\n\n // 1. include the component definition hash\n inputHashSink.push(int32ToBytes(component.definitionHash))\n\n // 2. include the input hash nonce if available\n if (state?.operationStatus?.inputHashNonce) {\n inputHashSink.push(int32ToBytes(state.operationStatus.inputHashNonce))\n }\n\n // 3. include instance args encoded as msgpack\n if (instance.args) {\n inputHashSink.push(encode(instance.args))\n }\n\n // 4. include the source hash if available\n if (sourceHash) {\n inputHashSink.push(int32ToBytes(sourceHash))\n } else if (isUnitModel(component)) {\n this.logger.warn(\n { instanceId: instance.id },\n \"missing source hash for unit model, this may lead to incorrect input hash\",\n )\n }\n\n const sortedInputs = Object.entries(resolvedInputs)\n //\n .sort(([a], [b]) => a.localeCompare(b))\n\n const dependencyInstanceIds = new Set<string>()\n\n // 5. include the sorted resolved inputs\n for (const [inputKey, inputs] of sortedInputs) {\n if (Object.keys(inputs).length === 0) {\n continue\n }\n\n // 5.1. include the input key to distinguish different inputs with possibly the same instanceId\n inputHashSink.push(Buffer.from(inputKey))\n\n // the instances inside the input should also have stable order\n const instanceIds = inputs.map(input => input.input.instanceId).sort()\n\n for (const instanceId of instanceIds) {\n const dependency = this.outputs.get(instanceId)\n if (!dependency) continue\n\n // 5.2 include both input and output hashes of the dependency\n inputHashSink.push(int32ToBytes(dependency.inputHash))\n inputHashSink.push(Buffer.from(dependency.outputHash))\n\n dependencyInstanceIds.add(instanceId)\n }\n }\n\n // also calculate the dependency output hash as the combined output hashes of all unique dependencies\n const dependencyOutputHashSink: Uint8Array[] = []\n const sortedDependencyInstanceIds = Array.from(dependencyInstanceIds).sort()\n\n for (const dependencyInstanceId of sortedDependencyInstanceIds) {\n const dependency = this.outputs.get(dependencyInstanceId)\n if (!dependency) continue\n\n dependencyOutputHashSink.push(Buffer.from(dependencyInstanceId))\n }\n\n return {\n inputHash: crc32(Buffer.concat(inputHashSink)),\n dependencyOutputHash: bytesToHex(sha256(Buffer.concat(dependencyOutputHashSink))),\n outputHash: state?.operationStatus?.outputHash ?? \"\",\n }\n }\n}\n","export class PromiseTracker {\n private readonly trackedPromises = new Set<Promise<unknown>>()\n\n /**\n * Tracks a promise to ensure its rejection is handled inside the tracker's scope.\n */\n track<T>(promise: Promise<T>): void {\n this.trackedPromises.add(promise)\n\n void promise.finally(() => this.trackedPromises.delete(promise))\n }\n\n /**\n * Waits for all tracked promises to resolve or reject.\n */\n async waitForAll(): Promise<void> {\n if (this.trackedPromises.size === 0) {\n return\n }\n\n await Promise.allSettled(this.trackedPromises)\n }\n}\n","export type AsyncBatcherOptions = {\n waitMs?: number\n maxWaitTimeMs?: number\n}\n\nexport type AsyncBatcher<T> = {\n /**\n * Add an item to the batch.\n */\n call(item: T): void\n\n /**\n * Immediately flush the pending batch (if any).\n */\n flush(): Promise<void>\n}\n\nexport function createAsyncBatcher<T>(\n fn: (items: T[]) => Promise<void> | void,\n { waitMs = 100, maxWaitTimeMs = 1000 }: AsyncBatcherOptions = {},\n): AsyncBatcher<T> {\n let batch: T[] = []\n let activeTimeout: NodeJS.Timeout | null = null\n let maxWaitTimeout: NodeJS.Timeout | null = null\n let firstCallTimestamp: number | null = null\n\n async function processBatch() {\n if (batch.length === 0) return\n\n const currentBatch = batch\n batch = [] // Reset batch before async call\n\n await fn(currentBatch)\n\n // Clear max wait timer since batch has been processed\n if (maxWaitTimeout) {\n clearTimeout(maxWaitTimeout)\n maxWaitTimeout = null\n }\n firstCallTimestamp = null\n }\n\n function schedule() {\n if (activeTimeout) clearTimeout(activeTimeout)\n activeTimeout = setTimeout(() => {\n activeTimeout = null\n void processBatch()\n }, waitMs)\n\n // Ensure batch is executed within maxWaitTimeMs\n if (!firstCallTimestamp) {\n firstCallTimestamp = Date.now()\n maxWaitTimeout = setTimeout(() => {\n if (activeTimeout) clearTimeout(activeTimeout)\n activeTimeout = null\n void processBatch()\n }, maxWaitTimeMs)\n }\n }\n\n return {\n /**\n * Add an item to the batch.\n */\n call(item: T): void {\n batch.push(item)\n schedule()\n },\n\n /**\n * Immediately flush the pending batch (if any).\n */\n async flush(): Promise<void> {\n if (activeTimeout) {\n clearTimeout(activeTimeout)\n activeTimeout = null\n }\n if (maxWaitTimeout) {\n clearTimeout(maxWaitTimeout)\n maxWaitTimeout = null\n }\n await processBatch()\n },\n }\n}\n","export function int32ToBytes(value: number): Uint8Array {\n const buffer = new ArrayBuffer(4)\n const view = new DataView(buffer)\n view.setInt32(0, value, true) // true for little-endian\n return new Uint8Array(buffer)\n}\n","import type { ResolvedInstanceInput } from \"./input\"\nimport type { InstanceState } from \"../models\"\nimport { isUnitModel, type ComponentModel, type InstanceModel } from \"@highstate/contract\"\nimport { Ajv } from \"ajv\"\nimport styles from \"ansi-styles\"\nimport { GraphResolver } from \"./graph-resolver\"\n\nexport type ValidationNode = {\n instance: InstanceModel\n component: ComponentModel\n state: InstanceState | undefined\n resolvedInputs: Record<string, ResolvedInstanceInput[]>\n}\n\nexport type ValidationOutput =\n | {\n status: \"ok\"\n }\n | {\n status: \"error\"\n errorText: string\n }\n\n/**\n * Validates the instance based on its arguments and inputs.\n */\nexport class ValidationResolver extends GraphResolver<ValidationNode, ValidationOutput> {\n getNodeDependencies({ resolvedInputs }: ValidationNode): string[] {\n const dependencies: string[] = []\n\n for (const inputs of Object.values(resolvedInputs)) {\n for (const input of inputs) {\n dependencies.push(input.input.instanceId)\n }\n }\n\n return dependencies\n }\n\n processNode({ instance, component, state, resolvedInputs }: ValidationNode): ValidationOutput {\n const ajv = new Ajv({ strict: false })\n\n this.logger.debug({ instanceId: instance.id }, \"validating instance\")\n\n const validationErrors: string[] = []\n\n for (const [name, argument] of Object.entries(component.args)) {\n if (!argument.required && !instance.args?.[name]) {\n continue\n }\n\n if (!ajv.validate(argument.schema, instance.args?.[name])) {\n this.logger.debug({ instanceId: instance.id, argumentName: name }, \"invalid argument\")\n\n validationErrors.push(\n `Invalid argument ` +\n `\"${styles.blueBright.open}${name}${styles.reset.close}\": ` +\n ajv.errorsText(),\n )\n }\n }\n\n if (isUnitModel(component)) {\n for (const [secret, secretSchema] of Object.entries(component.secrets)) {\n if (secretSchema.required && !state?.secretNames?.includes(secret)) {\n validationErrors.push(\n `Missing required secret ` +\n `\"${styles.blueBright.open}${secret}${styles.reset.close}\"`,\n )\n }\n }\n }\n\n for (const [key, inputs] of Object.entries(resolvedInputs)) {\n for (const input of inputs) {\n const inputInstance = this.outputs.get(input.input.instanceId)\n if (inputInstance?.status !== \"ok\") {\n validationErrors.push(\n `Invalid input ` +\n `\"${styles.blueBright.open}${key}${styles.reset.close}\":\\n` +\n `\"${styles.blueBright.open}${input.input.instanceId}${styles.reset.close}\" ` +\n `has validation errors`,\n )\n }\n }\n }\n\n for (const [name, input] of Object.entries(component.inputs)) {\n if (!input.required) {\n continue\n }\n\n if (!resolvedInputs[name] || !resolvedInputs[name].length) {\n validationErrors.push(\n `Missing required input ` +\n `\"${styles.blueBright.open}${name}${styles.reset.close}\" ` +\n `of type ` +\n `\"${styles.greenBright.open}${input.type}${styles.reset.close}\"`,\n )\n }\n }\n\n if (validationErrors.length === 0) {\n return { status: \"ok\" }\n }\n\n const numberPrefixLength = (validationErrors.length + 1).toString().length + 2 // +2 for the \". \" prefix\n\n const formattedError = validationErrors\n .map((error, index) => {\n const lines = error.split(\"\\n\")\n const prefix = `${index + 1}. `\n\n return lines\n .map((line, lineIndex) => {\n const linePrefix = lineIndex === 0 ? prefix : \" \".repeat(numberPrefixLength)\n\n return `${linePrefix}${line}`\n })\n .join(\"\\r\\n\")\n })\n .join(\"\\r\\n\")\n\n return {\n status: \"error\",\n errorText: formattedError,\n }\n }\n}\n","import type { Logger } from \"pino\"\nimport type { DependentSetHandler, GraphResolver, ResolverOutputHandler } from \"./graph-resolver\"\nimport type { InstanceState } from \"../models/project\"\nimport { StateResolver } from \"./state\"\nimport { InputResolver, type InputResolverNode, type InputResolverOutput } from \"./input\"\nimport { InputHashResolver, type InputHashNode, type InputHashOutput } from \"./input-hash\"\nimport { ValidationResolver, type ValidationNode, type ValidationOutput } from \"./validation\"\n\nexport type GraphResolverType = keyof GraphResolverMap\n\nexport type GraphResolverMap = {\n InputResolver: [InputResolverNode, InputResolverOutput]\n InputHashResolver: [InputHashNode, InputHashOutput]\n ValidationResolver: [ValidationNode, ValidationOutput]\n StateResolver: [InstanceState, void]\n}\n\nexport const resolverFactories = {\n InputResolver,\n InputHashResolver,\n ValidationResolver,\n StateResolver,\n} as Record<\n GraphResolverType,\n new (\n nodes: ReadonlyMap<string, unknown>,\n logger: Logger,\n outputHandler?: ResolverOutputHandler<unknown>,\n dependentSetHandler?: DependentSetHandler,\n ) => GraphResolver<unknown, unknown>\n>\n"],"mappings":";AAAA,SAAS,SAAS;AAEX,IAAM,uBAAuB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM3C,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS3B,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOjC,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOjC,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO3B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/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":["z","z","z","z","WellKnownInstanceCustomStatus","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","nodeId","resolvedInputs","isUnitModel","isUnitModel","isUnitModel","isUnitModel","secretSchema"]}