apexrest 1.2.0 → 1.3.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +9 -3
  2. package/README.uk.md +9 -3
  3. package/dist/codex-compat/plugins/apexrest-apex/.codex-plugin/plugin.json +1 -1
  4. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/evidence/block%3Aanalytics%2Fstatus-summary%401.0.0.json +19 -0
  5. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/evidence/block%3Acrud%2Freport-dialog%401.0.0.json +19 -0
  6. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/evidence/block%3Aread%2Fdetail%401.0.0.json +19 -0
  7. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/evidence/block%3Aread%2Ffiltered-list%401.0.0.json +19 -0
  8. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/evidence/block%3Aread%2Fhistory%401.0.0.json +19 -0
  9. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/evidence/block%3Aread%2Fmaster-detail%401.0.0.json +19 -0
  10. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/generator.json +5 -0
  11. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/manifest.json +29 -0
  12. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/packages/analytics/status-summary/1.0.0/block.yaml +59 -0
  13. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/packages/analytics/status-summary/1.0.0/renderer.json +14 -0
  14. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/packages/crud/report-dialog/1.0.0/block.yaml +66 -0
  15. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/packages/crud/report-dialog/1.0.0/renderer.json +14 -0
  16. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/packages/read/detail/1.0.0/block.yaml +59 -0
  17. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/packages/read/detail/1.0.0/renderer.json +14 -0
  18. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/packages/read/filtered-list/1.0.0/block.yaml +59 -0
  19. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/packages/read/filtered-list/1.0.0/renderer.json +14 -0
  20. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/packages/read/history/1.0.0/block.yaml +59 -0
  21. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/packages/read/history/1.0.0/renderer.json +14 -0
  22. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/packages/read/master-detail/1.0.0/block.yaml +59 -0
  23. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/packages/read/master-detail/1.0.0/renderer.json +14 -0
  24. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/profiles.json +10 -0
  25. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/revocations.json +1 -0
  26. package/dist/codex-compat/plugins/apexrest-apex/resources/blueprints/crm.yaml +172 -0
  27. package/dist/codex-compat/plugins/apexrest-apex/resources/blueprints/index.json +12 -0
  28. package/dist/codex-compat/plugins/apexrest-apex/resources/blueprints/service-desk.yaml +120 -0
  29. package/dist/codex-compat/plugins/apexrest-apex/resources/panel/index.html +7 -0
  30. package/dist/codex-compat/plugins/apexrest-apex/resources/panel/panel.js +234 -2
  31. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-allocation.schema.json +33 -0
  32. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-block.schema.json +208 -0
  33. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-blueprint.schema.json +664 -0
  34. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-command.schema.json +106 -0
  35. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-contract.schema.json +174 -0
  36. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-diagnostic.schema.json +26 -0
  37. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-entity.schema.json +141 -0
  38. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-evidence.schema.json +95 -0
  39. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-field.schema.json +53 -0
  40. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-instance.schema.json +117 -0
  41. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-lock.schema.json +54 -0
  42. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-operation.schema.json +55 -0
  43. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-owner.schema.json +105 -0
  44. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-parameters.schema.json +61 -0
  45. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-plan.schema.json +1010 -0
  46. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-renderer.schema.json +69 -0
  47. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-state.schema.json +146 -0
  48. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/deploy-plan.schema.json +760 -169
  49. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/operations.schema.json +486 -0
  50. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/project.schema.json +13 -0
  51. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/sync-state.schema.json +238 -0
  52. package/dist/codex-compat/plugins/apexrest-apex/resources/third-party/node_modules__yaml__LICENSE +13 -0
  53. package/dist/codex-compat/plugins/apexrest-apex/runtime/apexrest.mjs +21 -11
  54. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-2BBNJVKW.mjs +1996 -0
  55. package/dist/codex-compat/plugins/apexrest-apex/runtime/{chunk-HOKFFGSZ.mjs → chunk-33GE2NWZ.mjs} +1 -1
  56. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-5JI3XEAK.mjs +14 -0
  57. package/dist/codex-compat/plugins/apexrest-apex/runtime/{chunk-2ZUNLCLK.mjs → chunk-BAHECVGO.mjs} +30 -10
  58. package/dist/{runtime/chunk-SPZVXAM5.mjs → codex-compat/plugins/apexrest-apex/runtime/chunk-CYPFCUNE.mjs} +7 -4
  59. package/dist/{runtime/chunk-3MDDJFXN.mjs → codex-compat/plugins/apexrest-apex/runtime/chunk-EBBEN4AV.mjs} +29 -6
  60. package/dist/{runtime/chunk-NDZ2RWQU.mjs → codex-compat/plugins/apexrest-apex/runtime/chunk-ESDVN7DS.mjs} +3 -2
  61. package/dist/codex-compat/plugins/apexrest-apex/runtime/{chunk-AQZLLQ3D.mjs → chunk-FTTPESNK.mjs} +2 -2
  62. package/dist/codex-compat/plugins/apexrest-apex/runtime/{chunk-S24BD6PY.mjs → chunk-G3KR57BY.mjs} +1 -1
  63. package/dist/codex-compat/plugins/apexrest-apex/runtime/{chunk-TXVQLYTH.mjs → chunk-HKJVCGQQ.mjs} +118 -87
  64. package/dist/codex-compat/plugins/apexrest-apex/runtime/{chunk-WK5GP4ES.mjs → chunk-KQ5IDT7Z.mjs} +2 -2
  65. package/dist/{runtime/chunk-7RZW5QV2.mjs → codex-compat/plugins/apexrest-apex/runtime/chunk-RWGJITHZ.mjs} +5 -5
  66. package/dist/codex-compat/plugins/apexrest-apex/runtime/{chunk-IX6V6ZGW.mjs → chunk-WXP75UUP.mjs} +5 -5
  67. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-YPLIIQ4Y.mjs +10233 -0
  68. package/dist/codex-compat/plugins/apexrest-apex/runtime/{chunk-QIVPMPU3.mjs → chunk-YQHHPRJH.mjs} +1 -1
  69. package/dist/codex-compat/plugins/apexrest-apex/runtime/mcp.mjs +7 -7
  70. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-apexlang/SKILL.md +1 -1
  71. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-compose/SKILL.md +18 -0
  72. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-compose/agents/openai.yaml +4 -0
  73. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-compose/references/workflow.md +15 -0
  74. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-deploy/SKILL.md +3 -1
  75. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-menu/SKILL.md +3 -1
  76. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-menu/references/cli-catalog.md +8 -1
  77. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-project/SKILL.md +2 -0
  78. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-work/SKILL.md +3 -1
  79. package/dist/resources/blocks/evidence/block%3Aanalytics%2Fstatus-summary%401.0.0.json +19 -0
  80. package/dist/resources/blocks/evidence/block%3Acrud%2Freport-dialog%401.0.0.json +19 -0
  81. package/dist/resources/blocks/evidence/block%3Aread%2Fdetail%401.0.0.json +19 -0
  82. package/dist/resources/blocks/evidence/block%3Aread%2Ffiltered-list%401.0.0.json +19 -0
  83. package/dist/resources/blocks/evidence/block%3Aread%2Fhistory%401.0.0.json +19 -0
  84. package/dist/resources/blocks/evidence/block%3Aread%2Fmaster-detail%401.0.0.json +19 -0
  85. package/dist/resources/blocks/generator.json +5 -0
  86. package/dist/resources/blocks/manifest.json +29 -0
  87. package/dist/resources/blocks/packages/analytics/status-summary/1.0.0/block.yaml +59 -0
  88. package/dist/resources/blocks/packages/analytics/status-summary/1.0.0/renderer.json +14 -0
  89. package/dist/resources/blocks/packages/crud/report-dialog/1.0.0/block.yaml +66 -0
  90. package/dist/resources/blocks/packages/crud/report-dialog/1.0.0/renderer.json +14 -0
  91. package/dist/resources/blocks/packages/read/detail/1.0.0/block.yaml +59 -0
  92. package/dist/resources/blocks/packages/read/detail/1.0.0/renderer.json +14 -0
  93. package/dist/resources/blocks/packages/read/filtered-list/1.0.0/block.yaml +59 -0
  94. package/dist/resources/blocks/packages/read/filtered-list/1.0.0/renderer.json +14 -0
  95. package/dist/resources/blocks/packages/read/history/1.0.0/block.yaml +59 -0
  96. package/dist/resources/blocks/packages/read/history/1.0.0/renderer.json +14 -0
  97. package/dist/resources/blocks/packages/read/master-detail/1.0.0/block.yaml +59 -0
  98. package/dist/resources/blocks/packages/read/master-detail/1.0.0/renderer.json +14 -0
  99. package/dist/resources/blocks/profiles.json +10 -0
  100. package/dist/resources/blocks/revocations.json +1 -0
  101. package/dist/resources/blueprints/crm.yaml +172 -0
  102. package/dist/resources/blueprints/index.json +12 -0
  103. package/dist/resources/blueprints/service-desk.yaml +120 -0
  104. package/dist/resources/panel/index.html +7 -0
  105. package/dist/resources/panel/panel.js +234 -2
  106. package/dist/resources/schemas/composer-allocation.schema.json +33 -0
  107. package/dist/resources/schemas/composer-block.schema.json +208 -0
  108. package/dist/resources/schemas/composer-blueprint.schema.json +664 -0
  109. package/dist/resources/schemas/composer-command.schema.json +106 -0
  110. package/dist/resources/schemas/composer-contract.schema.json +174 -0
  111. package/dist/resources/schemas/composer-diagnostic.schema.json +26 -0
  112. package/dist/resources/schemas/composer-entity.schema.json +141 -0
  113. package/dist/resources/schemas/composer-evidence.schema.json +95 -0
  114. package/dist/resources/schemas/composer-field.schema.json +53 -0
  115. package/dist/resources/schemas/composer-instance.schema.json +117 -0
  116. package/dist/resources/schemas/composer-lock.schema.json +54 -0
  117. package/dist/resources/schemas/composer-operation.schema.json +55 -0
  118. package/dist/resources/schemas/composer-owner.schema.json +105 -0
  119. package/dist/resources/schemas/composer-parameters.schema.json +61 -0
  120. package/dist/resources/schemas/composer-plan.schema.json +1010 -0
  121. package/dist/resources/schemas/composer-renderer.schema.json +69 -0
  122. package/dist/resources/schemas/composer-state.schema.json +146 -0
  123. package/dist/resources/schemas/deploy-plan.schema.json +760 -169
  124. package/dist/resources/schemas/operations.schema.json +486 -0
  125. package/dist/resources/schemas/project.schema.json +13 -0
  126. package/dist/resources/schemas/sync-state.schema.json +238 -0
  127. package/dist/resources/third-party/node_modules__yaml__LICENSE +13 -0
  128. package/dist/runtime/apexrest.mjs +21 -11
  129. package/dist/runtime/chunk-2BBNJVKW.mjs +1996 -0
  130. package/dist/runtime/{chunk-HOKFFGSZ.mjs → chunk-33GE2NWZ.mjs} +1 -1
  131. package/dist/runtime/chunk-5JI3XEAK.mjs +14 -0
  132. package/dist/runtime/{chunk-2ZUNLCLK.mjs → chunk-BAHECVGO.mjs} +30 -10
  133. package/dist/{codex-compat/plugins/apexrest-apex/runtime/chunk-SPZVXAM5.mjs → runtime/chunk-CYPFCUNE.mjs} +7 -4
  134. package/dist/{codex-compat/plugins/apexrest-apex/runtime/chunk-3MDDJFXN.mjs → runtime/chunk-EBBEN4AV.mjs} +29 -6
  135. package/dist/{codex-compat/plugins/apexrest-apex/runtime/chunk-NDZ2RWQU.mjs → runtime/chunk-ESDVN7DS.mjs} +3 -2
  136. package/dist/runtime/{chunk-AQZLLQ3D.mjs → chunk-FTTPESNK.mjs} +2 -2
  137. package/dist/runtime/{chunk-S24BD6PY.mjs → chunk-G3KR57BY.mjs} +1 -1
  138. package/dist/runtime/{chunk-TXVQLYTH.mjs → chunk-HKJVCGQQ.mjs} +118 -87
  139. package/dist/runtime/{chunk-WK5GP4ES.mjs → chunk-KQ5IDT7Z.mjs} +2 -2
  140. package/dist/{codex-compat/plugins/apexrest-apex/runtime/chunk-7RZW5QV2.mjs → runtime/chunk-RWGJITHZ.mjs} +5 -5
  141. package/dist/runtime/{chunk-IX6V6ZGW.mjs → chunk-WXP75UUP.mjs} +5 -5
  142. package/dist/runtime/chunk-YPLIIQ4Y.mjs +10233 -0
  143. package/dist/runtime/{chunk-QIVPMPU3.mjs → chunk-YQHHPRJH.mjs} +1 -1
  144. package/dist/runtime/mcp.mjs +7 -7
  145. package/package.json +10 -3
  146. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-4MYHJ2IU.mjs +0 -1208
  147. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-BD2AVCFU.mjs +0 -367
  148. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-YLXJ6H4J.mjs +0 -14
  149. package/dist/runtime/chunk-4MYHJ2IU.mjs +0 -1208
  150. package/dist/runtime/chunk-BD2AVCFU.mjs +0 -367
  151. package/dist/runtime/chunk-YLXJ6H4J.mjs +0 -14
@@ -1,367 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
- import {
3
- browserPreferences,
4
- browserPreferencesSchema,
5
- openVerificationBrowser
6
- } from "./chunk-4MYHJ2IU.mjs";
7
- import {
8
- VERSION
9
- } from "./chunk-S24BD6PY.mjs";
10
- import {
11
- OracleAdapter,
12
- configureConnection,
13
- configureSqlcl,
14
- connections,
15
- external_exports,
16
- loadProject,
17
- ordsUrl,
18
- ordsUsername,
19
- parse,
20
- policy,
21
- refName,
22
- requireTrust,
23
- runProcess,
24
- savedConnectionName,
25
- sqlclConfig,
26
- sqlclConfigSchema
27
- } from "./chunk-3MDDJFXN.mjs";
28
- import {
29
- Fault,
30
- contained,
31
- exists,
32
- readJson,
33
- sanitized,
34
- writeJson
35
- } from "./chunk-2Z3BZF66.mjs";
36
-
37
- // packages/core/src/panel-schema.ts
38
- var panelPreferencesSchema = external_exports.strictObject({
39
- browserMode: browserPreferencesSchema.shape.browserMode.removeDefault().optional()
40
- });
41
- var panelReadSchema = external_exports.strictObject({
42
- project: external_exports.string().min(1).max(4096).optional()
43
- });
44
- var connectionActionSchema = external_exports.strictObject({
45
- kind: external_exports.literal("connection"),
46
- name: refName,
47
- sqlclName: savedConnectionName.optional(),
48
- ordsUrl: ordsUrl.optional(),
49
- ordsUsername: ordsUsername.optional(),
50
- password: external_exports.string().min(1).max(4096).optional()
51
- });
52
- var panelActionSchema = external_exports.strictObject({
53
- project: external_exports.string().min(1).max(4096).optional(),
54
- action: external_exports.discriminatedUnion("kind", [
55
- external_exports.strictObject({ kind: external_exports.literal("preferences"), settings: panelPreferencesSchema }),
56
- external_exports.strictObject({ kind: external_exports.literal("sqlcl"), settings: sqlclConfigSchema }),
57
- external_exports.strictObject({ kind: external_exports.literal("saved-connections") }),
58
- connectionActionSchema,
59
- external_exports.strictObject({ kind: external_exports.literal("cancel-job"), id: external_exports.uuid() }),
60
- external_exports.strictObject({ kind: external_exports.literal("validate") }),
61
- external_exports.strictObject({ kind: external_exports.literal("browser"), env: external_exports.string().min(1).max(100) }),
62
- external_exports.strictObject({
63
- kind: external_exports.literal("test"),
64
- suite: external_exports.enum(["unit", "sql", "api", "e2e", "all"]),
65
- env: external_exports.string().min(1).max(100).optional()
66
- }),
67
- external_exports.strictObject({ kind: external_exports.literal("plan"), env: external_exports.string().min(1).max(100) })
68
- ])
69
- });
70
- var publicPanelActionSchema = panelActionSchema.extend({
71
- action: external_exports.discriminatedUnion("kind", [
72
- panelActionSchema.shape.action.options[0],
73
- ...panelActionSchema.shape.action.options.slice(1).map(
74
- (option) => option.shape.kind.value === "connection" ? connectionActionSchema.omit({ password: true }) : option
75
- )
76
- ])
77
- });
78
-
79
- // packages/core/src/jobs.ts
80
- import path from "node:path";
81
- import { spawn } from "node:child_process";
82
- import { randomUUID } from "node:crypto";
83
- import { setTimeout as delay } from "node:timers/promises";
84
- var JobService = class {
85
- constructor(ctx) {
86
- this.ctx = ctx;
87
- }
88
- ctx;
89
- async start(operation, input, runtime) {
90
- await requireTrust(this.ctx.root);
91
- if (!["apex.generate", "apex.export", "apex.validate", "deploy.plan", "deploy.apply", "test.run"].includes(
92
- operation
93
- ))
94
- throw new Fault("INVALID_JOB_OPERATION", "Operation cannot run as a background job.", 2);
95
- const id = randomUUID(), root = await contained(this.ctx.root, ".apexrest/jobs/" + id);
96
- await writeJson(path.join(root, "request.json"), {
97
- id,
98
- operation,
99
- input: { ...input, project: this.ctx.root }
100
- });
101
- await writeJson(path.join(root, "state.json"), {
102
- id,
103
- status: "queued",
104
- operation,
105
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
106
- });
107
- const worker = spawn(process.execPath, [runtime, "--job-worker", this.ctx.root, id], {
108
- cwd: this.ctx.root,
109
- env: process.env,
110
- detached: true,
111
- stdio: "ignore",
112
- windowsHide: true
113
- });
114
- await new Promise((resolve, reject) => {
115
- worker.once("spawn", resolve);
116
- worker.once("error", reject);
117
- });
118
- worker.unref();
119
- return {
120
- jobId: id,
121
- status: "queued",
122
- nextAction: "Wait for this job with apexrest_job_status and waitSeconds:25; never rerun the operation to fetch results. Cancellation does not imply database rollback."
123
- };
124
- }
125
- async status(id, waitSeconds = 0, signal) {
126
- parse(external_exports.uuid(), id);
127
- parse(external_exports.number().int().min(0).max(30), waitSeconds);
128
- const root = await contained(this.ctx.root, ".apexrest/jobs/" + id);
129
- const deadline = Date.now() + waitSeconds * 1e3;
130
- for (; ; ) {
131
- const state = await readJson(path.join(root, "state.json"));
132
- if (!["queued", "running"].includes(state.status)) return state;
133
- if (Date.parse(state.updatedAt) + 6e4 < Date.now())
134
- return {
135
- ...state,
136
- status: "outcome_unknown",
137
- nextAction: "Worker heartbeat expired. Reconcile target before retrying."
138
- };
139
- const remaining = deadline - Date.now();
140
- if (remaining <= 0 || signal?.aborted) return state;
141
- await delay(Math.min(250, remaining), void 0, { signal }).catch((error) => {
142
- if (!signal?.aborted) throw error;
143
- });
144
- }
145
- }
146
- async cancel(id) {
147
- await requireTrust(this.ctx.root);
148
- parse(external_exports.uuid(), id);
149
- const state = await this.status(id);
150
- if (!["queued", "running"].includes(state.status)) return state;
151
- await writeJson(await contained(this.ctx.root, ".apexrest/jobs/" + id + "/cancel.json"), {
152
- requestedAt: (/* @__PURE__ */ new Date()).toISOString()
153
- });
154
- return { jobId: id, status: "cancellation_requested", rollbackConfirmed: false };
155
- }
156
- };
157
- async function executeJob(ctx, id, execute) {
158
- await requireTrust(ctx.root);
159
- parse(external_exports.uuid(), id);
160
- const root = await contained(ctx.root, ".apexrest/jobs/" + id);
161
- const request = await readJson(path.join(root, "request.json"));
162
- const controller = new AbortController();
163
- let done = false;
164
- const pulse = async () => {
165
- if (done) return;
166
- if (await exists(path.join(root, "cancel.json"))) controller.abort();
167
- if (!done)
168
- await writeJson(path.join(root, "state.json"), {
169
- id,
170
- operation: request.operation,
171
- status: "running",
172
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
173
- });
174
- };
175
- await pulse();
176
- let pending = Promise.resolve();
177
- const timer = setInterval(() => {
178
- pending = pending.then(pulse).catch(() => {
179
- controller.abort();
180
- });
181
- }, 2e3), timeout = setTimeout(() => controller.abort(), 9e5);
182
- try {
183
- const result = await execute(request.operation, request.input, controller.signal);
184
- done = true;
185
- clearInterval(timer);
186
- clearTimeout(timeout);
187
- await pending;
188
- await writeJson(path.join(root, "state.json"), {
189
- id,
190
- status: "completed",
191
- result,
192
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
193
- });
194
- } finally {
195
- done = true;
196
- clearInterval(timer);
197
- clearTimeout(timeout);
198
- }
199
- }
200
-
201
- // packages/core/src/panel.ts
202
- import path2 from "node:path";
203
- import { fileURLToPath } from "node:url";
204
- import { readdir, realpath, stat } from "node:fs/promises";
205
- import { randomUUID as randomUUID2 } from "node:crypto";
206
- var safe = (value) => sanitized(value);
207
- var PanelService = class {
208
- constructor(root, oracle = new OracleAdapter()) {
209
- this.root = root;
210
- this.oracle = oracle;
211
- }
212
- root;
213
- oracle;
214
- async preferences() {
215
- return browserPreferences(this.root);
216
- }
217
- async records(folder) {
218
- const base = await contained(this.root, ".apexrest/" + folder);
219
- if (!await exists(base)) return [];
220
- const entries = (await readdir(base, { withFileTypes: true })).filter(
221
- (e) => e.isDirectory() && external_exports.uuid().safeParse(e.name).success
222
- );
223
- if (entries.length > 2e3)
224
- throw new Fault(
225
- "PANEL_HISTORY_LIMIT",
226
- "Archive old operation records before loading more than 2000 runs.",
227
- 2
228
- );
229
- const files = await Promise.all(
230
- entries.map(async (entry) => {
231
- const file = await contained(base, entry.name + "/state.json");
232
- const info = await stat(file).catch(() => null);
233
- return { id: entry.name, file, at: info?.mtimeMs ?? 0, size: info?.size ?? 0 };
234
- })
235
- );
236
- return Promise.all(
237
- files.filter((f) => f.size > 0).sort((a, b) => b.at - a.at).slice(0, 12).map(async (f) => {
238
- if (f.size > 2 * 1024 * 1024)
239
- return {
240
- id: f.id,
241
- status: "unavailable",
242
- diagnostics: ["Record exceeds the panel limit."]
243
- };
244
- try {
245
- return { ...await readJson(f.file), id: f.id };
246
- } catch {
247
- return {
248
- id: f.id,
249
- status: "unavailable",
250
- diagnostics: ["Cannot read this operation record."]
251
- };
252
- }
253
- })
254
- );
255
- }
256
- async snapshot() {
257
- this.root = await realpath(this.root);
258
- const ctx = await loadProject(this.root).catch((error) => {
259
- if (error instanceof Fault && error.code === "PROJECT_NOT_CONFIGURED") return null;
260
- throw error;
261
- });
262
- const [prefs, sqlcl, refs, security, jobRecords, deploymentRecords] = await Promise.all([
263
- this.preferences(),
264
- sqlclConfig(),
265
- connections(),
266
- policy(),
267
- this.records("jobs"),
268
- this.records("deployments")
269
- ]);
270
- const jobs = await Promise.all(
271
- jobRecords.map(async (row) => {
272
- const state = ctx ? await new JobService(ctx).status(String(row.id)) : row;
273
- const result = state.result ?? {};
274
- return {
275
- id: String(row.id),
276
- operation: String(row.operation ?? result.operation ?? "operation"),
277
- status: String(result.status ?? state.status),
278
- updatedAt: String(state.updatedAt ?? ""),
279
- summary: String(result.summary ?? "").slice(0, 1e3),
280
- diagnostics: Array.isArray(result.diagnostics) ? result.diagnostics.slice(0, 5) : [],
281
- artifacts: Array.isArray(result.artifacts) ? result.artifacts.slice(0, 10) : []
282
- };
283
- })
284
- );
285
- const deployments = deploymentRecords.map((row) => ({
286
- id: String(row.id),
287
- status: String(row.state ?? "unknown"),
288
- at: String(row.at ?? ""),
289
- details: JSON.stringify(safe(row.details ?? {})).slice(0, 1200)
290
- }));
291
- let changes = { status: "unavailable", files: [] };
292
- try {
293
- const git = await runProcess({
294
- executable: "git",
295
- args: ["status", "--porcelain=v1", "--untracked-files=normal"],
296
- cwd: this.root,
297
- timeoutMs: 3e3
298
- });
299
- if (git.code === 0)
300
- changes = { status: "available", files: git.stdout.split("\n").filter(Boolean).slice(0, 80) };
301
- } catch {
302
- }
303
- let toolchain = null;
304
- if (ctx) {
305
- const file = await contained(this.root, ctx.config.toolchain.lockFile);
306
- if (await exists(file)) {
307
- if ((await stat(file)).size <= 128e3) toolchain = await readJson(file);
308
- }
309
- }
310
- return safe({
311
- version: VERSION,
312
- updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
313
- project: this.root,
314
- configured: !!ctx,
315
- trusted: security.trustedProjects.includes(this.root),
316
- configuration: ctx?.config ?? null,
317
- sqlcl,
318
- preferences: prefs,
319
- connections: refs,
320
- toolchain,
321
- jobs,
322
- deployments,
323
- changes,
324
- permissions: {
325
- activeGrants: security.grants.filter((g) => g.projectRoot === this.root && Date.parse(g.expiresAt) > Date.now()).map((g) => ({ operations: g.operations, expiresAt: g.expiresAt, exactPlan: !!g.planDigest }))
326
- }
327
- });
328
- }
329
- async act(action) {
330
- action = parse(panelActionSchema, { action }).action;
331
- this.root = await realpath(this.root);
332
- await requireTrust(this.root);
333
- if (action.kind === "saved-connections") return this.oracle.savedConnections();
334
- if (action.kind === "preferences") {
335
- const settings = { ...await this.preferences(), ...action.settings };
336
- await writeJson(await contained(this.root, ".apexrest/panel/preferences.json"), settings);
337
- return { saved: true, appliesTo: "browser-verification" };
338
- }
339
- if (action.kind === "sqlcl") {
340
- return configureSqlcl(
341
- action.settings.mode,
342
- action.settings.mcpRestrictLevel,
343
- action.settings.databaseTransport
344
- );
345
- }
346
- if (action.kind === "connection") return configureConnection(action.name, action);
347
- const ctx = await loadProject(this.root);
348
- if (action.kind === "browser") return openVerificationBrowser(ctx, action.env);
349
- if (action.kind === "cancel-job") return new JobService(ctx).cancel(action.id);
350
- const operation = action.kind === "validate" ? "apex.validate" : action.kind === "plan" ? "deploy.plan" : "test.run";
351
- const input = action.kind === "plan" ? { env: action.env, out: ".apexrest/plans/" + randomUUID2() + ".json" } : action.kind === "test" ? { suite: action.suite, ...action.env ? { env: action.env } : {} } : {};
352
- return new JobService(ctx).start(
353
- operation,
354
- input,
355
- path2.join(path2.dirname(fileURLToPath(import.meta.url)), "apexrest.mjs")
356
- );
357
- }
358
- };
359
-
360
- export {
361
- panelReadSchema,
362
- panelActionSchema,
363
- publicPanelActionSchema,
364
- JobService,
365
- executeJob,
366
- PanelService
367
- };
@@ -1,14 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
- import {
3
- startMcp
4
- } from "./chunk-2ZUNLCLK.mjs";
5
- import "./chunk-TXVQLYTH.mjs";
6
- import "./chunk-AQZLLQ3D.mjs";
7
- import "./chunk-BD2AVCFU.mjs";
8
- import "./chunk-4MYHJ2IU.mjs";
9
- import "./chunk-S24BD6PY.mjs";
10
- import "./chunk-3MDDJFXN.mjs";
11
- import "./chunk-2Z3BZF66.mjs";
12
- export {
13
- startMcp
14
- };