@revoengine/cli 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +113 -12
  3. package/dist/src/application-access.d.ts +4 -0
  4. package/dist/src/application-access.js +18 -0
  5. package/dist/src/application-cors.d.ts +2 -0
  6. package/dist/src/application-cors.js +19 -0
  7. package/dist/src/argument-contract.js +24 -4
  8. package/dist/src/automation-contract.generated.d.ts +165 -6
  9. package/dist/src/automation-contract.generated.js +198 -6
  10. package/dist/src/cli.js +10 -2
  11. package/dist/src/client.d.ts +53 -1
  12. package/dist/src/client.js +84 -0
  13. package/dist/src/commands/applications.d.ts +2 -0
  14. package/dist/src/commands/applications.js +44 -0
  15. package/dist/src/commands/emulate.d.ts +1 -0
  16. package/dist/src/commands/emulate.js +79 -3
  17. package/dist/src/commands/index.d.ts +2 -0
  18. package/dist/src/commands/index.js +2 -0
  19. package/dist/src/commands/migrate.js +10 -2
  20. package/dist/src/commands/sites.d.ts +2 -0
  21. package/dist/src/commands/sites.js +156 -0
  22. package/dist/src/commands/terminal-pty.js +2 -1
  23. package/dist/src/component-lock.d.ts +2 -1
  24. package/dist/src/component-lock.js +22 -1
  25. package/dist/src/endpoint-application.d.ts +25 -0
  26. package/dist/src/endpoint-application.js +75 -0
  27. package/dist/src/endpoint-emulator.d.ts +5 -0
  28. package/dist/src/endpoint-emulator.js +29 -0
  29. package/dist/src/endpoint-storage-transports.d.ts +2 -0
  30. package/dist/src/endpoint-storage-transports.js +8 -0
  31. package/dist/src/metadata-backfill.d.ts +1 -1
  32. package/dist/src/metadata-backfill.js +10 -1
  33. package/dist/src/migration.d.ts +6 -2
  34. package/dist/src/migration.js +104 -41
  35. package/dist/src/project.d.ts +8 -1
  36. package/dist/src/project.js +4 -0
  37. package/dist/src/request-contract.d.ts +5 -0
  38. package/dist/src/request-contract.js +12 -0
  39. package/dist/src/resource-inventory.d.ts +4 -2
  40. package/dist/src/resource-inventory.js +16 -1
  41. package/dist/src/resource-syncs/account-principal.d.ts +2 -0
  42. package/dist/src/resource-syncs/account-principal.js +3 -0
  43. package/dist/src/resource-syncs/application-principals.d.ts +60 -0
  44. package/dist/src/resource-syncs/application-principals.js +151 -0
  45. package/dist/src/resource-syncs/application-sync.d.ts +110 -0
  46. package/dist/src/resource-syncs/application-sync.js +328 -0
  47. package/dist/src/resource-syncs/endpoint-sync.d.ts +38 -0
  48. package/dist/src/resource-syncs/endpoint-sync.js +278 -14
  49. package/dist/src/resource-syncs/group-sync.d.ts +12 -0
  50. package/dist/src/resource-syncs/group-sync.js +60 -6
  51. package/dist/src/resource-syncs/runtime-definition-validation.js +26 -1
  52. package/dist/src/resource-syncs/service-account-sync.d.ts +10 -0
  53. package/dist/src/resource-syncs/service-account-sync.js +32 -4
  54. package/dist/src/reviewed-plan.js +2 -2
  55. package/dist/src/sync-omit-write-fence.js +4 -1
  56. package/dist/src/sync-omit.d.ts +1 -1
  57. package/dist/src/sync-omit.js +7 -2
  58. package/dist/src/tracked-resources.d.ts +1 -1
  59. package/dist/src/tracked-resources.js +3 -2
  60. package/dist/src/types.d.ts +30 -0
  61. package/dist/src/ui.js +2 -0
  62. package/dist/src/workspace-diff.js +1 -0
  63. package/dist/src/workspace-digests.js +2 -0
  64. package/dist/src/workspace-prune.js +67 -9
  65. package/package.json +11 -6
  66. package/scripts/postinstall.mjs +40 -0
@@ -40,6 +40,7 @@ export type GroupPullResult = {
40
40
  };
41
41
  export type GroupPlanStatus = 'clean' | 'create' | 'manual-owner' | 'safe-update' | 'remote-changed' | 'conflict' | 'missing-lock' | 'orphan' | 'collision' | 'skipped' | 'delete';
42
42
  export type GroupPlanItem = {
43
+ targetRevisionHash?: string;
43
44
  fieldChanges?: FieldChange[];
44
45
  status: GroupPlanStatus;
45
46
  stableKey?: string;
@@ -62,7 +63,15 @@ export type GroupsPlan = {
62
63
  warnings: string[];
63
64
  exclusions: string[];
64
65
  };
66
+ export type VerifiedGroup = {
67
+ stableKey: string;
68
+ groupId: string;
69
+ version: number;
70
+ desiredHash: string;
71
+ revisionHash: string;
72
+ };
65
73
  export type GroupPushResult = {
74
+ verifiedGroup?: VerifiedGroup;
66
75
  stableKey: string;
67
76
  action: 'create' | 'update' | 'noop' | 'manual-owner' | 'orphan' | 'skipped';
68
77
  status: 'deployed' | 'skipped' | 'failed';
@@ -70,6 +79,8 @@ export type GroupPushResult = {
70
79
  reason?: string;
71
80
  error?: string;
72
81
  };
82
+ /** Stable source/admission snapshot; signed avatars and member profile data never enter receipts. */
83
+ export declare function groupRevisionHash(record: GroupRecord): string;
73
84
  export declare function groupManifestFromRecord(record: GroupRecord, stableKeyName: string): GroupManifest | null;
74
85
  export declare function hashPortableGroup(manifest: GroupManifest): string;
75
86
  export declare function groupManifestPath(workspaceRoot: string, manifest: GroupManifest): string;
@@ -100,6 +111,7 @@ export declare function pushGroups(input: {
100
111
  stableKeyName: string;
101
112
  force?: boolean;
102
113
  onlyStableKeys?: string[];
114
+ reviewedPlan?: GroupsPlan;
103
115
  }): Promise<{
104
116
  plan: GroupsPlan;
105
117
  results: GroupPushResult[];
@@ -29,6 +29,23 @@ function groupMemberCount(record) {
29
29
  : 0;
30
30
  return Math.max(members, users, declared);
31
31
  }
32
+ /** Stable source/admission snapshot; signed avatars and member profile data never enter receipts. */
33
+ export function groupRevisionHash(record) {
34
+ const memberIds = [...new Set([...(record.members ?? []), ...(record.users ?? [])].map(value => typeof value === 'string' ? value : isRecord(value) && typeof (value.userId ?? value.id) === 'string' ? String(value.userId ?? value.id) : '<unresolved>'))].sort();
35
+ return hashStable({
36
+ groupId: groupIdOf(record), version: record.version ?? null, name: record.name ?? '', category: record.category ?? null,
37
+ description: record.description ?? record.desc ?? '', metadata: groupMetadataOf(record), accessType: record.accessType ?? null,
38
+ ownerType: typeof record.ownerType === 'string' ? record.ownerType.toUpperCase() : null, ownerId: record.ownerId ?? null,
39
+ leaderId: record.leaderId ?? null, deletedAt: record.deletedAt ?? null, deletedBy: record.deletedBy ?? null,
40
+ memberCount: groupMemberCount(record), membershipIdentityDigest: hashStable(memberIds),
41
+ });
42
+ }
43
+ function verifiedGroupReceipt(stableKey, record, desiredHash, expectedId, stableKeyName) {
44
+ if (!expectedId || groupIdOf(record) !== expectedId || !Number.isSafeInteger(record.version) || Number(record.version) < 0
45
+ || record.deletedAt || record.deletedBy || stableKeyOf(record, stableKeyName) !== stableKey)
46
+ throw new Error('Group readback requires the exact live physical identity and version.');
47
+ return { stableKey, groupId: expectedId, version: record.version, desiredHash, revisionHash: groupRevisionHash(record) };
48
+ }
32
49
  function groupHint(value) {
33
50
  return JSON.stringify([
34
51
  value.category ?? null,
@@ -485,6 +502,7 @@ export async function buildGroupsPlan(input) {
485
502
  name: desired.name,
486
503
  desiredHash,
487
504
  currentHash: target.hash,
505
+ targetRevisionHash: groupRevisionHash(target.record),
488
506
  ...(desiredOwner?.type === 'system' ? { ownerKind: 'system' } : {}),
489
507
  ...(ownerStableKey ? { ownerStableKey, ownerKind: desiredOwner?.type === 'service-account' ? 'service-account' : 'group' } : {}),
490
508
  ...(changedFields.length > 0 ? {
@@ -799,8 +817,15 @@ function updateEnvironmentBaseline(input) {
799
817
  lock.groups[input.stableKey] = nextEntry;
800
818
  writeComponentLock(projectRoot, lock);
801
819
  }
802
- function localManifestByStableKey(cwd) {
803
- return new Map(readWorkspaceGroups(cwd).map((entry) => [entry.manifest.stableKey, entry]));
820
+ function localManifestByStableKey(cwd, stableKeyName, onlyStableKeys) {
821
+ const entries = readWorkspaceGroups(cwd).filter(entry => !onlyStableKeys || onlyStableKeys.includes(entry.manifest.stableKey));
822
+ const result = new Map();
823
+ for (const entry of entries) {
824
+ if (validateManifest(entry.manifest, stableKeyName).length || result.has(entry.manifest.stableKey))
825
+ throw new Error('Group source identity or definition changed after review.');
826
+ result.set(entry.manifest.stableKey, entry);
827
+ }
828
+ return result;
804
829
  }
805
830
  async function liveOwnerMatches(client, stableKeyName, item) {
806
831
  if (item.ownerKind === 'system') {
@@ -832,7 +857,8 @@ function resultTargetPath(cwd, localByKey, item) {
832
857
  return local ? localTargetPath(cwd, local.manifestPath) : item.stableKey || item.name;
833
858
  }
834
859
  export async function pushGroups(input) {
835
- const plan = await buildGroupsPlan(input);
860
+ const reviewedItems = input.reviewedPlan && input.onlyStableKeys ? input.reviewedPlan.items.filter(item => item.stableKey && input.onlyStableKeys.includes(item.stableKey)) : input.reviewedPlan?.items;
861
+ const plan = input.reviewedPlan ? { ...input.reviewedPlan, items: reviewedItems } : await buildGroupsPlan(input);
836
862
  if (plan.blockers.length > 0) {
837
863
  throw new Error(`Group push blocked: ${plan.blockers.join(' ')}`);
838
864
  }
@@ -845,12 +871,31 @@ export async function pushGroups(input) {
845
871
  if (plan.items.some((item) => item.status === 'collision')) {
846
872
  throw new Error('Group push blocked by stableKey collision; --force cannot bypass identity ambiguity.');
847
873
  }
848
- const localByKey = localManifestByStableKey(input.cwd);
874
+ const localByKey = localManifestByStableKey(input.cwd, input.stableKeyName, input.onlyStableKeys);
849
875
  const results = [];
850
876
  for (const item of plan.items.filter((candidate) => candidate.status === 'clean')) {
851
877
  if (!item.stableKey || !item.currentHash) {
852
878
  continue;
853
879
  }
880
+ const local = localByKey.get(item.stableKey);
881
+ if (!local || hashPortableGroup(local.manifest) !== item.desiredHash)
882
+ throw new Error('Group source changed after review.');
883
+ const matches = await liveTargetByStableKey(input.client, input.stableKeyName, item.stableKey);
884
+ if (matches.length !== 1)
885
+ throw new Error('Group target identity changed after review.');
886
+ const targetId = groupIdOf(matches[0]);
887
+ const verified = unwrapData(await input.client.getGroup(targetId));
888
+ if (!item.targetRevisionHash || groupRevisionHash(verified) !== item.targetRevisionHash)
889
+ throw new Error('Group target identity or revision changed after review.');
890
+ const verifiedManifest = groupManifestFromRecord(verified, input.stableKeyName);
891
+ if (verifiedManifest && local.manifest.owner && verified.ownerType === 'USER' && verified.ownerId) {
892
+ const principal = await accountPrincipal(input.client, verified.ownerId, input.stableKeyName);
893
+ if (principal)
894
+ verifiedManifest.owner = ownerFromPrincipal(principal);
895
+ }
896
+ if (!verifiedManifest || hashPortableGroup(verifiedManifest) !== item.desiredHash)
897
+ throw new Error('Group clean readback changed after review.');
898
+ const verifiedGroup = verifiedGroupReceipt(item.stableKey, verified, item.desiredHash, targetId, input.stableKeyName);
854
899
  updateEnvironmentBaseline({
855
900
  cwd: input.cwd,
856
901
  envName: input.envName,
@@ -860,6 +905,7 @@ export async function pushGroups(input) {
860
905
  results.push({
861
906
  stableKey: item.stableKey,
862
907
  action: 'noop',
908
+ verifiedGroup,
863
909
  status: 'skipped',
864
910
  targetPath: resultTargetPath(input.cwd, localByKey, item),
865
911
  reason: 'no local changes',
@@ -906,6 +952,8 @@ export async function pushGroups(input) {
906
952
  throw new Error('create response did not include groupId');
907
953
  }
908
954
  const verified = unwrapData(await input.client.getGroup(createdId));
955
+ if (!Number.isSafeInteger(created.version) || verified.version !== created.version)
956
+ throw new Error('Created Group revision changed before readback.');
909
957
  const verifiedManifest = groupManifestFromRecord(verified, input.stableKeyName);
910
958
  if (verifiedManifest && local.manifest.owner && verified.ownerType === 'USER' && verified.ownerId) {
911
959
  const principal = await accountPrincipal(input.client, verified.ownerId, input.stableKeyName);
@@ -921,8 +969,9 @@ export async function pushGroups(input) {
921
969
  if (String(verified.ownerType || '').toUpperCase() !== (item.ownerKind === 'service-account' || item.ownerKind === 'system' ? 'USER' : 'GROUP') || verified.ownerId !== ownerId) {
922
970
  throw new Error('created Group did not retain the resolved target owner');
923
971
  }
972
+ const verifiedGroup = verifiedGroupReceipt(stableKey, verified, liveDesiredHash, createdId, input.stableKeyName);
924
973
  updateEnvironmentBaseline({ cwd: input.cwd, envName: input.envName, stableKey, remoteHash: liveDesiredHash });
925
- results.push({ stableKey, action: 'create', status: 'deployed', targetPath });
974
+ results.push({ stableKey, action: 'create', status: 'deployed', targetPath, verifiedGroup });
926
975
  }
927
976
  catch (error) {
928
977
  results.push({ stableKey, action: 'create', status: 'failed', targetPath, error: error instanceof Error ? error.message : String(error) });
@@ -966,6 +1015,8 @@ export async function pushGroups(input) {
966
1015
  throw new Error('live target did not include groupId');
967
1016
  }
968
1017
  const target = unwrapData(await input.client.getGroup(targetId));
1018
+ if (!item.targetRevisionHash || groupRevisionHash(target) !== item.targetRevisionHash)
1019
+ throw new Error('Group target identity or revision changed after review.');
969
1020
  const targetManifest = groupManifestFromRecord(target, input.stableKeyName);
970
1021
  if (targetManifest && local.manifest.owner && target.ownerType === 'USER' && target.ownerId) {
971
1022
  const principal = await accountPrincipal(input.client, target.ownerId, input.stableKeyName);
@@ -989,6 +1040,8 @@ export async function pushGroups(input) {
989
1040
  }
990
1041
  await input.client.updateGroup(targetId, buildUpdatePayload(preserveOmittedProperties('group', local.manifest, targetManifest), target, desiredOwnerId, item.ownerKind === 'service-account' || item.ownerKind === 'system' ? 'USER' : 'GROUP'));
991
1042
  const verified = unwrapData(await input.client.getGroup(targetId));
1043
+ if (!Number.isSafeInteger(target.version) || verified.version !== Number(target.version) + 1)
1044
+ throw new Error('Updated Group revision changed before readback.');
992
1045
  const verifiedManifest = groupManifestFromRecord(verified, input.stableKeyName);
993
1046
  if (verifiedManifest && local.manifest.owner && verified.ownerType === 'USER' && verified.ownerId) {
994
1047
  const principal = await accountPrincipal(input.client, verified.ownerId, input.stableKeyName);
@@ -1004,8 +1057,9 @@ export async function pushGroups(input) {
1004
1057
  || verified.ownerId !== desiredOwnerId)) {
1005
1058
  throw new Error('updated Group did not retain the resolved target owner');
1006
1059
  }
1060
+ const verifiedGroup = verifiedGroupReceipt(stableKey, verified, liveDesiredHash, targetId, input.stableKeyName);
1007
1061
  updateEnvironmentBaseline({ cwd: input.cwd, envName: input.envName, stableKey, remoteHash: liveDesiredHash });
1008
- results.push({ stableKey, action: 'update', status: 'deployed', targetPath });
1062
+ results.push({ stableKey, action: 'update', status: 'deployed', targetPath, verifiedGroup });
1009
1063
  }
1010
1064
  catch (error) {
1011
1065
  results.push({ stableKey, action: 'update', status: 'failed', targetPath, error: error instanceof Error ? error.message : String(error) });
@@ -1,4 +1,4 @@
1
- import { requestContractDefaults, validateRequestContract } from "../request-contract.js";
1
+ import { requestContractDefaults, requestContracts, validateRequestContract } from "../request-contract.js";
2
2
  import { isRecord } from "./util.js";
3
3
  /** Matches the Endpoint DTO transform, so accepted normalized routes also verify on readback. */
4
4
  export function normalizeEndpointPath(value) {
@@ -77,6 +77,7 @@ export function endpointDefinitionErrors(manifest) {
77
77
  const route = isRecord(manifest.route) ? manifest.route : {};
78
78
  const body = { ...requestFields(manifest),
79
79
  ...(manifest.description === undefined ? {} : { desc: manifest.description }),
80
+ ...(manifest.allowUnauthenticated === undefined ? {} : { allowUnauthenticated: manifest.allowUnauthenticated }),
80
81
  method: route.method, path: typeof route.path === 'string' ? normalizeEndpointPath(route.path) : route.path };
81
82
  const errors = validateRequestContract('EndpointRequestDto', body, { partial: true, path: 'Endpoint' });
82
83
  if (typeof body.path === 'string' && body.path.split('/').filter(Boolean).length > requestContractDefaults.endpoint.maxPathSegments) {
@@ -86,6 +87,30 @@ export function endpointDefinitionErrors(manifest) {
86
87
  errors.push(...validateRequestContract('EndpointOptionsDto', { componentSchemaElement: manifest.schema.element }, { path: 'Endpoint.options' }));
87
88
  }
88
89
  const options = isRecord(manifest.options) ? manifest.options : {};
90
+ if (isRecord(options.requestBody)) {
91
+ const requestBody = options.requestBody;
92
+ const maxBytes = ['json', 'form', 'storage'].includes(String(requestBody.mode))
93
+ ? requestContractDefaults.endpoint.requestBody.maxBytes : requestContractDefaults.endpoint.requestBody.inlineMaxBytes;
94
+ if (requestBody.maxBytes !== undefined && (!Number.isInteger(requestBody.maxBytes) || Number(requestBody.maxBytes) < 1 || Number(requestBody.maxBytes) > maxBytes))
95
+ errors.push(`Endpoint.options.requestBody.maxBytes exceeds the ${maxBytes} byte limit for this mode`);
96
+ if (requestBody.storage !== undefined)
97
+ errors.push('Endpoint.options.requestBody.storage was removed; use mode storage and select an upload session in the Component result');
98
+ if (requestBody.mode === 'storage' && ((options.responseMode ?? 'http') !== 'http' || options.legacyResults || options.noResult || [204, 205].includes(Number(options.httpCode)) || options.responseBody != null))
99
+ errors.push('Endpoint Storage upload requires HTTP, modern Component results and a fixed JSON receipt without responseBody');
100
+ if (!isRecord(manifest.execution) || !['POST', 'PUT', 'PATCH', 'DELETE'].includes(String(route.method).toUpperCase()) || options.response != null)
101
+ errors.push('Endpoint.options.requestBody requires a body-capable Component endpoint without a static response');
102
+ }
103
+ if (isRecord(options.responseBody) && options.responseBody.maxBytes !== undefined
104
+ && (!Number.isInteger(options.responseBody.maxBytes) || Number(options.responseBody.maxBytes) < 1
105
+ || Number(options.responseBody.maxBytes) > Number(requestContracts.EndpointResponseBodyDto.properties?.maxBytes.maximum)))
106
+ errors.push('Endpoint.options.responseBody.maxBytes must fit its canonical byte limit');
107
+ if (isRecord(options.responseBody) && ((options.responseMode ?? 'http') !== 'http' || options.legacyResults))
108
+ errors.push('Endpoint.options.responseBody requires HTTP and does not support legacyResults');
109
+ if (isRecord(options.responseBody) && options.responseBody.mode === 'storage'
110
+ && (!isRecord(manifest.execution) || options.response != null || options.noResult === true || options.responseBody.contentType !== undefined
111
+ || options.httpCode !== undefined && options.httpCode !== 200
112
+ || isRecord(options.responseBody.headers) && Object.keys(options.responseBody.headers).some(name => name.toLowerCase() === 'content-disposition')))
113
+ errors.push('Endpoint Storage download requires a Component result, HTTP 200 and native file metadata without static response, noResult, contentType or Content-Disposition overrides');
89
114
  if (options.guard && manifest.schema)
90
115
  errors.push('Endpoint static guard and schema component cannot be configured together');
91
116
  // Full schema compilation remains owned by Sandbox; these are the API's root envelope semantics.
@@ -29,6 +29,7 @@ export type ServiceAccountPullResult = {
29
29
  };
30
30
  export type ServiceAccountPlanStatus = 'clean' | 'create' | 'safe-update' | 'remote-changed' | 'conflict' | 'missing-lock' | 'orphan' | 'collision' | 'skipped' | 'delete' | 'manual-owner';
31
31
  export type ServiceAccountPlanItem = {
32
+ targetRevisionHash?: string;
32
33
  fieldChanges?: FieldChange[];
33
34
  status: ServiceAccountPlanStatus;
34
35
  stableKey?: string;
@@ -48,7 +49,15 @@ export type ServiceAccountsPlan = {
48
49
  items: ServiceAccountPlanItem[];
49
50
  exclusions: string[];
50
51
  };
52
+ export type VerifiedServiceAccount = {
53
+ stableKey: string;
54
+ userId: string;
55
+ version: number;
56
+ desiredHash: string;
57
+ revisionHash: string;
58
+ };
51
59
  export type ServiceAccountPushResult = {
60
+ verifiedServiceAccount?: VerifiedServiceAccount;
52
61
  stableKey: string;
53
62
  action: 'create' | 'update' | 'noop' | 'orphan' | 'skipped';
54
63
  status: 'deployed' | 'skipped' | 'failed';
@@ -92,6 +101,7 @@ export declare function pushServiceAccounts(input: {
92
101
  stableKeyName: string;
93
102
  force?: boolean;
94
103
  onlyStableKeys?: string[];
104
+ reviewedPlan?: ServiceAccountsPlan;
95
105
  }): Promise<{
96
106
  plan: ServiceAccountsPlan;
97
107
  results: ServiceAccountPushResult[];
@@ -1,7 +1,7 @@
1
1
  import { assertOmittedPropertiesPreserved, hashSyncDefinition, preserveOmittedProperties, syncBaselineHash, syncSourceBaselineHash, withoutSyncOmit } from "../sync-omit.js";
2
2
  import path from 'node:path';
3
3
  import { readPortableOwner, resolvePortableOwner, ownerIsAvailable } from "./account-principal.js";
4
- import { isBuiltinSystemAccount } from "./account-principal.js";
4
+ import { isBuiltinSystemAccount, serviceAccountRevisionHash } from "./account-principal.js";
5
5
  import { describeFieldChanges } from "../diff-details.js";
6
6
  import { hashStable, readComponentLock, writeComponentLock, } from "../component-lock.js";
7
7
  import { readConfiguredResourceMetadataStableKey, sanitizeUserMetadata, } from "../resource-metadata.js";
@@ -245,6 +245,7 @@ export async function buildServiceAccountsPlan(input) {
245
245
  name: desired.name,
246
246
  desiredHash,
247
247
  currentHash: target.hash,
248
+ targetRevisionHash: serviceAccountRevisionHash(target.record),
248
249
  ...(diff.changedFields.length > 0 ? { changedFields: diff.changedFields, fieldChanges: describeFieldChanges(desired, target.manifest, diff.changedFields) } : {}),
249
250
  };
250
251
  if (desiredHash === target.hash) {
@@ -549,8 +550,14 @@ async function assertCreateStillSafe(client, stableKeyName, desired) {
549
550
  }
550
551
  }
551
552
  }
553
+ function serviceAccountReceipt(stableKey, record, desiredHash) {
554
+ if (!record.userId || !Number.isInteger(record.version))
555
+ throw new Error('Service Account readback requires exact userId/version.');
556
+ return { stableKey, userId: record.userId, version: record.version, desiredHash, revisionHash: serviceAccountRevisionHash(record) };
557
+ }
552
558
  export async function pushServiceAccounts(input) {
553
- const plan = await buildServiceAccountsPlan(input);
559
+ const reviewedItems = input.reviewedPlan && input.onlyStableKeys ? input.reviewedPlan.items.filter(item => item.stableKey && input.onlyStableKeys.includes(item.stableKey)) : input.reviewedPlan?.items;
560
+ const plan = input.reviewedPlan ? { ...input.reviewedPlan, items: reviewedItems } : await buildServiceAccountsPlan(input);
554
561
  if (plan.blockers.length > 0) {
555
562
  throw new Error(`Service-account push blocked: ${plan.blockers.join(' ')}`);
556
563
  }
@@ -569,10 +576,23 @@ export async function pushServiceAccounts(input) {
569
576
  continue;
570
577
  }
571
578
  const local = localByKey.get(exactKey(item.stableKey));
579
+ if (!local || hashPortableServiceAccount(local.manifest) !== item.desiredHash)
580
+ throw new Error('Service Account source changed after review.');
581
+ const matches = await liveTargetByStableKey(input.client, input.stableKeyName, item.stableKey);
582
+ if (matches.length !== 1)
583
+ throw new Error('Service Account target identity changed after review.');
584
+ const verified = unwrapData(await input.client.getServiceAccount(serviceAccountIdOf(matches[0])));
585
+ if (item.targetRevisionHash !== serviceAccountRevisionHash(verified))
586
+ throw new Error('Service Account target revision changed after review.');
587
+ const verifiedManifest = await serviceAccountManifestFromRecord(input.client, verified, input.stableKeyName);
588
+ if (!verifiedManifest || hashPortableServiceAccount(comparableManifest(local.manifest, verifiedManifest)) !== item.desiredHash)
589
+ throw new Error('Service Account clean readback changed after review.');
590
+ const verifiedServiceAccount = serviceAccountReceipt(item.stableKey, verified, item.desiredHash);
572
591
  updateEnvironmentBaseline({ cwd: input.cwd, envName: input.envName, stableKey: item.stableKey, remoteHash: item.currentHash });
573
592
  results.push({
574
593
  stableKey: item.stableKey,
575
594
  action: 'noop',
595
+ verifiedServiceAccount,
576
596
  status: 'skipped',
577
597
  targetPath: local ? localTargetPath(input.cwd, local.manifestPath) : item.stableKey,
578
598
  reason: 'No local changes; target-local secrets are preserved',
@@ -607,6 +627,8 @@ export async function pushServiceAccounts(input) {
607
627
  throw new Error('create response did not include userId');
608
628
  }
609
629
  const verified = unwrapData(await input.client.getServiceAccount(createdId));
630
+ if (verified.userId !== createdId || verified.version !== created.version)
631
+ throw new Error('Created Service Account readback changed identity or revision.');
610
632
  const rawVerifiedManifest = await serviceAccountManifestFromRecord(input.client, verified, input.stableKeyName);
611
633
  const verifiedManifest = rawVerifiedManifest ? comparableManifest(local.manifest, rawVerifiedManifest) : null;
612
634
  if (!verifiedManifest || hashPortableServiceAccount(verifiedManifest) !== liveDesiredHash) {
@@ -614,8 +636,9 @@ export async function pushServiceAccounts(input) {
614
636
  }
615
637
  if (!withoutSyncOmit(() => hashPortableServiceAccount(verifiedManifest) === hashPortableServiceAccount(local.manifest)))
616
638
  throw new Error('Created resource did not initialize the complete source definition.');
639
+ const verifiedServiceAccount = serviceAccountReceipt(stableKey, verified, liveDesiredHash);
617
640
  updateEnvironmentBaseline({ cwd: input.cwd, envName: input.envName, stableKey, remoteHash: liveDesiredHash });
618
- results.push({ stableKey, action: 'create', status: 'deployed', targetPath, reason: 'Created; secrets are target-local and require separate configuration', credentials: { stableKey, environment: input.envName, policy: 'target-local', status: 'configure-manually' } });
641
+ results.push({ verifiedServiceAccount, stableKey, action: 'create', status: 'deployed', targetPath, reason: 'Created; secrets are target-local and require separate configuration', credentials: { stableKey, environment: input.envName, policy: 'target-local', status: 'configure-manually' } });
619
642
  }
620
643
  catch (error) {
621
644
  results.push({ stableKey, action: 'create', status: 'failed', targetPath, error: error instanceof Error ? error.message : String(error) });
@@ -632,6 +655,8 @@ export async function pushServiceAccounts(input) {
632
655
  throw new Error('live target did not include userId');
633
656
  }
634
657
  let target = unwrapData(await input.client.getServiceAccount(targetId));
658
+ if (item.targetRevisionHash !== serviceAccountRevisionHash(target))
659
+ throw new Error('Service Account target identity or revision changed after review.');
635
660
  let targetManifest = await serviceAccountManifestFromRecord(input.client, target, input.stableKeyName);
636
661
  if (targetManifest) {
637
662
  targetManifest = comparableManifest(local.manifest, targetManifest);
@@ -641,6 +666,7 @@ export async function pushServiceAccounts(input) {
641
666
  }
642
667
  const preservedTargetManifest = structuredClone(targetManifest);
643
668
  const diff = diffServiceAccounts(local.manifest, targetManifest);
669
+ const expectedVersion = Number(target.version) + (diff.changedFields.length > 0 ? 1 : 0);
644
670
  if (diff.changedFields.length > 0) {
645
671
  await input.client.updateServiceAccount(targetId, await buildBaseUpdatePayload(input.client, preserveOmittedProperties('service-account', local.manifest, targetManifest), target, input.stableKeyName));
646
672
  target = unwrapData(await input.client.getServiceAccount(targetId));
@@ -650,6 +676,8 @@ export async function pushServiceAccounts(input) {
650
676
  }
651
677
  }
652
678
  const verified = unwrapData(await input.client.getServiceAccount(targetId));
679
+ if (verified.userId !== targetId || verified.version !== expectedVersion)
680
+ throw new Error('Service Account readback changed identity or revision.');
653
681
  const rawVerifiedManifest = await serviceAccountManifestFromRecord(input.client, verified, input.stableKeyName);
654
682
  const verifiedManifest = rawVerifiedManifest ? comparableManifest(local.manifest, rawVerifiedManifest) : null;
655
683
  if (!verifiedManifest || hashPortableServiceAccount(verifiedManifest) !== liveDesiredHash) {
@@ -657,7 +685,7 @@ export async function pushServiceAccounts(input) {
657
685
  }
658
686
  assertOmittedPropertiesPreserved('service-account', preservedTargetManifest, verifiedManifest);
659
687
  updateEnvironmentBaseline({ cwd: input.cwd, envName: input.envName, stableKey, remoteHash: liveDesiredHash });
660
- results.push({ stableKey, action: 'update', status: 'deployed', targetPath, reason: 'Target-local secrets preserved', credentials: { stableKey, environment: input.envName, policy: 'target-local', status: 'preserved-target-local' } });
688
+ results.push({ verifiedServiceAccount: serviceAccountReceipt(stableKey, verified, liveDesiredHash), stableKey, action: 'update', status: 'deployed', targetPath, reason: 'Target-local secrets preserved', credentials: { stableKey, environment: input.envName, policy: 'target-local', status: 'preserved-target-local' } });
661
689
  }
662
690
  catch (error) {
663
691
  results.push({ stableKey, action: 'update', status: 'failed', targetPath, error: error instanceof Error ? error.message : String(error) });
@@ -1,5 +1,5 @@
1
1
  import { hashStable } from "./component-lock.js";
2
- const families = ['databaseSchemas', 'databaseViews', 'components', 'jobTemplates', 'endpoints',
2
+ const families = ['databaseSchemas', 'databaseViews', 'components', 'applications', 'jobTemplates', 'endpoints',
3
3
  'schedules', 'events', 'groups', 'roleGroups', 'serviceAccounts', 'agentPlugins', 'agents'];
4
4
  // Compare authoring state and intended writes, independent of paths, timestamps,
5
5
  // presentation diffs and lock adoption bookkeeping in separate CI checkouts.
@@ -17,7 +17,7 @@ function reviewState(plan) {
17
17
  const value = item;
18
18
  return Object.fromEntries(['stableKey', 'identityKey', 'componentId', 'remoteComponentId', 'remoteVersion',
19
19
  'desiredHash', 'localHash', 'currentHash', 'remoteHash', 'operation', 'desiredActive', 'currentActive',
20
- 'targetRevisionHash', 'componentDesiredHash'].filter(key => value[key] !== undefined).map(key => [key, value[key]]));
20
+ 'targetRevisionHash', 'mappingHash', 'groupFences', 'principalFences', 'humanFences', 'componentDesiredHash', 'applicationDependency', 'anonymousExecutionDependency'].filter(key => value[key] !== undefined).map(key => [key, value[key]]));
21
21
  }).sort((left, right) => hashStable(left).localeCompare(hashStable(right))) })),
22
22
  };
23
23
  }
@@ -1,11 +1,12 @@
1
1
  const identityFields = {
2
+ application: 'serviceId',
2
3
  'database-table': 'databaseId', 'database-view': 'databaseViewId', component: 'componentId',
3
4
  endpoint: 'endpointId', 'job-template': 'jobTemplateId', schedule: 'scheduleId', event: 'eventId',
4
5
  group: 'groupId', 'role-group': 'roleGroupId', 'service-account': 'userId', agent: 'agentId', 'agent-plugin': 'agentPluginId',
5
6
  };
6
7
  const envelopeFields = ['data', 'items', 'results', 'resource', 'database', 'databaseSchema', 'databaseView', 'component', 'endpoint',
7
8
  'jobTemplate', 'schedule', 'event', 'jobEvent', 'group', 'roleGroup', 'account', 'agent', 'agentPlugin', 'databases', 'databaseSchemas', 'databaseViews',
8
- 'components', 'endpoints', 'jobTemplates', 'schedules', 'events', 'jobEvents', 'groups', 'roleGroups', 'accounts', 'serviceAccounts', 'agents', 'agentPlugins'];
9
+ 'components', 'applications', 'endpoints', 'jobTemplates', 'schedules', 'events', 'jobEvents', 'groups', 'roleGroups', 'accounts', 'serviceAccounts', 'agents', 'agentPlugins'];
9
10
  function isObject(value) {
10
11
  return value !== null && typeof value === 'object' && !Array.isArray(value);
11
12
  }
@@ -40,12 +41,14 @@ export function syncTargetVersionRecords(family, value, fallbackId) {
40
41
  return records;
41
42
  }
42
43
  const writeFamilies = {
44
+ updateApplication: 'application',
43
45
  updateJobTemplate: 'job-template', updateEndpoint: 'endpoint', updateSchedule: 'schedule', updateEvent: 'event',
44
46
  updateGroup: 'group', updateRoleGroup: 'role-group', updateServiceAccount: 'service-account',
45
47
  updateAgent: 'agent', updateAgentPlugin: 'agent-plugin', updateDatabaseSchema: 'database-table',
46
48
  updateDatabaseSchemaMetadata: 'database-table', acceptDatabaseSchema: 'database-table', updateDatabaseView: 'database-view',
47
49
  };
48
50
  const createFamilies = {
51
+ createApplication: 'application',
49
52
  createJobTemplate: 'job-template', createEndpoint: 'endpoint', createSchedule: 'schedule', createEvent: 'event',
50
53
  createGroup: 'group', createRoleGroup: 'role-group', createServiceAccount: 'service-account',
51
54
  createAgent: 'agent', createAgentPlugin: 'agent-plugin', createDatabaseSchema: 'database-table', createDatabaseView: 'database-view',
@@ -1,5 +1,5 @@
1
1
  import type { ParsedArgs } from './types.ts';
2
- export declare const SYNC_RESOURCE_FAMILIES: readonly ["database-table", "database-view", "component", "service-account", "agent-plugin", "agent", "job-template", "endpoint", "schedule", "event", "group", "role-group"];
2
+ export declare const SYNC_RESOURCE_FAMILIES: readonly ["database-table", "database-view", "component", "application", "service-account", "agent-plugin", "agent", "job-template", "endpoint", "schedule", "event", "group", "role-group"];
3
3
  export type SyncResourceFamily = (typeof SYNC_RESOURCE_FAMILIES)[number];
4
4
  export type SyncOmitRule = {
5
5
  resource?: SyncResourceFamily;
@@ -1,7 +1,7 @@
1
1
  import { AsyncLocalStorage } from 'node:async_hooks';
2
2
  import { createHash } from 'node:crypto';
3
3
  import { requestContracts } from "./request-contract.js";
4
- export const SYNC_RESOURCE_FAMILIES = ['database-table', 'database-view', 'component', 'service-account', 'agent-plugin', 'agent', 'job-template', 'endpoint', 'schedule', 'event', 'group', 'role-group'];
4
+ export const SYNC_RESOURCE_FAMILIES = ['database-table', 'database-view', 'component', 'application', 'service-account', 'agent-plugin', 'agent', 'job-template', 'endpoint', 'schedule', 'event', 'group', 'role-group'];
5
5
  const context = new AsyncLocalStorage();
6
6
  const MAX_DIGEST_NODES = 50_000;
7
7
  const MAX_DIGEST_DEPTH = 100;
@@ -64,6 +64,7 @@ function schemaAllows(schema, parts) {
64
64
  }
65
65
  const runtimeOptionRoots = { endpoint: 'EndpointOptionsDto', 'job-template': 'JobOptionsDto' };
66
66
  const ordinaryRoots = {
67
+ application: ['name', 'description', 'cors', 'invocationPolicy', 'anonymousAccess'],
67
68
  'database-table': ['name', 'category', 'description', 'audit'],
68
69
  'database-view': ['name', 'category', 'description'],
69
70
  component: ['name', 'category', 'desc', 'active', 'testConfig'],
@@ -71,7 +72,7 @@ const ordinaryRoots = {
71
72
  'agent-plugin': ['name'],
72
73
  agent: ['name'],
73
74
  'job-template': ['name', 'category', 'description', 'timeout', 'inputs', 'delivery'],
74
- endpoint: ['name', 'category', 'description', 'active', 'timeout'],
75
+ endpoint: ['name', 'category', 'description', 'active', 'timeout', 'allowUnauthenticated'],
75
76
  schedule: ['name', 'category', 'description', 'cron', 'timezone', 'input', 'inputMode'],
76
77
  event: ['name', 'category', 'description', 'filter', 'input', 'inputMode', 'extensions'],
77
78
  group: ['name', 'category', 'description'],
@@ -91,6 +92,10 @@ function familyPath(family, parts) {
91
92
  }
92
93
  function allowedPath(family, parts, stableKeyName = 'stableKey') {
93
94
  const [root, second, third] = parts;
95
+ if (family === 'application' && root === 'metadata')
96
+ return false;
97
+ if (family === 'application' && ['cors', 'invocationPolicy', 'anonymousAccess'].includes(root))
98
+ return parts.length === 1;
94
99
  if (root === 'metadata')
95
100
  return parts.length > 1 && second !== stableKeyName && second !== 'stableKey' && !second.startsWith('__')
96
101
  && !(second === 'details' && (parts.length === 2 || third === stableKeyName || third === 'stableKey'));
@@ -1,5 +1,5 @@
1
1
  export declare const TRACK_ALL_RESOURCES = "all";
2
- export declare const TRACKABLE_RESOURCE_TYPES: readonly ["component", "endpoint", "group", "role-group", "job-template", "schedule", "event", "database-table", "database-view", "service-account", "agent-plugin", "agent"];
2
+ export declare const TRACKABLE_RESOURCE_TYPES: readonly ["component", "application", "endpoint", "group", "role-group", "job-template", "schedule", "event", "database-table", "database-view", "service-account", "agent-plugin", "agent"];
3
3
  export type TrackableResourceType = typeof TRACKABLE_RESOURCE_TYPES[number];
4
4
  export type TrackedResource = typeof TRACK_ALL_RESOURCES | TrackableResourceType;
5
5
  export declare function normalizeTrackedResources(value: string | string[] | null | undefined): TrackedResource[];
@@ -1,6 +1,7 @@
1
1
  export const TRACK_ALL_RESOURCES = 'all';
2
- export const TRACKABLE_RESOURCE_TYPES = ['component', 'endpoint', 'group', 'role-group', 'job-template', 'schedule', 'event', 'database-table', 'database-view', 'service-account', 'agent-plugin', 'agent'];
2
+ export const TRACKABLE_RESOURCE_TYPES = ['component', 'application', 'endpoint', 'group', 'role-group', 'job-template', 'schedule', 'event', 'database-table', 'database-view', 'service-account', 'agent-plugin', 'agent'];
3
3
  const RESOURCE_ALIASES = {
4
+ application: 'application', applications: 'application', app: 'application', apps: 'application',
4
5
  'service-account': 'service-account',
5
6
  'service-accounts': 'service-account',
6
7
  serviceaccount: 'service-account',
@@ -49,7 +50,7 @@ export function normalizeTrackedResources(value) {
49
50
  }
50
51
  const resource = RESOURCE_ALIASES[key];
51
52
  if (!resource) {
52
- throw new Error(`Unsupported tracked resource "${part.trim()}". Supported values: all, component, endpoint, group, role-group, job-template, schedule, event, database-table, database-view, service-account, agent-plugin, agent.`);
53
+ throw new Error(`Unsupported tracked resource "${part.trim()}". Supported values: all, component, application, endpoint, group, role-group, job-template, schedule, event, database-table, database-view, service-account, agent-plugin, agent.`);
53
54
  }
54
55
  if (!normalized.includes(resource)) {
55
56
  normalized.push(resource);
@@ -153,7 +153,37 @@ export type EndpointOptions = {
153
153
  componentSchemaElement?: string | null;
154
154
  [key: string]: unknown;
155
155
  };
156
+ export type ApplicationCors = {
157
+ mode: 'public' | 'allowlist' | 'disabled';
158
+ allowedOrigins: string[];
159
+ };
160
+ export type ApplicationInvocationPolicy = {
161
+ mode: 'all' | 'allowlist' | 'denylist';
162
+ users: string[];
163
+ serviceAccounts: string[];
164
+ groups?: string[];
165
+ };
166
+ export type ApplicationAnonymousAccess = {
167
+ enabled: boolean;
168
+ requestsPerMinute: number;
169
+ maxConcurrent: number;
170
+ };
171
+ export type ApplicationRecord = {
172
+ category?: never;
173
+ serviceId: string;
174
+ key: string;
175
+ name: string;
176
+ description: string | null;
177
+ cors: ApplicationCors;
178
+ invocationPolicy?: ApplicationInvocationPolicy | null;
179
+ anonymousAccess?: ApplicationAnonymousAccess | null;
180
+ system: boolean;
181
+ version: number;
182
+ [key: string]: unknown;
183
+ };
156
184
  export type EndpointRecord = {
185
+ allowUnauthenticated?: boolean;
186
+ serviceId?: string;
157
187
  executionPolicy?: RuntimeExecutionPolicy | null;
158
188
  endpointId?: string;
159
189
  id?: string;
package/dist/src/ui.js CHANGED
@@ -159,6 +159,7 @@ function renderCommandCatalog() {
159
159
  paintHeader('Endpoints'),
160
160
  commandRow('revo emulate endpoints [--mode=local|published] [--read-only=true|false] [--project <name>] [--host <address>] [--port <port>] [--skip-validate] [--no-watch]', 'Preview local changes or call published endpoints'),
161
161
  commandRow('revo endpoints', 'List available API endpoints'),
162
+ commandRow('revo applications [pull|plan|push] --all [--project <name>] [--json] [--yes] [--force]', 'Synchronize Applications by immutable key; Default supports CORS only'),
162
163
  commandRow('revo endpoints pull --all [--project <name>] [--force]', 'Pull managed endpoints into the configured workspace'),
163
164
  commandRow('revo endpoints plan --all [--project <name>] [--json] [--strict]', 'Preview Endpoint state and Component compatibility'),
164
165
  commandRow('revo endpoints push --all [--project <name>] [--yes] [--force]', 'Deploy and verify managed endpoints'),
@@ -204,6 +205,7 @@ function renderCommandCatalog() {
204
205
  commandRow('revo migrate run --from <env> --to <env> [--resources <list>] [--skip-groups] --yes [--force] [--json]', 'Pull, plan, migrate, and verify resources in dependency order'),
205
206
  commandRow('revo migrate verify --from <env> --to <env> [--resources <list>] [--json]', 'Verify target resources against a fresh temporary source pull'),
206
207
  commandRow('revo studio <action> [sessionId] [--body-file file]', 'Stage, test, review, commit and activate shared Studio sessions'),
208
+ commandRow('revo sites list|show|link|create|update-files|configure|build|preview|publish|unpublish', 'Work with Sites in a local Studio instance'),
207
209
  commandRow('revo search <CODE|SIMPLE> <term>', 'Search code references or all platform content'),
208
210
  commandRow('revo request <METHOD> <PATH> [BODY]', 'Make a raw API request with optional JSON body'),
209
211
  ].join('\n');
@@ -1,6 +1,7 @@
1
1
  import { formatDiffValue } from "./diff-details.js";
2
2
  function resourceItems(plan, resource) {
3
3
  switch (resource) {
4
+ case 'application': return plan.applications?.items || [];
4
5
  case 'database-table': return plan.databaseSchemas?.items || [];
5
6
  case 'database-view': return plan.databaseViews?.items || [];
6
7
  case 'component': return plan.components?.items || [];
@@ -9,6 +9,7 @@ import { hashPortableAgent } from "./resource-syncs/agent-sync.js";
9
9
  import { hashPortableDatabaseSchema, readWorkspaceDatabaseSchemas } from "./resource-syncs/database-table-sync.js";
10
10
  import { hashPortableDatabaseView } from "./resource-syncs/database-view-sync.js";
11
11
  import { hashPortableEndpoint } from "./resource-syncs/endpoint-sync.js";
12
+ import { hashPortableApplication } from "./resource-syncs/application-sync.js";
12
13
  import { hashPortableEvent } from "./resource-syncs/event-sync.js";
13
14
  import { hashPortableGroup } from "./resource-syncs/group-sync.js";
14
15
  import { hashPortableJobTemplate } from "./resource-syncs/job-template-sync.js";
@@ -22,6 +23,7 @@ export function updateWorkspaceDigests(cwd) {
22
23
  const local = readPruneManifests(cwd, resources);
23
24
  const workspaceDigests = {};
24
25
  const hashers = { agent: hashPortableAgent, 'agent-plugin': hashPortableAgent,
26
+ application: hashPortableApplication,
25
27
  'database-table': hashPortableDatabaseSchema, 'database-view': hashPortableDatabaseView,
26
28
  endpoint: hashPortableEndpoint, event: hashPortableEvent, group: hashPortableGroup,
27
29
  'job-template': hashPortableJobTemplate, 'role-group': hashPortableRoleGroup,