sf-plugin-data 0.0.0-stage → 0.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.
- package/LICENSE +21 -0
- package/README.md +589 -2
- package/bin/run.js +4 -0
- package/docs/artifact-format.md +527 -0
- package/docs/capabilities.md +1208 -0
- package/docs/git-workflow.md +160 -0
- package/docs/handover.md +10446 -0
- package/lib/api.d.ts +7 -0
- package/lib/api.js +7 -0
- package/lib/artifacts/code-fields.d.ts +49 -0
- package/lib/artifacts/code-fields.js +142 -0
- package/lib/artifacts/data-graph-document.d.ts +29 -0
- package/lib/artifacts/data-graph-document.js +52 -0
- package/lib/artifacts/data-space-field.d.ts +65 -0
- package/lib/artifacts/data-space-field.js +98 -0
- package/lib/artifacts/data-stream-document.d.ts +264 -0
- package/lib/artifacts/data-stream-document.js +680 -0
- package/lib/artifacts/data-transform-document.d.ts +152 -0
- package/lib/artifacts/data-transform-document.js +560 -0
- package/lib/artifacts/dependency-selection.d.ts +51 -0
- package/lib/artifacts/dependency-selection.js +154 -0
- package/lib/artifacts/dlo-document.d.ts +93 -0
- package/lib/artifacts/dlo-document.js +253 -0
- package/lib/artifacts/enum-case.d.ts +39 -0
- package/lib/artifacts/enum-case.js +67 -0
- package/lib/artifacts/git-deploy-selection.d.ts +68 -0
- package/lib/artifacts/git-deploy-selection.js +474 -0
- package/lib/artifacts/identity-resolution-document.d.ts +133 -0
- package/lib/artifacts/identity-resolution-document.js +625 -0
- package/lib/artifacts/mapping-document.d.ts +1 -0
- package/lib/artifacts/mapping-document.js +1 -0
- package/lib/artifacts/native-calculated-insight-document.d.ts +142 -0
- package/lib/artifacts/native-calculated-insight-document.js +321 -0
- package/lib/artifacts/native-data-graph-document.d.ts +124 -0
- package/lib/artifacts/native-data-graph-document.js +780 -0
- package/lib/artifacts/native-dmo-document.d.ts +151 -0
- package/lib/artifacts/native-dmo-document.js +313 -0
- package/lib/artifacts/native-mapping-document.d.ts +67 -0
- package/lib/artifacts/native-mapping-document.js +187 -0
- package/lib/artifacts/native-relationship-document.d.ts +76 -0
- package/lib/artifacts/native-relationship-document.js +232 -0
- package/lib/artifacts/path-selector.d.ts +55 -0
- package/lib/artifacts/path-selector.js +167 -0
- package/lib/artifacts/read-deploy-input.d.ts +239 -0
- package/lib/artifacts/read-deploy-input.js +1359 -0
- package/lib/artifacts/segment-document.d.ts +183 -0
- package/lib/artifacts/segment-document.js +570 -0
- package/lib/artifacts/verbatim-document.d.ts +203 -0
- package/lib/artifacts/verbatim-document.js +339 -0
- package/lib/artifacts/write-data-graph.d.ts +17 -0
- package/lib/artifacts/write-data-graph.js +162 -0
- package/lib/artifacts/write-data-stream.d.ts +11 -0
- package/lib/artifacts/write-data-stream.js +175 -0
- package/lib/artifacts/write-data-transform.d.ts +11 -0
- package/lib/artifacts/write-data-transform.js +180 -0
- package/lib/artifacts/write-dlo.d.ts +11 -0
- package/lib/artifacts/write-dlo.js +158 -0
- package/lib/artifacts/write-identity-resolution.d.ts +18 -0
- package/lib/artifacts/write-identity-resolution.js +165 -0
- package/lib/artifacts/write-mapping-definition.d.ts +17 -0
- package/lib/artifacts/write-mapping-definition.js +127 -0
- package/lib/artifacts/write-member-export.d.ts +88 -0
- package/lib/artifacts/write-member-export.js +199 -0
- package/lib/artifacts/write-native-calculated-insight.d.ts +21 -0
- package/lib/artifacts/write-native-calculated-insight.js +176 -0
- package/lib/artifacts/write-native-dmo.d.ts +11 -0
- package/lib/artifacts/write-native-dmo.js +158 -0
- package/lib/artifacts/write-native-mapping.d.ts +11 -0
- package/lib/artifacts/write-native-mapping.js +157 -0
- package/lib/artifacts/write-native-relationship.d.ts +11 -0
- package/lib/artifacts/write-native-relationship.js +157 -0
- package/lib/artifacts/write-segment.d.ts +26 -0
- package/lib/artifacts/write-segment.js +212 -0
- package/lib/commands/data360/delete.d.ts +280 -0
- package/lib/commands/data360/delete.js +2297 -0
- package/lib/commands/data360/deploy.d.ts +303 -0
- package/lib/commands/data360/deploy.js +2400 -0
- package/lib/commands/data360/publish.d.ts +93 -0
- package/lib/commands/data360/publish.js +292 -0
- package/lib/commands/data360/retrieve.d.ts +322 -0
- package/lib/commands/data360/retrieve.js +1963 -0
- package/lib/commands/data360/segment/members/export.d.ts +101 -0
- package/lib/commands/data360/segment/members/export.js +318 -0
- package/lib/errors/codes/calculated-insight.d.ts +2 -0
- package/lib/errors/codes/calculated-insight.js +25 -0
- package/lib/errors/codes/data-graph.d.ts +2 -0
- package/lib/errors/codes/data-graph.js +22 -0
- package/lib/errors/codes/data-stream.d.ts +2 -0
- package/lib/errors/codes/data-stream.js +70 -0
- package/lib/errors/codes/data-transform.d.ts +2 -0
- package/lib/errors/codes/data-transform.js +35 -0
- package/lib/errors/codes/dependency.d.ts +2 -0
- package/lib/errors/codes/dependency.js +11 -0
- package/lib/errors/codes/dlo.d.ts +2 -0
- package/lib/errors/codes/dlo.js +31 -0
- package/lib/errors/codes/dmo.d.ts +2 -0
- package/lib/errors/codes/dmo.js +28 -0
- package/lib/errors/codes/general.d.ts +2 -0
- package/lib/errors/codes/general.js +57 -0
- package/lib/errors/codes/identity-resolution.d.ts +2 -0
- package/lib/errors/codes/identity-resolution.js +24 -0
- package/lib/errors/codes/mapping.d.ts +2 -0
- package/lib/errors/codes/mapping.js +42 -0
- package/lib/errors/codes/relationship.d.ts +2 -0
- package/lib/errors/codes/relationship.js +21 -0
- package/lib/errors/codes/segment.d.ts +2 -0
- package/lib/errors/codes/segment.js +49 -0
- package/lib/errors/registry.d.ts +60 -0
- package/lib/errors/registry.js +123 -0
- package/lib/plugin.d.ts +5 -0
- package/lib/plugin.js +5 -0
- package/lib/services/acquire-retrieve-selection.d.ts +43 -0
- package/lib/services/acquire-retrieve-selection.js +145 -0
- package/lib/services/bind-identity-resolution-dependencies.d.ts +53 -0
- package/lib/services/bind-identity-resolution-dependencies.js +238 -0
- package/lib/services/bind-segment-dependencies.d.ts +49 -0
- package/lib/services/bind-segment-dependencies.js +115 -0
- package/lib/services/bounded-reads.d.ts +17 -0
- package/lib/services/bounded-reads.js +42 -0
- package/lib/services/calculated-insight-sql-checks.d.ts +33 -0
- package/lib/services/calculated-insight-sql-checks.js +193 -0
- package/lib/services/command-dlo.d.ts +48 -0
- package/lib/services/command-dlo.js +103 -0
- package/lib/services/command-native-data-graph.d.ts +54 -0
- package/lib/services/command-native-data-graph.js +485 -0
- package/lib/services/command-native-data-stream.d.ts +104 -0
- package/lib/services/command-native-data-stream.js +257 -0
- package/lib/services/command-native-dmo.d.ts +124 -0
- package/lib/services/command-native-dmo.js +338 -0
- package/lib/services/command-native-mapping.d.ts +65 -0
- package/lib/services/command-native-mapping.js +129 -0
- package/lib/services/command-native-relationship.d.ts +46 -0
- package/lib/services/command-native-relationship.js +103 -0
- package/lib/services/cross-dataspace-deploy.d.ts +111 -0
- package/lib/services/cross-dataspace-deploy.js +493 -0
- package/lib/services/cross-dataspace-rename.d.ts +74 -0
- package/lib/services/cross-dataspace-rename.js +1314 -0
- package/lib/services/cross-dataspace-sql.d.ts +109 -0
- package/lib/services/cross-dataspace-sql.js +1301 -0
- package/lib/services/cross-space-context.d.ts +23 -0
- package/lib/services/cross-space-context.js +36 -0
- package/lib/services/crud-plan.d.ts +137 -0
- package/lib/services/crud-plan.js +408 -0
- package/lib/services/data-space-check.d.ts +89 -0
- package/lib/services/data-space-check.js +162 -0
- package/lib/services/data-space-prefix.d.ts +77 -0
- package/lib/services/data-space-prefix.js +127 -0
- package/lib/services/data-transform-space.d.ts +31 -0
- package/lib/services/data-transform-space.js +79 -0
- package/lib/services/delete-calculated-insight.d.ts +44 -0
- package/lib/services/delete-calculated-insight.js +101 -0
- package/lib/services/delete-data-transform.d.ts +52 -0
- package/lib/services/delete-data-transform.js +222 -0
- package/lib/services/delete-dmo-field.d.ts +211 -0
- package/lib/services/delete-dmo-field.js +472 -0
- package/lib/services/delete-identity-resolution.d.ts +43 -0
- package/lib/services/delete-identity-resolution.js +295 -0
- package/lib/services/delete-segment.d.ts +42 -0
- package/lib/services/delete-segment.js +248 -0
- package/lib/services/deploy-result.d.ts +54 -0
- package/lib/services/deploy-result.js +60 -0
- package/lib/services/escaped-copy.d.ts +23 -0
- package/lib/services/escaped-copy.js +88 -0
- package/lib/services/execute-calculated-insight-deploy.d.ts +42 -0
- package/lib/services/execute-calculated-insight-deploy.js +96 -0
- package/lib/services/execute-data-transform-deploy.d.ts +56 -0
- package/lib/services/execute-data-transform-deploy.js +168 -0
- package/lib/services/execute-native-identity-resolution-deploy.d.ts +48 -0
- package/lib/services/execute-native-identity-resolution-deploy.js +360 -0
- package/lib/services/execute-segment-deploy.d.ts +45 -0
- package/lib/services/execute-segment-deploy.js +393 -0
- package/lib/services/local-file-removal.d.ts +36 -0
- package/lib/services/local-file-removal.js +103 -0
- package/lib/services/native-calculated-insight.d.ts +87 -0
- package/lib/services/native-calculated-insight.js +164 -0
- package/lib/services/native-crm-data-stream.d.ts +91 -0
- package/lib/services/native-crm-data-stream.js +272 -0
- package/lib/services/native-data-graph-context.d.ts +12 -0
- package/lib/services/native-data-graph-context.js +139 -0
- package/lib/services/native-data-graph-crd.d.ts +261 -0
- package/lib/services/native-data-graph-crd.js +866 -0
- package/lib/services/native-data-stream.d.ts +329 -0
- package/lib/services/native-data-stream.js +1830 -0
- package/lib/services/native-dlo.d.ts +163 -0
- package/lib/services/native-dlo.js +402 -0
- package/lib/services/native-dmo.d.ts +191 -0
- package/lib/services/native-dmo.js +614 -0
- package/lib/services/native-mapping.d.ts +255 -0
- package/lib/services/native-mapping.js +1226 -0
- package/lib/services/native-relationship.d.ts +132 -0
- package/lib/services/native-relationship.js +512 -0
- package/lib/services/operation-diagnostic.d.ts +83 -0
- package/lib/services/operation-diagnostic.js +272 -0
- package/lib/services/preflight-calculated-insight-deploy.d.ts +58 -0
- package/lib/services/preflight-calculated-insight-deploy.js +95 -0
- package/lib/services/preflight-data-transform-deploy.d.ts +33 -0
- package/lib/services/preflight-data-transform-deploy.js +104 -0
- package/lib/services/preflight-identity-resolution-deploy.d.ts +107 -0
- package/lib/services/preflight-identity-resolution-deploy.js +281 -0
- package/lib/services/preflight-segment-deploy.d.ts +31 -0
- package/lib/services/preflight-segment-deploy.js +109 -0
- package/lib/services/publish-calculated-insight.d.ts +40 -0
- package/lib/services/publish-calculated-insight.js +95 -0
- package/lib/services/publish-segment.d.ts +65 -0
- package/lib/services/publish-segment.js +194 -0
- package/lib/services/readback-pace.d.ts +16 -0
- package/lib/services/readback-pace.js +23 -0
- package/lib/services/retrieve-data-transform.d.ts +26 -0
- package/lib/services/retrieve-data-transform.js +65 -0
- package/lib/services/retrieve-identity-resolution.d.ts +40 -0
- package/lib/services/retrieve-identity-resolution.js +87 -0
- package/lib/services/retrieve-inventory.d.ts +32 -0
- package/lib/services/retrieve-inventory.js +151 -0
- package/lib/services/retrieve-segment.d.ts +120 -0
- package/lib/services/retrieve-segment.js +502 -0
- package/lib/services/segment-lookup.d.ts +46 -0
- package/lib/services/segment-lookup.js +108 -0
- package/lib/services/segment-members.d.ts +144 -0
- package/lib/services/segment-members.js +402 -0
- package/lib/services/select-native-retrieve.d.ts +60 -0
- package/lib/services/select-native-retrieve.js +226 -0
- package/lib/services/settle-calculated-insight.d.ts +22 -0
- package/lib/services/settle-calculated-insight.js +53 -0
- package/lib/services/sql-tokens.d.ts +58 -0
- package/lib/services/sql-tokens.js +147 -0
- package/lib/transport/api-version.d.ts +36 -0
- package/lib/transport/api-version.js +89 -0
- package/lib/transport/bound-ssot.d.ts +27 -0
- package/lib/transport/bound-ssot.js +116 -0
- package/lib/transport/calculated-insight-rest.d.ts +28 -0
- package/lib/transport/calculated-insight-rest.js +62 -0
- package/lib/transport/connect-client.d.ts +129 -0
- package/lib/transport/connect-client.js +446 -0
- package/lib/transport/connect-diagnostic.d.ts +89 -0
- package/lib/transport/connect-diagnostic.js +331 -0
- package/lib/transport/data-graph-rest.d.ts +27 -0
- package/lib/transport/data-graph-rest.js +76 -0
- package/lib/transport/data-stream-rest.d.ts +62 -0
- package/lib/transport/data-stream-rest.js +348 -0
- package/lib/transport/data-transform-rest.d.ts +25 -0
- package/lib/transport/data-transform-rest.js +100 -0
- package/lib/transport/dlo-native-rest.d.ts +22 -0
- package/lib/transport/dlo-native-rest.js +89 -0
- package/lib/transport/dlo-rest.d.ts +23 -0
- package/lib/transport/dlo-rest.js +135 -0
- package/lib/transport/dmo-native-rest.d.ts +18 -0
- package/lib/transport/dmo-native-rest.js +55 -0
- package/lib/transport/dmo-rest.d.ts +30 -0
- package/lib/transport/dmo-rest.js +163 -0
- package/lib/transport/mapping-rest.d.ts +63 -0
- package/lib/transport/mapping-rest.js +341 -0
- package/lib/transport/project-metadata.d.ts +36 -0
- package/lib/transport/project-metadata.js +118 -0
- package/lib/transport/relationship-rest.d.ts +43 -0
- package/lib/transport/relationship-rest.js +201 -0
- package/package.json +96 -4
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { DloDeployInput, DeployInput, DeletedArtifactKind } from './read-deploy-input.js';
|
|
2
|
+
import type { IdentityResolutionDeployInput, SegmentDeployInput } from './read-deploy-input.js';
|
|
3
|
+
import type { CalculatedInsightDeployInput } from './read-deploy-input.js';
|
|
4
|
+
import type { VerbatimDocument } from './verbatim-document.js';
|
|
5
|
+
/** Payload-free refusal of unsafe or unsupported Git selections. */
|
|
6
|
+
export declare class GitSelectionError extends Error {
|
|
7
|
+
readonly code: 'INVALID_GIT_SELECTION' | 'BLOCKED_GIT_LIFECYCLE';
|
|
8
|
+
constructor(code: 'INVALID_GIT_SELECTION' | 'BLOCKED_GIT_LIFECYCLE');
|
|
9
|
+
}
|
|
10
|
+
/** A file present at the merge base and absent now: a delete in the org, identified from base content. */
|
|
11
|
+
export type GitDeleteCandidate = Readonly<{
|
|
12
|
+
family: DeletedArtifactKind;
|
|
13
|
+
/** Absolute path the file had (the JSON file for a calculated insight). */
|
|
14
|
+
path: string;
|
|
15
|
+
/** A DLO has no single data space: its spaces are the base document's c__dataSpace list. */
|
|
16
|
+
identity: Readonly<{
|
|
17
|
+
dataSpace?: string;
|
|
18
|
+
apiName: string;
|
|
19
|
+
}>;
|
|
20
|
+
/** Calculated insight only: absolute path of the SQL file. */
|
|
21
|
+
companionPath?: string;
|
|
22
|
+
/** Segment only: absolute paths of the SQL file of each base model. */
|
|
23
|
+
codePaths?: readonly string[];
|
|
24
|
+
/**
|
|
25
|
+
* The validated base document (deeply frozen); the delete runs from it, not from a file. A
|
|
26
|
+
* verbatim document (retrieved as-is) is deleted by family and name only.
|
|
27
|
+
*/
|
|
28
|
+
document: DeployInput['document'] | VerbatimDocument;
|
|
29
|
+
/** Relationship source DMO, from the base content. */
|
|
30
|
+
sourceObjectName?: string;
|
|
31
|
+
/** SHA-256 of the base bytes. */
|
|
32
|
+
baseDigest: string;
|
|
33
|
+
}>;
|
|
34
|
+
export type GitDeploySelection = {
|
|
35
|
+
paths: string[];
|
|
36
|
+
/** Every input admitted from the current files, byte-bound for later re-admission. */
|
|
37
|
+
capturedInputs?: readonly DeployInput[];
|
|
38
|
+
dlos?: readonly DloDeployInput[];
|
|
39
|
+
segments?: readonly SegmentDeployInput[];
|
|
40
|
+
calculatedInsights?: readonly CalculatedInsightDeployInput[];
|
|
41
|
+
identityResolutions?: readonly IdentityResolutionDeployInput[];
|
|
42
|
+
/** Files deleted in the range. Carried for the caller; selection never deletes. */
|
|
43
|
+
deletions?: readonly GitDeleteCandidate[];
|
|
44
|
+
/** Changed verbatim files (retrieved as-is) that were left out, one warning each. */
|
|
45
|
+
warnings?: readonly string[];
|
|
46
|
+
provenance: {
|
|
47
|
+
repositoryRoot: string;
|
|
48
|
+
requestedRef: string;
|
|
49
|
+
referenceCommit: string;
|
|
50
|
+
headCommit: string;
|
|
51
|
+
mergeBase: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Resolve merge-base/HEAD plus index, working-tree and untracked changes locally.
|
|
56
|
+
* Changed files of every family are admitted by the existing authored-input parser.
|
|
57
|
+
* Files deleted in the range become delete candidates read from the merge base; they are
|
|
58
|
+
* carried, never executed here. Git-inferred renames block; they are not a guarantee of
|
|
59
|
+
* historical rename intent.
|
|
60
|
+
* @param {object} options Requested reference and absolute invocation directory.
|
|
61
|
+
* @param {string} options.cwd Invocation directory, including nested repository directories.
|
|
62
|
+
* @param {string} options.ref Requested Git revision resolving to a commit.
|
|
63
|
+
* @returns {Promise<GitDeploySelection>} Validated absolute paths and resolved commit provenance.
|
|
64
|
+
*/
|
|
65
|
+
export declare function selectGitDeployInputs(options: {
|
|
66
|
+
cwd: string;
|
|
67
|
+
ref: string;
|
|
68
|
+
}): Promise<GitDeploySelection>;
|
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { lstat, readFile } from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { promisify } from 'node:util';
|
|
6
|
+
import { admitDeletedArtifact, readDeployInputs, skippedVerbatimWarnings, } from './read-deploy-input.js';
|
|
7
|
+
import { codeFilePath } from './code-fields.js';
|
|
8
|
+
import { ciJsonSuffix, ciSql, ciSqlSuffix, classifyComponentPath, families, segmentSql, segmentSqlPattern, } from './path-selector.js';
|
|
9
|
+
import { parseVerbatimDocument } from './verbatim-document.js';
|
|
10
|
+
const execute = promisify(execFile);
|
|
11
|
+
/** Payload-free refusal of unsafe or unsupported Git selections. */
|
|
12
|
+
export class GitSelectionError extends Error {
|
|
13
|
+
code;
|
|
14
|
+
constructor(code) {
|
|
15
|
+
super('Select a valid Git reference and current canonical files; renames, unknown deleted files and ambiguous deletions block deployment.');
|
|
16
|
+
this.code = code;
|
|
17
|
+
this.name = 'GitSelectionError';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Execute bounded local Git reads with argument arrays, never through a shell.
|
|
22
|
+
* @param {string} cwd Absolute working directory.
|
|
23
|
+
* @param {string[]} arguments_ Git arguments, with user references separated from options.
|
|
24
|
+
* @returns {Promise<Buffer>} Exact output bytes.
|
|
25
|
+
*/
|
|
26
|
+
async function gitBytes(cwd, arguments_) {
|
|
27
|
+
const { stdout } = await execute('git', ['--literal-pathspecs', ...arguments_], {
|
|
28
|
+
cwd,
|
|
29
|
+
encoding: 'buffer',
|
|
30
|
+
maxBuffer: 4_194_304,
|
|
31
|
+
timeout: 30_000,
|
|
32
|
+
windowsHide: true,
|
|
33
|
+
env: { ...process.env, GIT_OPTIONAL_LOCKS: '0' },
|
|
34
|
+
});
|
|
35
|
+
return stdout;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Execute a Git read and decode strict UTF-8.
|
|
39
|
+
* @param {string} cwd Absolute working directory.
|
|
40
|
+
* @param {string[]} arguments_ Git arguments.
|
|
41
|
+
* @returns {Promise<string>} Strict UTF-8 output.
|
|
42
|
+
*/
|
|
43
|
+
async function git(cwd, arguments_) {
|
|
44
|
+
return new TextDecoder('utf-8', { fatal: true }).decode(await gitBytes(cwd, arguments_));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Split a complete NUL-delimited response without losing embedded whitespace.
|
|
48
|
+
* @param {string} output Git output.
|
|
49
|
+
* @returns {string[]} Complete nonempty tokens.
|
|
50
|
+
*/
|
|
51
|
+
function tokens(output) {
|
|
52
|
+
if (!output)
|
|
53
|
+
return [];
|
|
54
|
+
if (!output.endsWith('\0'))
|
|
55
|
+
throw new GitSelectionError('INVALID_GIT_SELECTION');
|
|
56
|
+
const values = output.slice(0, -1).split('\0');
|
|
57
|
+
if (values.some((value) => !value))
|
|
58
|
+
throw new GitSelectionError('INVALID_GIT_SELECTION');
|
|
59
|
+
return values;
|
|
60
|
+
}
|
|
61
|
+
const segmentXml = (file) => /\.marketSegmentDefinition-meta\.xml$/iu.test(file);
|
|
62
|
+
const relevant = (file) => segmentXml(file) ||
|
|
63
|
+
ciSql(file) ||
|
|
64
|
+
segmentSql(file) ||
|
|
65
|
+
families.some(({ suffix }) => file.toLowerCase().endsWith(suffix.toLowerCase()));
|
|
66
|
+
// A deleted path in a plugin folder must resolve to a known family.
|
|
67
|
+
const watched = (file) => relevant(file) || file.split('/').includes('data360');
|
|
68
|
+
/**
|
|
69
|
+
* Map one repository-relative path to its family and canonical name, or refuse it.
|
|
70
|
+
* @param {string} file Repository-relative POSIX path.
|
|
71
|
+
* @returns {object} Family and canonical name (`__cio` included for calculated insights).
|
|
72
|
+
*/
|
|
73
|
+
function classify(file) {
|
|
74
|
+
const component = classifyComponentPath(file);
|
|
75
|
+
if (!component)
|
|
76
|
+
throw new GitSelectionError('INVALID_GIT_SELECTION');
|
|
77
|
+
return component;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Collect changed paths and deleted watched paths; renames, copies and conflicts block.
|
|
81
|
+
* @param {string} output NUL-delimited name-status diff, including both rename paths.
|
|
82
|
+
* @param {Set<string>} paths Deduplicated changed relevant paths.
|
|
83
|
+
* @param {Set<string>} deleted Deduplicated deleted watched paths.
|
|
84
|
+
* @param {boolean} [unstaged] Working-tree diff: an unstaged deletion of a watched file blocks,
|
|
85
|
+
* because Git cannot see where an unstaged file moved.
|
|
86
|
+
* @returns {boolean} Whether an actual deletion status occurred, including unrelated paths.
|
|
87
|
+
*/
|
|
88
|
+
function collect(output, paths, deleted, unstaged = false) {
|
|
89
|
+
const values = tokens(output);
|
|
90
|
+
let hasDeletion = false;
|
|
91
|
+
for (let index = 0; index < values.length;) {
|
|
92
|
+
const status = values[index++];
|
|
93
|
+
if (!/^(?:[AMDTU]|[RC]\d{1,3})$/u.test(status))
|
|
94
|
+
throw new GitSelectionError('INVALID_GIT_SELECTION');
|
|
95
|
+
const first = values[index++];
|
|
96
|
+
const second = /^[RC]/u.test(status) ? values[index++] : undefined;
|
|
97
|
+
if (!first || (/^[RC]/u.test(status) && !second))
|
|
98
|
+
throw new GitSelectionError('INVALID_GIT_SELECTION');
|
|
99
|
+
if (status === 'D') {
|
|
100
|
+
hasDeletion = true;
|
|
101
|
+
if (watched(first) && unstaged)
|
|
102
|
+
throw new GitSelectionError('BLOCKED_GIT_LIFECYCLE');
|
|
103
|
+
if (watched(first))
|
|
104
|
+
deleted.add(first);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (!relevant(first) && !(second && relevant(second)))
|
|
108
|
+
continue;
|
|
109
|
+
if (/^[RCU]/u.test(status))
|
|
110
|
+
throw new GitSelectionError('BLOCKED_GIT_LIFECYCLE');
|
|
111
|
+
paths.add(first);
|
|
112
|
+
}
|
|
113
|
+
return hasDeletion;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Whether anything exists at a path now (a re-added file is not a deletion).
|
|
117
|
+
* @param {string} file Absolute path.
|
|
118
|
+
* @returns {Promise<boolean>} Presence of any entry, link or not.
|
|
119
|
+
*/
|
|
120
|
+
async function present(file) {
|
|
121
|
+
try {
|
|
122
|
+
await lstat(file);
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (error.code === 'ENOENT')
|
|
127
|
+
return false;
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Whether a worktree file is a verbatim document (retrieved as-is).
|
|
133
|
+
* @param {string} file Absolute path.
|
|
134
|
+
* @returns {Promise<boolean>} A regular file holding a verbatim document.
|
|
135
|
+
*/
|
|
136
|
+
async function verbatimFile(file) {
|
|
137
|
+
try {
|
|
138
|
+
const stat = await lstat(file);
|
|
139
|
+
return (stat.isFile() &&
|
|
140
|
+
stat.size <= 1_048_576 &&
|
|
141
|
+
parseVerbatimDocument(await readFile(file, 'utf8')) !== undefined);
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Read one regular file of a commit, or undefined when the commit has no entry at that path.
|
|
149
|
+
* @param {string} repositoryRoot Absolute repository root.
|
|
150
|
+
* @param {string} commit Resolved commit.
|
|
151
|
+
* @param {string} file Repository-relative POSIX path.
|
|
152
|
+
* @returns {Promise<Buffer | undefined>} Exact bytes, at most 1 MiB.
|
|
153
|
+
*/
|
|
154
|
+
async function revisionBytes(repositoryRoot, commit, file) {
|
|
155
|
+
const listing = tokens(await git(repositoryRoot, ['ls-tree', '-z', '-l', '--full-tree', commit, '--', file]));
|
|
156
|
+
if (listing.length === 0)
|
|
157
|
+
return undefined;
|
|
158
|
+
const match = /^100(?:644|755) blob ([a-f0-9]{40}|[a-f0-9]{64}) +(\d+)\t([\s\S]+)$/u.exec(listing[0]);
|
|
159
|
+
if (listing.length !== 1 || !match || match[3] !== file || Number(match[2]) > 1_048_576)
|
|
160
|
+
throw new GitSelectionError('BLOCKED_GIT_LIFECYCLE');
|
|
161
|
+
const bytes = await gitBytes(repositoryRoot, ['cat-file', 'blob', match[1]]);
|
|
162
|
+
if (bytes.length !== Number(match[2]))
|
|
163
|
+
throw new GitSelectionError('INVALID_GIT_SELECTION');
|
|
164
|
+
return bytes;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Family and API name of a document, case-insensitive; graphs and transforms carry their name in
|
|
168
|
+
* the definition.
|
|
169
|
+
* @param {DeployInput['document']} document Validated document.
|
|
170
|
+
* @returns {string} Key such as `dmo:person__dlm`.
|
|
171
|
+
*/
|
|
172
|
+
function identityKey(document) {
|
|
173
|
+
const value = document;
|
|
174
|
+
return `${document.kind}:${String(value.identity?.apiName ?? value.definition?.name)}`.toLowerCase();
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* A deleted segment: its JSON and the SQL file of every base model, all gone from the worktree,
|
|
178
|
+
* read from the merge base and joined.
|
|
179
|
+
* @param {object} context Repository and merge base.
|
|
180
|
+
* @param {string} context.repositoryRoot Absolute repository root.
|
|
181
|
+
* @param {string} context.mergeBase Resolved merge base.
|
|
182
|
+
* @param {string} file Deleted repository-relative path (the JSON or a SQL file).
|
|
183
|
+
* @param {string} name Segment name.
|
|
184
|
+
* @returns {Promise<GitDeleteCandidate | undefined>} Candidate, or undefined when the segment did not exist at the merge base.
|
|
185
|
+
*/
|
|
186
|
+
async function segmentDeleteCandidate(context, file, name) {
|
|
187
|
+
const { repositoryRoot, mergeBase } = context;
|
|
188
|
+
const relative = (value) => path.relative(repositoryRoot, value).split(path.sep).join('/');
|
|
189
|
+
const absolute = (value) => path.join(repositoryRoot, ...value.split('/'));
|
|
190
|
+
const jsonPath = path.join(repositoryRoot, 'data360', 'segments', `${name}.segment.json`);
|
|
191
|
+
const json = await revisionBytes(repositoryRoot, mergeBase, relative(jsonPath));
|
|
192
|
+
if (json === undefined) {
|
|
193
|
+
// Added after the merge base and removed again: nothing changed in the range.
|
|
194
|
+
if ((await revisionBytes(repositoryRoot, mergeBase, file)) === undefined)
|
|
195
|
+
return undefined;
|
|
196
|
+
throw new GitSelectionError('BLOCKED_GIT_LIFECYCLE');
|
|
197
|
+
}
|
|
198
|
+
let models;
|
|
199
|
+
try {
|
|
200
|
+
const parsed = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(json));
|
|
201
|
+
models = (parsed.spec?.models ?? []).map((model) => {
|
|
202
|
+
if (typeof model?.name !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9_]*$/u.test(model.name))
|
|
203
|
+
throw new Error('Model name');
|
|
204
|
+
return model.name;
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
throw new GitSelectionError('INVALID_GIT_SELECTION');
|
|
209
|
+
}
|
|
210
|
+
const codePaths = models.map((model) => codeFilePath(jsonPath, { extension: 'sql', name: model }));
|
|
211
|
+
// The JSON and every SQL file go together; one left behind is not a complete deletion.
|
|
212
|
+
for (const member of [jsonPath, ...codePaths])
|
|
213
|
+
if (await present(member))
|
|
214
|
+
throw new GitSelectionError('BLOCKED_GIT_LIFECYCLE');
|
|
215
|
+
const code = await Promise.all(codePaths.map(async (member) => revisionBytes(repositoryRoot, mergeBase, relative(member))));
|
|
216
|
+
if (code.includes(undefined))
|
|
217
|
+
throw new GitSelectionError('BLOCKED_GIT_LIFECYCLE');
|
|
218
|
+
let admitted;
|
|
219
|
+
try {
|
|
220
|
+
admitted = admitDeletedArtifact('segment', name, json, models.map((model, index) => ({ name: model, bytes: code[index] })));
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
throw new GitSelectionError('INVALID_GIT_SELECTION');
|
|
224
|
+
}
|
|
225
|
+
const hash = createHash('sha256');
|
|
226
|
+
for (const content of [json, ...code])
|
|
227
|
+
hash.update(String(content.length)).update(':').update(content);
|
|
228
|
+
return Object.freeze({
|
|
229
|
+
family: 'segment',
|
|
230
|
+
path: absolute(relative(jsonPath)),
|
|
231
|
+
codePaths: Object.freeze(codePaths.map((member) => absolute(relative(member)))),
|
|
232
|
+
identity: Object.freeze(admitted.identity),
|
|
233
|
+
document: admitted.document,
|
|
234
|
+
baseDigest: hash.digest('hex'),
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Turn deleted paths into delete candidates identified from merge-base content.
|
|
239
|
+
* @param {object} context Repository and merge base.
|
|
240
|
+
* @param {string} context.repositoryRoot Absolute repository root.
|
|
241
|
+
* @param {string} context.mergeBase Resolved merge base.
|
|
242
|
+
* @param {string[]} removed Deleted watched paths absent from the worktree.
|
|
243
|
+
* @returns {Promise<GitDeleteCandidate[]>} Candidates sorted by path.
|
|
244
|
+
*/
|
|
245
|
+
async function deleteCandidates(context, removed) {
|
|
246
|
+
const { repositoryRoot, mergeBase } = context;
|
|
247
|
+
const absolute = (file) => path.join(repositoryRoot, ...file.split('/'));
|
|
248
|
+
const candidates = new Map();
|
|
249
|
+
// eslint-disable-next-line unicorn/no-array-sort -- Sort a fresh array within the existing TypeScript library target.
|
|
250
|
+
for (const file of [...removed].sort()) {
|
|
251
|
+
let kind;
|
|
252
|
+
let name;
|
|
253
|
+
try {
|
|
254
|
+
({ kind, name } = classify(file));
|
|
255
|
+
}
|
|
256
|
+
catch {
|
|
257
|
+
// A deleted file of no known family cannot be turned into an org delete.
|
|
258
|
+
throw new GitSelectionError('BLOCKED_GIT_LIFECYCLE');
|
|
259
|
+
}
|
|
260
|
+
const key = `${kind}:${name}`;
|
|
261
|
+
if (candidates.has(key))
|
|
262
|
+
continue;
|
|
263
|
+
if (kind === 'segment') {
|
|
264
|
+
const candidate = await segmentDeleteCandidate(context, file, name);
|
|
265
|
+
if (candidate)
|
|
266
|
+
candidates.set(key, candidate);
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
let members = [file];
|
|
270
|
+
if (kind === 'calculated-insight') {
|
|
271
|
+
const relative = (value) => path.relative(repositoryRoot, value).split(path.sep).join('/');
|
|
272
|
+
const directory = path.join(repositoryRoot, 'data360', 'calculatedInsights');
|
|
273
|
+
members = [
|
|
274
|
+
relative(path.join(directory, `${name}${ciJsonSuffix}`)),
|
|
275
|
+
relative(path.join(directory, `${name}${ciSqlSuffix}`)),
|
|
276
|
+
];
|
|
277
|
+
// A verbatim insight (retrieved as-is) is its JSON alone: no SQL file is needed or deleted.
|
|
278
|
+
const json = await revisionBytes(repositoryRoot, mergeBase, members[0]);
|
|
279
|
+
if (json !== undefined && parseVerbatimDocument(json.toString('utf8')) !== undefined)
|
|
280
|
+
members = [members[0]];
|
|
281
|
+
// The JSON and the SQL file go together; one left behind is not a complete deletion.
|
|
282
|
+
for (const member of members)
|
|
283
|
+
if (await present(absolute(member)))
|
|
284
|
+
throw new GitSelectionError('BLOCKED_GIT_LIFECYCLE');
|
|
285
|
+
}
|
|
286
|
+
const bytes = await Promise.all(members.map(async (member) => revisionBytes(repositoryRoot, mergeBase, member)));
|
|
287
|
+
// Added after the merge base and removed again: nothing changed in the range.
|
|
288
|
+
if (bytes.every((value) => value === undefined))
|
|
289
|
+
continue;
|
|
290
|
+
if (bytes.includes(undefined))
|
|
291
|
+
throw new GitSelectionError('BLOCKED_GIT_LIFECYCLE');
|
|
292
|
+
const [first, second] = bytes;
|
|
293
|
+
let admitted;
|
|
294
|
+
try {
|
|
295
|
+
admitted =
|
|
296
|
+
second === undefined
|
|
297
|
+
? admitDeletedArtifact(kind, name, first)
|
|
298
|
+
: admitDeletedArtifact(kind, name, first, [{ bytes: second }]);
|
|
299
|
+
}
|
|
300
|
+
catch {
|
|
301
|
+
throw new GitSelectionError('INVALID_GIT_SELECTION');
|
|
302
|
+
}
|
|
303
|
+
const hash = createHash('sha256');
|
|
304
|
+
if (second === undefined) {
|
|
305
|
+
hash.update(first);
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
hash
|
|
309
|
+
.update(String(first.length))
|
|
310
|
+
.update(':')
|
|
311
|
+
.update(first)
|
|
312
|
+
.update(String(second.length))
|
|
313
|
+
.update(':')
|
|
314
|
+
.update(second);
|
|
315
|
+
}
|
|
316
|
+
candidates.set(key, Object.freeze({
|
|
317
|
+
family: kind,
|
|
318
|
+
path: absolute(members[0]),
|
|
319
|
+
...(members[1] === undefined ? {} : { companionPath: absolute(members[1]) }),
|
|
320
|
+
identity: Object.freeze(admitted.identity),
|
|
321
|
+
document: admitted.document,
|
|
322
|
+
...(admitted.sourceObjectName === undefined
|
|
323
|
+
? {}
|
|
324
|
+
: { sourceObjectName: admitted.sourceObjectName }),
|
|
325
|
+
baseDigest: hash.digest('hex'),
|
|
326
|
+
}));
|
|
327
|
+
}
|
|
328
|
+
return [...candidates.values()];
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Resolve merge-base/HEAD plus index, working-tree and untracked changes locally.
|
|
332
|
+
* Changed files of every family are admitted by the existing authored-input parser.
|
|
333
|
+
* Files deleted in the range become delete candidates read from the merge base; they are
|
|
334
|
+
* carried, never executed here. Git-inferred renames block; they are not a guarantee of
|
|
335
|
+
* historical rename intent.
|
|
336
|
+
* @param {object} options Requested reference and absolute invocation directory.
|
|
337
|
+
* @param {string} options.cwd Invocation directory, including nested repository directories.
|
|
338
|
+
* @param {string} options.ref Requested Git revision resolving to a commit.
|
|
339
|
+
* @returns {Promise<GitDeploySelection>} Validated absolute paths and resolved commit provenance.
|
|
340
|
+
*/
|
|
341
|
+
export async function selectGitDeployInputs(options) {
|
|
342
|
+
try {
|
|
343
|
+
if (!path.isAbsolute(options.cwd) ||
|
|
344
|
+
!options.ref ||
|
|
345
|
+
options.ref !== options.ref.trim() ||
|
|
346
|
+
options.ref.startsWith('-') ||
|
|
347
|
+
/[\0\r\n]/u.test(options.ref))
|
|
348
|
+
throw new GitSelectionError('INVALID_GIT_SELECTION');
|
|
349
|
+
const rootOutput = await git(options.cwd, ['rev-parse', '--show-toplevel']);
|
|
350
|
+
const repositoryRoot = rootOutput.trimEnd();
|
|
351
|
+
if (!path.isAbsolute(repositoryRoot))
|
|
352
|
+
throw new GitSelectionError('INVALID_GIT_SELECTION');
|
|
353
|
+
const resolve = async (reference) => {
|
|
354
|
+
const output = await git(repositoryRoot, [
|
|
355
|
+
'rev-parse',
|
|
356
|
+
'--verify',
|
|
357
|
+
'--end-of-options',
|
|
358
|
+
`${reference}^{commit}`,
|
|
359
|
+
]);
|
|
360
|
+
const commit = output.trim();
|
|
361
|
+
if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(commit))
|
|
362
|
+
throw new GitSelectionError('INVALID_GIT_SELECTION');
|
|
363
|
+
return commit;
|
|
364
|
+
};
|
|
365
|
+
const referenceCommit = await resolve(options.ref);
|
|
366
|
+
const headCommit = await resolve('HEAD');
|
|
367
|
+
const baseOutput = await git(repositoryRoot, [
|
|
368
|
+
'merge-base',
|
|
369
|
+
'--all',
|
|
370
|
+
referenceCommit,
|
|
371
|
+
headCommit,
|
|
372
|
+
]);
|
|
373
|
+
const mergeBase = baseOutput.trim();
|
|
374
|
+
if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(mergeBase))
|
|
375
|
+
throw new GitSelectionError('INVALID_GIT_SELECTION');
|
|
376
|
+
const paths = new Set();
|
|
377
|
+
const deleted = new Set();
|
|
378
|
+
const diff = [
|
|
379
|
+
'diff',
|
|
380
|
+
'--name-status',
|
|
381
|
+
'-z',
|
|
382
|
+
'--find-renames',
|
|
383
|
+
'-l0',
|
|
384
|
+
'--no-ext-diff',
|
|
385
|
+
'--no-textconv',
|
|
386
|
+
];
|
|
387
|
+
collect(await git(repositoryRoot, [...diff, mergeBase, headCommit, '--']), paths, deleted);
|
|
388
|
+
collect(await git(repositoryRoot, [...diff, '--cached', headCommit, '--']), paths, deleted);
|
|
389
|
+
const worktree = await git(repositoryRoot, [...diff, '--']);
|
|
390
|
+
const hasWorktreeDeletion = collect(worktree, paths, deleted, true);
|
|
391
|
+
const untracked = tokens(await git(repositoryRoot, ['ls-files', '--others', '--exclude-standard', '-z']));
|
|
392
|
+
// Git cannot infer worktree renames to untracked destinations: refuse ambiguous inbound moves.
|
|
393
|
+
if (untracked.some((file) => relevant(file)) && hasWorktreeDeletion)
|
|
394
|
+
throw new GitSelectionError('BLOCKED_GIT_LIFECYCLE');
|
|
395
|
+
for (const file of untracked)
|
|
396
|
+
if (relevant(file))
|
|
397
|
+
paths.add(file);
|
|
398
|
+
// The current tree decides: a path deleted at some stage but present now is not a delete.
|
|
399
|
+
const removed = [];
|
|
400
|
+
for (const file of deleted) {
|
|
401
|
+
if (await present(path.join(repositoryRoot, ...file.split('/')))) {
|
|
402
|
+
if (!paths.has(file))
|
|
403
|
+
throw new GitSelectionError('BLOCKED_GIT_LIFECYCLE');
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
// A segment SQL file deleted while its JSON stays is a change of that segment (a model
|
|
407
|
+
// removed); the segment is read again from its current files.
|
|
408
|
+
const match = segmentSqlPattern.exec(path.posix.basename(file));
|
|
409
|
+
if (match &&
|
|
410
|
+
(await present(path.join(repositoryRoot, ...path.posix.dirname(file).split('/'), `${match[1]}.segment.json`)))) {
|
|
411
|
+
paths.add(file);
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
// An SQL file removed beside a verbatim insight JSON (retrieved as-is) that stays: a
|
|
415
|
+
// leftover cleaned up, not a deletion of the insight.
|
|
416
|
+
if (ciSql(file) &&
|
|
417
|
+
(await verbatimFile(path.join(repositoryRoot, ...file.slice(0, -ciSqlSuffix.length).split('/')) +
|
|
418
|
+
ciJsonSuffix))) {
|
|
419
|
+
paths.add(file);
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
paths.delete(file);
|
|
423
|
+
removed.push(file);
|
|
424
|
+
}
|
|
425
|
+
const metadata = [...paths].map((file) => {
|
|
426
|
+
if (segmentXml(file))
|
|
427
|
+
throw new GitSelectionError('INVALID_GIT_SELECTION');
|
|
428
|
+
const { kind, name } = classify(file);
|
|
429
|
+
return `${kind}:${name}`;
|
|
430
|
+
});
|
|
431
|
+
const deletions = await deleteCandidates({ repositoryRoot, mergeBase }, removed);
|
|
432
|
+
// Existing admission checks canonical filename, document identity and no-link regular files.
|
|
433
|
+
// A Git range names every changed file; verbatim ones are skipped with a warning.
|
|
434
|
+
const inputs = metadata.length > 0
|
|
435
|
+
? await readDeployInputs({ cwd: repositoryRoot, metadata, verbatim: 'skip' })
|
|
436
|
+
: [];
|
|
437
|
+
const warnings = skippedVerbatimWarnings(inputs);
|
|
438
|
+
const segments = inputs.filter((input) => input.document.kind === 'segment');
|
|
439
|
+
const identityResolutions = inputs.filter((input) => input.document.kind === 'identity-resolution');
|
|
440
|
+
const calculatedInsights = inputs.filter((input) => input.document.kind === 'calculated-insight');
|
|
441
|
+
const dlos = inputs.filter((input) => input.document.kind === 'dlo');
|
|
442
|
+
// A delete and an add of one identity at different paths (a rename split across commit,
|
|
443
|
+
// index and worktree, which Git cannot pair) would delete and create the same component.
|
|
444
|
+
const current = new Set(inputs.map((input) => identityKey(input.document)));
|
|
445
|
+
if (deletions.some((deletion) => current.has(identityKey(deletion.document))))
|
|
446
|
+
throw new GitSelectionError('BLOCKED_GIT_LIFECYCLE');
|
|
447
|
+
return {
|
|
448
|
+
...(dlos.length > 0 ? { dlos: Object.freeze(dlos) } : {}),
|
|
449
|
+
...(calculatedInsights.length > 0
|
|
450
|
+
? { calculatedInsights: Object.freeze(calculatedInsights) }
|
|
451
|
+
: {}),
|
|
452
|
+
...(identityResolutions.length > 0
|
|
453
|
+
? { identityResolutions: Object.freeze(identityResolutions) }
|
|
454
|
+
: {}),
|
|
455
|
+
paths: inputs.map((input) => input.path),
|
|
456
|
+
...(inputs.length > 0 ? { capturedInputs: Object.freeze(inputs) } : {}),
|
|
457
|
+
...(segments.length > 0 ? { segments: Object.freeze(segments) } : {}),
|
|
458
|
+
...(deletions.length > 0 ? { deletions: Object.freeze(deletions) } : {}),
|
|
459
|
+
...(warnings.length > 0 ? { warnings } : {}),
|
|
460
|
+
provenance: {
|
|
461
|
+
repositoryRoot,
|
|
462
|
+
requestedRef: options.ref,
|
|
463
|
+
referenceCommit,
|
|
464
|
+
headCommit,
|
|
465
|
+
mergeBase,
|
|
466
|
+
},
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
catch (error) {
|
|
470
|
+
if (error instanceof GitSelectionError)
|
|
471
|
+
throw error;
|
|
472
|
+
throw new GitSelectionError('INVALID_GIT_SELECTION');
|
|
473
|
+
}
|
|
474
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { DocumentMode } from './verbatim-document.js';
|
|
2
|
+
/**
|
|
3
|
+
* The references of a ruleset (its DMOs, fields, DLO sources and generated outputs) carry no data
|
|
4
|
+
* space: they are all in the ruleset's own data space, the file's `c__dataSpace`, and named as
|
|
5
|
+
* Salesforce stores them there (`ds2_Individual__dlm`, `FirstName__c` in a non-default space).
|
|
6
|
+
*/
|
|
7
|
+
export type IdentityResolutionIdentity = {
|
|
8
|
+
kind: 'identity-resolution';
|
|
9
|
+
apiName: string;
|
|
10
|
+
};
|
|
11
|
+
export type IdentityResolutionDmoReference = {
|
|
12
|
+
kind: 'dmo';
|
|
13
|
+
apiName: string;
|
|
14
|
+
};
|
|
15
|
+
export type IdentityResolutionFieldReference = {
|
|
16
|
+
kind: 'dmo-field';
|
|
17
|
+
parentApiName: string;
|
|
18
|
+
apiName: string;
|
|
19
|
+
};
|
|
20
|
+
export type IdentityResolutionOutputIdentity = {
|
|
21
|
+
owner: IdentityResolutionIdentity;
|
|
22
|
+
entity: IdentityResolutionDmoReference;
|
|
23
|
+
role: 'unified' | 'link';
|
|
24
|
+
};
|
|
25
|
+
export type IdentityResolutionSourceReference = {
|
|
26
|
+
kind: 'dlo';
|
|
27
|
+
apiName: string;
|
|
28
|
+
};
|
|
29
|
+
export type IdentityResolutionReconciliationSettings = {
|
|
30
|
+
ruleType: string;
|
|
31
|
+
shouldIgnoreEmptyValue: boolean;
|
|
32
|
+
sources: IdentityResolutionSourceReference[];
|
|
33
|
+
};
|
|
34
|
+
export type IdentityResolutionDocument = {
|
|
35
|
+
schemaVersion: 1;
|
|
36
|
+
kind: 'identity-resolution';
|
|
37
|
+
c__dataSpace: string;
|
|
38
|
+
identity: {
|
|
39
|
+
apiName: string;
|
|
40
|
+
};
|
|
41
|
+
spec: {
|
|
42
|
+
configurationType: string;
|
|
43
|
+
label: string;
|
|
44
|
+
description: string;
|
|
45
|
+
doesRunAutomatically: boolean;
|
|
46
|
+
isCaseSensitive: boolean;
|
|
47
|
+
secondaryDmo: IdentityResolutionDmoReference;
|
|
48
|
+
filters: unknown[];
|
|
49
|
+
trustedSources?: unknown[];
|
|
50
|
+
matchRules: Array<{
|
|
51
|
+
label: string;
|
|
52
|
+
criteria: Array<{
|
|
53
|
+
field: IdentityResolutionFieldReference;
|
|
54
|
+
matchMethodType: string;
|
|
55
|
+
caseSensitiveMatch: boolean;
|
|
56
|
+
shouldMatchOnBlank: boolean;
|
|
57
|
+
partyIdentificationInfo?: Record<string, unknown>;
|
|
58
|
+
}>;
|
|
59
|
+
}>;
|
|
60
|
+
reconciliationRules: Array<IdentityResolutionReconciliationSettings & {
|
|
61
|
+
entity: IdentityResolutionDmoReference;
|
|
62
|
+
fields: Array<IdentityResolutionReconciliationSettings & {
|
|
63
|
+
field: IdentityResolutionFieldReference;
|
|
64
|
+
}>;
|
|
65
|
+
outputs: IdentityResolutionOutputIdentity[];
|
|
66
|
+
}>;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export type IdentityResolutionProjection = {
|
|
70
|
+
candidate: IdentityResolutionDocument;
|
|
71
|
+
expectations: {
|
|
72
|
+
native: Record<string, unknown>;
|
|
73
|
+
outputs: Array<{
|
|
74
|
+
identity: IdentityResolutionOutputIdentity;
|
|
75
|
+
sourceApiName: string;
|
|
76
|
+
}>;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
/** Refuse unsupported IR shapes without retaining payloads. */
|
|
80
|
+
export declare class IdentityResolutionError extends Error {
|
|
81
|
+
readonly code: string;
|
|
82
|
+
constructor(code: string);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Validate the complete observed portable variant and return detached data. Retrieve mode keeps
|
|
86
|
+
* keys the plugin does not model and `null` values, and checks only what places the file and
|
|
87
|
+
* builds its structure; deploy checks every type, name and uniqueness rule and names the key path.
|
|
88
|
+
* @param {unknown} value Portable content, never a raw response.
|
|
89
|
+
* @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (keeps unknown keys and nulls).
|
|
90
|
+
* @returns {IdentityResolutionDocument} Checked detached document.
|
|
91
|
+
*/
|
|
92
|
+
export declare function validateIdentityResolutionDocument(value: unknown, mode?: DocumentMode): IdentityResolutionDocument;
|
|
93
|
+
/**
|
|
94
|
+
* The data space a ruleset GET names (`dataSpaceName`): the ruleset's real data space, read
|
|
95
|
+
* before anything is projected. One without a usable one is IDENTITY_RESOLUTION_DATASPACE_UNREADABLE.
|
|
96
|
+
* @param {unknown} native Native response.
|
|
97
|
+
* @returns {string} Data space.
|
|
98
|
+
*/
|
|
99
|
+
export declare function identityResolutionSpace(native: unknown): string;
|
|
100
|
+
/**
|
|
101
|
+
* The refusal of a ruleset whose file, or whose ruleset in the org, is in another data space than
|
|
102
|
+
* the run's.
|
|
103
|
+
* @param {string} apiName Ruleset name.
|
|
104
|
+
* @param {string} found The data space of the file or the org ruleset.
|
|
105
|
+
* @param {string} dataSpace The run's data space.
|
|
106
|
+
* @param {'file' | 'org'} where Whether the file or the org ruleset names `found`.
|
|
107
|
+
* @param {boolean} [crossSpace] A deploy --allow-cross-dataspace can translate: say so.
|
|
108
|
+
* @returns {IdentityResolutionError} IDENTITY_RESOLUTION_DATASPACE_MISMATCH with an explanation.
|
|
109
|
+
*/
|
|
110
|
+
export declare function identityResolutionSpaceMismatch(apiName: string, found: string, dataSpace: string, where: 'file' | 'org', crossSpace?: boolean): IdentityResolutionError;
|
|
111
|
+
/**
|
|
112
|
+
* Project the genuine API68 owner.
|
|
113
|
+
* @param {unknown} native Exact native owner response.
|
|
114
|
+
* @param {string} apiName Requested owner API name.
|
|
115
|
+
* @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (keeps unknown keys and nulls).
|
|
116
|
+
* @returns {IdentityResolutionProjection} Portable definition and private owner expectations.
|
|
117
|
+
*/
|
|
118
|
+
export declare function projectNativeIdentityResolution(native: unknown, apiName: string, mode?: DocumentMode): IdentityResolutionProjection;
|
|
119
|
+
/**
|
|
120
|
+
* The owner as the API returns it, without the run statistics it adds after a run: what a
|
|
121
|
+
* by-name delete of a verbatim file compares between its reads.
|
|
122
|
+
* @param {unknown} native Native response.
|
|
123
|
+
* @returns {Record<string, unknown>} Detached owner.
|
|
124
|
+
*/
|
|
125
|
+
export declare function observeIdentityResolutionOwner(native: unknown): Record<string, unknown>;
|
|
126
|
+
/**
|
|
127
|
+
* Serialize complete admitted portable content, never private acquisition expectations.
|
|
128
|
+
* @param {unknown} value Portable candidate.
|
|
129
|
+
* @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (keeps unknown keys and nulls).
|
|
130
|
+
* @returns {string} Stable JSON bytes with final LF.
|
|
131
|
+
*/
|
|
132
|
+
export declare function serializeIdentityResolutionDocument(value: unknown, mode?: DocumentMode): string;
|
|
133
|
+
export { identityResolutionName } from './path-selector.js';
|