@commercetools/cli-topic-integration-layer 0.5.1 → 0.7.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/README.md +2 -6
- package/dist/commands/integration-layer/allowlist/add.js +3 -3
- package/dist/commands/integration-layer/allowlist/add.js.map +1 -1
- package/dist/commands/integration-layer/allowlist/list.js +2 -2
- package/dist/commands/integration-layer/allowlist/list.js.map +1 -1
- package/dist/commands/integration-layer/allowlist/remove.js +3 -3
- package/dist/commands/integration-layer/allowlist/remove.js.map +1 -1
- package/dist/commands/integration-layer/allowlist/set.js +3 -3
- package/dist/commands/integration-layer/allowlist/set.js.map +1 -1
- package/dist/commands/integration-layer/config/get.js +2 -2
- package/dist/commands/integration-layer/config/get.js.map +1 -1
- package/dist/commands/integration-layer/config/list.js +2 -2
- package/dist/commands/integration-layer/config/list.js.map +1 -1
- package/dist/commands/integration-layer/config/set.js +2 -2
- package/dist/commands/integration-layer/config/set.js.map +1 -1
- package/dist/commands/integration-layer/config/unset.js +2 -2
- package/dist/commands/integration-layer/config/unset.js.map +1 -1
- package/dist/commands/integration-layer/explore.js +5 -5
- package/dist/commands/integration-layer/explore.js.map +1 -1
- package/dist/commands/integration-layer/extension/build.js +4 -1
- package/dist/commands/integration-layer/extension/build.js.map +1 -1
- package/dist/commands/integration-layer/extension/create-api-extension-input.d.ts +12 -0
- package/dist/commands/integration-layer/extension/create-api-extension-input.js +49 -0
- package/dist/commands/integration-layer/extension/create-api-extension-input.js.map +1 -0
- package/dist/commands/integration-layer/extension/delete.js +2 -2
- package/dist/commands/integration-layer/extension/delete.js.map +1 -1
- package/dist/commands/integration-layer/extension/invoke-api-extension.d.ts +19 -0
- package/dist/commands/integration-layer/extension/invoke-api-extension.js +140 -0
- package/dist/commands/integration-layer/extension/invoke-api-extension.js.map +1 -0
- package/dist/commands/integration-layer/extension/push.js +8 -5
- package/dist/commands/integration-layer/extension/push.js.map +1 -1
- package/dist/commands/integration-layer/extension/serve.d.ts +36 -0
- package/dist/commands/integration-layer/extension/serve.js +140 -36
- package/dist/commands/integration-layer/extension/serve.js.map +1 -1
- package/dist/commands/integration-layer/extension/status.js +2 -2
- package/dist/commands/integration-layer/extension/status.js.map +1 -1
- package/dist/commands/integration-layer/extension/validate.js +6 -3
- package/dist/commands/integration-layer/extension/validate.js.map +1 -1
- package/dist/commands/integration-layer/schema/fetch.js +2 -2
- package/dist/commands/integration-layer/schema/fetch.js.map +1 -1
- package/dist/hooks/authentication.d.ts +3 -0
- package/dist/hooks/authentication.js +33 -0
- package/dist/hooks/authentication.js.map +1 -0
- package/dist/lib/auth.d.ts +5 -0
- package/dist/lib/auth.js +41 -0
- package/dist/lib/auth.js.map +1 -0
- package/dist/lib/awaitBundleState.d.ts +2 -2
- package/dist/lib/awaitBundleState.js +2 -2
- package/dist/lib/awaitBundleState.js.map +1 -1
- package/dist/lib/base.d.ts +12 -21
- package/dist/lib/base.js +27 -76
- package/dist/lib/base.js.map +1 -1
- package/dist/lib/extensionConfig.d.ts +17 -0
- package/dist/lib/extensionConfig.js +36 -0
- package/dist/lib/extensionConfig.js.map +1 -0
- package/dist/lib/ilClient.d.ts +16 -10
- package/dist/lib/ilClient.js +28 -31
- package/dist/lib/ilClient.js.map +1 -1
- package/dist/lib/loadLocalEnv.d.ts +49 -0
- package/dist/lib/loadLocalEnv.js +112 -0
- package/dist/lib/loadLocalEnv.js.map +1 -0
- package/dist/lib/tooling/compose.js +2 -2
- package/dist/lib/tooling/compose.js.map +1 -1
- package/dist/lib/tooling/extensionInputSampleObj.d.ts +8 -0
- package/dist/lib/tooling/extensionInputSampleObj.js +178 -0
- package/dist/lib/tooling/extensionInputSampleObj.js.map +1 -0
- package/dist/lib/tooling/extensions.d.ts +22 -5
- package/dist/lib/tooling/extensions.js +30 -8
- package/dist/lib/tooling/extensions.js.map +1 -1
- package/dist/lib/tooling/generateExtensionInputSample.d.ts +22 -0
- package/dist/lib/tooling/generateExtensionInputSample.js +36 -0
- package/dist/lib/tooling/generateExtensionInputSample.js.map +1 -0
- package/dist/lib/tooling/sandboxFetch.d.ts +14 -0
- package/dist/lib/tooling/sandboxFetch.js +100 -0
- package/dist/lib/tooling/sandboxFetch.js.map +1 -0
- package/package.json +11 -3
- package/dist/commands/integration-layer/extension/invoke.d.ts +0 -14
- package/dist/commands/integration-layer/extension/invoke.js +0 -94
- package/dist/commands/integration-layer/extension/invoke.js.map +0 -1
package/dist/lib/ilClient.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
// Low-level HTTP client for the Commerce Integration Layer's per-project manage-surface
|
|
2
|
-
// routes. Every call is parameterised by (baseUrl, projectKey,
|
|
3
|
-
// layer resolves those (`IntegrationLayerCommand.resolveIlContext
|
|
4
|
-
//
|
|
5
|
-
//
|
|
2
|
+
// routes. Every call is parameterised by (baseUrl, projectKey, authFetch) — the command
|
|
3
|
+
// layer resolves those (`IntegrationLayerCommand.resolveIlContext`), and this module just
|
|
4
|
+
// speaks the wire protocol. `authFetch` is the `CtpAuthFetchFactory` fetch: it injects the
|
|
5
|
+
// `manage_project` bearer and transparently refreshes/retries it, so nothing here sets an
|
|
6
|
+
// Authorization header itself. The route bodies these mirror live in the integration
|
|
6
7
|
// layer's `routes/manage.ts`; the request/response shapes here are extracted from the
|
|
7
8
|
// `ee-ext` tooling's `remoteValidate.ts` / `push.ts` (which read them from env) and
|
|
8
9
|
// the remaining manage routes (config, status, delete, subgraph).
|
|
9
10
|
function apiRoot(baseUrl, projectKey) {
|
|
10
11
|
return `${baseUrl.replace(/\/+$/, "")}/${encodeURIComponent(projectKey)}`;
|
|
11
12
|
}
|
|
12
|
-
function bearer(token) {
|
|
13
|
-
return { Authorization: `Bearer ${token}` };
|
|
14
|
-
}
|
|
15
13
|
/** GET the project's raw core-subgraph SDL — the compose input (`GET …/subgraph`). */
|
|
16
|
-
export async function fetchSubgraphSdl(baseUrl, projectKey,
|
|
14
|
+
export async function fetchSubgraphSdl(baseUrl, projectKey, authFetch) {
|
|
17
15
|
const url = `${apiRoot(baseUrl, projectKey)}/subgraph`;
|
|
18
|
-
const res = await
|
|
16
|
+
const res = await authFetch(url, { headers: { accept: "text/plain" } });
|
|
19
17
|
const text = await res.text();
|
|
20
18
|
if (!res.ok) {
|
|
21
19
|
throw new Error(`could not fetch core-subgraph SDL (${res.status}) from ${url}: ${text}`);
|
|
@@ -37,9 +35,9 @@ export async function fetchSubgraphSdl(baseUrl, projectKey, token) {
|
|
|
37
35
|
* same `manage_project` boundary as `/subgraph`. 404 means the project has never
|
|
38
36
|
* published a composable version.
|
|
39
37
|
*/
|
|
40
|
-
export async function fetchDeployedApiSchemaSdl(baseUrl, projectKey,
|
|
38
|
+
export async function fetchDeployedApiSchemaSdl(baseUrl, projectKey, authFetch) {
|
|
41
39
|
const url = `${apiRoot(baseUrl, projectKey)}/schema/api`;
|
|
42
|
-
const res = await
|
|
40
|
+
const res = await authFetch(url, { headers: { accept: "text/plain" } });
|
|
43
41
|
const text = await res.text();
|
|
44
42
|
if (res.status === 404) {
|
|
45
43
|
throw new Error(`project '${projectKey}' has no composed schema published yet — publish one from the ` +
|
|
@@ -51,11 +49,11 @@ export async function fetchDeployedApiSchemaSdl(baseUrl, projectKey, token) {
|
|
|
51
49
|
return text;
|
|
52
50
|
}
|
|
53
51
|
/** POST a candidate SDL to the composition + breaking-change gate (`POST …/extension/validate`). */
|
|
54
|
-
export async function remoteValidate(baseUrl, projectKey,
|
|
52
|
+
export async function remoteValidate(baseUrl, projectKey, authFetch, typeDefs) {
|
|
55
53
|
const url = `${apiRoot(baseUrl, projectKey)}/extension/validate`;
|
|
56
|
-
const res = await
|
|
54
|
+
const res = await authFetch(url, {
|
|
57
55
|
method: "POST",
|
|
58
|
-
headers: { "Content-Type": "application/json"
|
|
56
|
+
headers: { "Content-Type": "application/json" },
|
|
59
57
|
body: JSON.stringify({ typeDefs }),
|
|
60
58
|
});
|
|
61
59
|
const text = await res.text();
|
|
@@ -71,9 +69,9 @@ export async function remoteValidate(baseUrl, projectKey, token, typeDefs) {
|
|
|
71
69
|
* came from; the Commerce Integration Layer stores it against the revision, shows it in the
|
|
72
70
|
* Merchant Center, and hands it to the connector.
|
|
73
71
|
*/
|
|
74
|
-
export async function pushBundle(baseUrl, projectKey,
|
|
72
|
+
export async function pushBundle(baseUrl, projectKey, authFetch, bundle, filename, sourceRevision) {
|
|
75
73
|
const url = `${apiRoot(baseUrl, projectKey)}/extension/bundle`;
|
|
76
|
-
const res = await
|
|
74
|
+
const res = await authFetch(url, {
|
|
77
75
|
method: "PUT",
|
|
78
76
|
headers: {
|
|
79
77
|
"Content-Type": "text/javascript",
|
|
@@ -86,7 +84,6 @@ export async function pushBundle(baseUrl, projectKey, token, bundle, filename, s
|
|
|
86
84
|
...(sourceRevision
|
|
87
85
|
? { "x-extension-source-revision": encodeURIComponent(sourceRevision) }
|
|
88
86
|
: {}),
|
|
89
|
-
...bearer(token),
|
|
90
87
|
},
|
|
91
88
|
body: bundle,
|
|
92
89
|
});
|
|
@@ -97,9 +94,9 @@ export async function pushBundle(baseUrl, projectKey, token, bundle, filename, s
|
|
|
97
94
|
return JSON.parse(text);
|
|
98
95
|
}
|
|
99
96
|
/** The stored bundle's metadata, or null if none is stored (`GET …/extension/bundle/meta`). */
|
|
100
|
-
export async function fetchExtensionMeta(baseUrl, projectKey,
|
|
97
|
+
export async function fetchExtensionMeta(baseUrl, projectKey, authFetch) {
|
|
101
98
|
const url = `${apiRoot(baseUrl, projectKey)}/extension/bundle/meta`;
|
|
102
|
-
const res = await
|
|
99
|
+
const res = await authFetch(url, { headers: { accept: "application/json" } });
|
|
103
100
|
if (res.status === 404)
|
|
104
101
|
return null;
|
|
105
102
|
const text = await res.text();
|
|
@@ -109,18 +106,18 @@ export async function fetchExtensionMeta(baseUrl, projectKey, token) {
|
|
|
109
106
|
return JSON.parse(text);
|
|
110
107
|
}
|
|
111
108
|
/** Remove the project's extension subgraph from Hive (`DELETE …/extension/subgraph`). */
|
|
112
|
-
export async function deleteExtensionSubgraph(baseUrl, projectKey,
|
|
109
|
+
export async function deleteExtensionSubgraph(baseUrl, projectKey, authFetch) {
|
|
113
110
|
const url = `${apiRoot(baseUrl, projectKey)}/extension/subgraph`;
|
|
114
|
-
const res = await
|
|
111
|
+
const res = await authFetch(url, { method: "DELETE" });
|
|
115
112
|
if (!res.ok && res.status !== 204) {
|
|
116
113
|
const text = await res.text();
|
|
117
114
|
throw new Error(`DELETE extension/subgraph failed (${res.status}): ${text}`);
|
|
118
115
|
}
|
|
119
116
|
}
|
|
120
117
|
/** GET the project's extension HTTP allowlist (`GET …/extension/allowlist`). */
|
|
121
|
-
export async function getAllowlist(baseUrl, projectKey,
|
|
118
|
+
export async function getAllowlist(baseUrl, projectKey, authFetch) {
|
|
122
119
|
const url = `${apiRoot(baseUrl, projectKey)}/extension/allowlist`;
|
|
123
|
-
const res = await
|
|
120
|
+
const res = await authFetch(url, { headers: { accept: "application/json" } });
|
|
124
121
|
const text = await res.text();
|
|
125
122
|
if (!res.ok) {
|
|
126
123
|
throw new Error(`GET extension/allowlist failed (${res.status}): ${text}`);
|
|
@@ -135,11 +132,11 @@ export async function getAllowlist(baseUrl, projectKey, token) {
|
|
|
135
132
|
* returns the stored list plus the config's new monotonic version. The `deny` ceiling
|
|
136
133
|
* is untouched (it has no write route).
|
|
137
134
|
*/
|
|
138
|
-
export async function putAllowlist(baseUrl, projectKey,
|
|
135
|
+
export async function putAllowlist(baseUrl, projectKey, authFetch, patterns) {
|
|
139
136
|
const url = `${apiRoot(baseUrl, projectKey)}/extension/allowlist`;
|
|
140
|
-
const res = await
|
|
137
|
+
const res = await authFetch(url, {
|
|
141
138
|
method: "PUT",
|
|
142
|
-
headers: { "Content-Type": "application/json"
|
|
139
|
+
headers: { "Content-Type": "application/json" },
|
|
143
140
|
body: JSON.stringify(patterns),
|
|
144
141
|
});
|
|
145
142
|
const text = await res.text();
|
|
@@ -149,9 +146,9 @@ export async function putAllowlist(baseUrl, projectKey, token, patterns) {
|
|
|
149
146
|
return JSON.parse(text);
|
|
150
147
|
}
|
|
151
148
|
/** List the project's extension config entries, secret values redacted (`GET …/extension/config`). */
|
|
152
|
-
export async function listConfig(baseUrl, projectKey,
|
|
149
|
+
export async function listConfig(baseUrl, projectKey, authFetch) {
|
|
153
150
|
const url = `${apiRoot(baseUrl, projectKey)}/extension/config`;
|
|
154
|
-
const res = await
|
|
151
|
+
const res = await authFetch(url, { headers: { accept: "application/json" } });
|
|
155
152
|
const text = await res.text();
|
|
156
153
|
if (!res.ok) {
|
|
157
154
|
throw new Error(`GET extension/config failed (${res.status}): ${text}`);
|
|
@@ -163,11 +160,11 @@ export async function listConfig(baseUrl, projectKey, token) {
|
|
|
163
160
|
* (`PATCH …/extension/config`). An entry with `value: null` deletes that key. PATCH
|
|
164
161
|
* (not PUT) so a single set/unset touches one key without clobbering the rest.
|
|
165
162
|
*/
|
|
166
|
-
export async function patchConfig(baseUrl, projectKey,
|
|
163
|
+
export async function patchConfig(baseUrl, projectKey, authFetch, entries) {
|
|
167
164
|
const url = `${apiRoot(baseUrl, projectKey)}/extension/config`;
|
|
168
|
-
const res = await
|
|
165
|
+
const res = await authFetch(url, {
|
|
169
166
|
method: "PATCH",
|
|
170
|
-
headers: { "Content-Type": "application/json"
|
|
167
|
+
headers: { "Content-Type": "application/json" },
|
|
171
168
|
body: JSON.stringify(entries),
|
|
172
169
|
});
|
|
173
170
|
const text = await res.text();
|
package/dist/lib/ilClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ilClient.js","sourceRoot":"","sources":["../../src/lib/ilClient.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,
|
|
1
|
+
{"version":3,"file":"ilClient.js","sourceRoot":"","sources":["../../src/lib/ilClient.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,wFAAwF;AACxF,0FAA0F;AAC1F,2FAA2F;AAC3F,0FAA0F;AAC1F,qFAAqF;AACrF,sFAAsF;AACtF,oFAAoF;A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MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE;QAC/B,MAAM,EAAE,OAAO;QACf,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;KAC9B,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAC9B,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,kCAAkC,GAAG,CAAC,MAAM,MAAM,IAAI,EAAE,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAkB,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Where a command's dotenv file is, and whether a missing file is an error. */
|
|
2
|
+
export interface EnvFileLocation {
|
|
3
|
+
/** Absolute path to the dotenv file. */
|
|
4
|
+
path: string;
|
|
5
|
+
/** True when an explicit `--env-file` was given, so a missing file must fail loudly. */
|
|
6
|
+
required: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Peek argv for `--env-file <path>` / `--env-file=<path>` before oclif parses flags.
|
|
10
|
+
* Must run in `init()` so values (e.g. `INTEGRATION_LAYER_URL`, `EXTENSION_CONFIG_*`)
|
|
11
|
+
* are in `process.env` when flag `env:` bindings resolve.
|
|
12
|
+
*/
|
|
13
|
+
export declare function envFilePathFromArgv(argv?: readonly string[]): string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve which dotenv file a command should read: an explicit `--env-file <path>`
|
|
16
|
+
* (required — a missing one is an error) or, failing that, `.env` in the cwd (optional).
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveEnvFileLocation(options?: {
|
|
19
|
+
argv?: readonly string[];
|
|
20
|
+
cwd?: string;
|
|
21
|
+
}): EnvFileLocation;
|
|
22
|
+
/**
|
|
23
|
+
* Load a dotenv file into `process.env` without overriding existing keys
|
|
24
|
+
* (Node's `process.loadEnvFile` semantics).
|
|
25
|
+
*
|
|
26
|
+
* - `--env-file <path>` (from argv): required; a missing file fails loudly.
|
|
27
|
+
* - otherwise `.env` in cwd: optional; a missing file is a no-op.
|
|
28
|
+
*
|
|
29
|
+
* Returns the absolute path that was loaded, or `undefined` when nothing was loaded.
|
|
30
|
+
*/
|
|
31
|
+
export declare function loadLocalEnv(options?: {
|
|
32
|
+
argv?: readonly string[];
|
|
33
|
+
cwd?: string;
|
|
34
|
+
}): string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Parse a dotenv file into a plain object WITHOUT touching `process.env`. Returns an
|
|
37
|
+
* empty object when the file is absent — the caller decides whether that's an error.
|
|
38
|
+
* Used by the `serve` hot-reload path, which needs the file's current values on each
|
|
39
|
+
* change (unlike {@link loadLocalEnv}, whose "existing env wins" load can't re-apply an
|
|
40
|
+
* edited value already present in `process.env`).
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseEnvFile(filePath: string): Record<string, string>;
|
|
43
|
+
/**
|
|
44
|
+
* Watch a dotenv file for changes and invoke `onChange` (debounced) after each write.
|
|
45
|
+
* Watches the containing DIRECTORY, not the file, so it survives editors that save via
|
|
46
|
+
* atomic rename (which swaps the inode and would silently kill a file-level watch) and
|
|
47
|
+
* catches the file being created after the server starts. Returns a stop function.
|
|
48
|
+
*/
|
|
49
|
+
export declare function watchEnvFile(filePath: string, onChange: () => void): () => void;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { watch } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { parseEnv } from "node:util";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
const ENV_FILE_FLAG = "--env-file";
|
|
6
|
+
/**
|
|
7
|
+
* Peek argv for `--env-file <path>` / `--env-file=<path>` before oclif parses flags.
|
|
8
|
+
* Must run in `init()` so values (e.g. `INTEGRATION_LAYER_URL`, `EXTENSION_CONFIG_*`)
|
|
9
|
+
* are in `process.env` when flag `env:` bindings resolve.
|
|
10
|
+
*/
|
|
11
|
+
export function envFilePathFromArgv(argv = process.argv) {
|
|
12
|
+
for (let i = 0; i < argv.length; i++) {
|
|
13
|
+
const arg = argv[i];
|
|
14
|
+
if (arg === ENV_FILE_FLAG) {
|
|
15
|
+
const next = argv[i + 1];
|
|
16
|
+
if (!next || next.startsWith("-")) {
|
|
17
|
+
throw new Error(`${ENV_FILE_FLAG} requires a path`);
|
|
18
|
+
}
|
|
19
|
+
return next;
|
|
20
|
+
}
|
|
21
|
+
if (arg.startsWith(`${ENV_FILE_FLAG}=`)) {
|
|
22
|
+
const value = arg.slice(ENV_FILE_FLAG.length + 1);
|
|
23
|
+
if (!value)
|
|
24
|
+
throw new Error(`${ENV_FILE_FLAG} requires a path`);
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Resolve which dotenv file a command should read: an explicit `--env-file <path>`
|
|
32
|
+
* (required — a missing one is an error) or, failing that, `.env` in the cwd (optional).
|
|
33
|
+
*/
|
|
34
|
+
export function resolveEnvFileLocation(options) {
|
|
35
|
+
const cwd = options?.cwd ?? process.cwd();
|
|
36
|
+
const fromArgv = envFilePathFromArgv(options?.argv ?? process.argv);
|
|
37
|
+
return {
|
|
38
|
+
path: path.resolve(cwd, fromArgv ?? ".env"),
|
|
39
|
+
required: fromArgv !== undefined,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Load a dotenv file into `process.env` without overriding existing keys
|
|
44
|
+
* (Node's `process.loadEnvFile` semantics).
|
|
45
|
+
*
|
|
46
|
+
* - `--env-file <path>` (from argv): required; a missing file fails loudly.
|
|
47
|
+
* - otherwise `.env` in cwd: optional; a missing file is a no-op.
|
|
48
|
+
*
|
|
49
|
+
* Returns the absolute path that was loaded, or `undefined` when nothing was loaded.
|
|
50
|
+
*/
|
|
51
|
+
export function loadLocalEnv(options) {
|
|
52
|
+
const { path: filePath, required } = resolveEnvFileLocation(options);
|
|
53
|
+
try {
|
|
54
|
+
process.loadEnvFile(filePath);
|
|
55
|
+
return filePath;
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
const code = err.code;
|
|
59
|
+
if (!required && code === "ENOENT")
|
|
60
|
+
return undefined;
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Parse a dotenv file into a plain object WITHOUT touching `process.env`. Returns an
|
|
66
|
+
* empty object when the file is absent — the caller decides whether that's an error.
|
|
67
|
+
* Used by the `serve` hot-reload path, which needs the file's current values on each
|
|
68
|
+
* change (unlike {@link loadLocalEnv}, whose "existing env wins" load can't re-apply an
|
|
69
|
+
* edited value already present in `process.env`).
|
|
70
|
+
*/
|
|
71
|
+
export function parseEnvFile(filePath) {
|
|
72
|
+
let source;
|
|
73
|
+
try {
|
|
74
|
+
source = readFileSync(filePath, "utf8");
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
if (err.code === "ENOENT")
|
|
78
|
+
return {};
|
|
79
|
+
throw err;
|
|
80
|
+
}
|
|
81
|
+
return parseEnv(source);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Watch a dotenv file for changes and invoke `onChange` (debounced) after each write.
|
|
85
|
+
* Watches the containing DIRECTORY, not the file, so it survives editors that save via
|
|
86
|
+
* atomic rename (which swaps the inode and would silently kill a file-level watch) and
|
|
87
|
+
* catches the file being created after the server starts. Returns a stop function.
|
|
88
|
+
*/
|
|
89
|
+
export function watchEnvFile(filePath, onChange) {
|
|
90
|
+
const dir = path.dirname(filePath);
|
|
91
|
+
const base = path.basename(filePath);
|
|
92
|
+
let timer;
|
|
93
|
+
let watcher;
|
|
94
|
+
try {
|
|
95
|
+
watcher = watch(dir, (_event, changed) => {
|
|
96
|
+
// `changed` is null on some platforms; fall back to firing on any dir event.
|
|
97
|
+
if (changed !== null && changed !== base)
|
|
98
|
+
return;
|
|
99
|
+
clearTimeout(timer);
|
|
100
|
+
timer = setTimeout(onChange, 50);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// A missing/unwatchable directory just means no hot-reload; not fatal.
|
|
105
|
+
return () => { };
|
|
106
|
+
}
|
|
107
|
+
return () => {
|
|
108
|
+
clearTimeout(timer);
|
|
109
|
+
watcher.close();
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=loadLocalEnv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadLocalEnv.js","sourceRoot":"","sources":["../../src/lib/loadLocalEnv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAkB,MAAM,SAAS,CAAC;AAChD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,aAAa,GAAG,YAAY,CAAC;AAUnC;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAA0B,OAAO,CAAC,IAAI;IACxE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC;QACrB,IAAI,GAAG,KAAK,aAAa,EAAE,CAAC;YAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACzB,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBAClC,MAAM,IAAI,KAAK,CAAC,GAAG,aAAa,kBAAkB,CAAC,CAAC;YACtD,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CA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AAc,CAAC;IACnB,IAAI,CAAC;QACH,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC1C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,EAAE,CAAC;QAChE,MAAM,GAAG,CAAC;IACZ,CAAC;IACD,OAAO,QAAQ,CAAC,MAAM,CAA2B,CAAC;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB,EAAE,QAAoB;IACjE,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrC,IAAI,KAAiC,CAAC;IACtC,IAAI,OAAkB,CAAC;IACvB,IAAI,CAAC;QACH,OAAO,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;YACvC,6EAA6E;YAC7E,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,IAAI;gBAAE,OAAO;YACjD,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,uEAAuE;QACvE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,EAAE;QACV,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,OAAO,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
//
|
|
4
4
|
// `composeWithIntegrationLayer` below is the low-level half. Fetching the project's
|
|
5
5
|
// subgraph SDL is a plain authenticated HTTP call, so it lives separately in
|
|
6
|
-
// `../ilClient.ts`, parameterised by (baseUrl, projectKey,
|
|
7
|
-
// layer supplying the
|
|
6
|
+
// `../ilClient.ts`, parameterised by (baseUrl, projectKey, authFetch) with the command
|
|
7
|
+
// layer supplying the authenticated fetch.
|
|
8
8
|
import { parse, printSchema } from "graphql";
|
|
9
9
|
import { composeServices } from "@apollo/composition";
|
|
10
10
|
/** The subgraph names the Commerce Integration Layer composes under — matched here so the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../../src/lib/tooling/compose.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,+FAA+F;AAC/F,EAAE;AACF,oFAAoF;AACpF,6EAA6E;AAC7E,
|
|
1
|
+
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../../src/lib/tooling/compose.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,+FAA+F;AAC/F,EAAE;AACF,oFAAoF;AACpF,6EAA6E;AAC7E,uFAAuF;AACvF,2CAA2C;AAE3C,OAAO,EAAE,KAAK,EAAE,WAAW,EAAsB,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;mDAEmD;AACnD,MAAM,CAAC,MAAM,yBAAyB,GAAG,mBAAmB,CAAC;AAC7D,MAAM,CAAC,MAAM,iBAAiB,GAAG,YAAY,CAAC;AAc9C;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,mBAA2B,EAC3B,YAAoB,EACpB,IAA2D;IAE3D,IAAI,QAAQ,CAAC;IACb,IAAI,CAAC;QACH,QAAQ,GAAG;YACT,EAAE,IAAI,EAAE,yBAAyB,EAAE,QAAQ,EAAE,KAAK,CAAC,mBAAmB,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,mBAAmB,EAAE;YACxG,EAAE,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE;SACnF,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,6BAA8B,GAAa,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;IACxF,CAAC;IAED,MAAM,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IACzC,gFAAgF;IAChF,6EAA6E;IAC7E,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACpE,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,iBAAiB,EAAE,CAAC;IAClE,OAAO;QACL,EAAE,EAAE,IAAI;QACR,SAAS;QACT,MAAM,EAAE,WAAW,CAAC,SAAS,CAAC;QAC9B,aAAa,EAAE,MAAM,CAAC,aAAa;KACpC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ExtensionResourceTypeId } from "@commercetools/platform-sdk";
|
|
2
|
+
export interface SampleContext {
|
|
3
|
+
resourceTypeId: ExtensionResourceTypeId;
|
|
4
|
+
id: string;
|
|
5
|
+
version: number;
|
|
6
|
+
}
|
|
7
|
+
/** Build the expanded `resource.obj` for an API-Extension resource type. */
|
|
8
|
+
export declare function sampleExtensionResourceObj(resourceTypeId: ExtensionResourceTypeId, ctx: SampleContext): Record<string, unknown>;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { AuthenticationModeValues, BusinessUnitTypeValues, CartOriginValues, CartStateValues, ExtensionResourceTypeIdValues, InventoryModeValues, OrderStateValues, PaymentMethodStatusValues, QuoteRequestStateValues, QuoteStateValues, RoundingModeValues, ShippingModeValues, StagedQuoteStateValues, TaxCalculationModeValues, TaxModeValues, } from "@commercetools/platform-sdk";
|
|
2
|
+
const SAMPLE = {
|
|
3
|
+
productId: "sample-product-id",
|
|
4
|
+
productTypeId: "sample-product-type-id",
|
|
5
|
+
lineItemId: "sample-line-item-id",
|
|
6
|
+
cartId: "sample-cart-id",
|
|
7
|
+
sku: "SAMPLE-SKU",
|
|
8
|
+
currency: "EUR",
|
|
9
|
+
email: "sample.customer@example.com",
|
|
10
|
+
quoteRequestId: "sample-quote-request-id",
|
|
11
|
+
stagedQuoteId: "sample-staged-quote-id",
|
|
12
|
+
timestamp: "2024-01-01T00:00:00.000Z",
|
|
13
|
+
};
|
|
14
|
+
function sampleMoney(centAmount = 1000) {
|
|
15
|
+
return {
|
|
16
|
+
type: "centPrecision",
|
|
17
|
+
currencyCode: SAMPLE.currency,
|
|
18
|
+
centAmount,
|
|
19
|
+
fractionDigits: 2,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function sampleAddress(id = "sample-address-id") {
|
|
23
|
+
return {
|
|
24
|
+
id,
|
|
25
|
+
country: "DE",
|
|
26
|
+
city: "Berlin",
|
|
27
|
+
streetName: "Sample Street",
|
|
28
|
+
streetNumber: "1",
|
|
29
|
+
postalCode: "10115",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function sampleProductTypeRef() {
|
|
33
|
+
return { typeId: "product-type", id: SAMPLE.productTypeId };
|
|
34
|
+
}
|
|
35
|
+
function sampleCartLineItem() {
|
|
36
|
+
return {
|
|
37
|
+
id: SAMPLE.lineItemId,
|
|
38
|
+
productId: SAMPLE.productId,
|
|
39
|
+
productType: sampleProductTypeRef(),
|
|
40
|
+
name: { en: "Sample product" },
|
|
41
|
+
quantity: 1,
|
|
42
|
+
variant: { id: 1, sku: SAMPLE.sku },
|
|
43
|
+
price: { value: sampleMoney() },
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function sampleShoppingListLineItem() {
|
|
47
|
+
return {
|
|
48
|
+
id: SAMPLE.lineItemId,
|
|
49
|
+
addedAt: SAMPLE.timestamp,
|
|
50
|
+
productId: SAMPLE.productId,
|
|
51
|
+
productType: sampleProductTypeRef(),
|
|
52
|
+
name: { en: "Sample product" },
|
|
53
|
+
published: true,
|
|
54
|
+
quantity: 1,
|
|
55
|
+
variant: { id: 1, sku: SAMPLE.sku },
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function sampleCartFields(ctx) {
|
|
59
|
+
return {
|
|
60
|
+
id: ctx.id,
|
|
61
|
+
version: ctx.version,
|
|
62
|
+
currency: SAMPLE.currency,
|
|
63
|
+
lineItems: [sampleCartLineItem()],
|
|
64
|
+
customLineItems: [],
|
|
65
|
+
totalPrice: sampleMoney(),
|
|
66
|
+
taxMode: TaxModeValues.Platform,
|
|
67
|
+
priceRoundingMode: RoundingModeValues.HalfEven,
|
|
68
|
+
taxRoundingMode: RoundingModeValues.HalfEven,
|
|
69
|
+
taxCalculationMode: TaxCalculationModeValues.LineItemLevel,
|
|
70
|
+
inventoryMode: InventoryModeValues.None,
|
|
71
|
+
cartState: CartStateValues.Active,
|
|
72
|
+
shippingMode: ShippingModeValues.Single,
|
|
73
|
+
shipping: [],
|
|
74
|
+
discountCodes: [],
|
|
75
|
+
directDiscounts: [],
|
|
76
|
+
refusedGifts: [],
|
|
77
|
+
origin: CartOriginValues.Customer,
|
|
78
|
+
itemShippingAddresses: [],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const sampleObjBuilders = {
|
|
82
|
+
[ExtensionResourceTypeIdValues.Cart]: sampleCartFields,
|
|
83
|
+
[ExtensionResourceTypeIdValues.Order]: (ctx) => ({
|
|
84
|
+
...sampleCartFields(ctx),
|
|
85
|
+
orderNumber: "SAMPLE-ORDER-001",
|
|
86
|
+
orderState: OrderStateValues.Open,
|
|
87
|
+
}),
|
|
88
|
+
[ExtensionResourceTypeIdValues.Payment]: (ctx) => ({
|
|
89
|
+
id: ctx.id,
|
|
90
|
+
version: ctx.version,
|
|
91
|
+
amountPlanned: sampleMoney(),
|
|
92
|
+
paymentMethodInfo: {
|
|
93
|
+
paymentInterface: "Sample",
|
|
94
|
+
method: "card",
|
|
95
|
+
},
|
|
96
|
+
paymentStatus: {
|
|
97
|
+
interfaceCode: "Pending",
|
|
98
|
+
interfaceText: "Pending",
|
|
99
|
+
},
|
|
100
|
+
}),
|
|
101
|
+
[ExtensionResourceTypeIdValues.PaymentMethod]: (ctx) => ({
|
|
102
|
+
id: ctx.id,
|
|
103
|
+
version: ctx.version,
|
|
104
|
+
key: "sample-payment-method",
|
|
105
|
+
name: { en: "Sample card" },
|
|
106
|
+
paymentInterface: "Sample",
|
|
107
|
+
paymentMethodStatus: PaymentMethodStatusValues.Active,
|
|
108
|
+
default: false,
|
|
109
|
+
}),
|
|
110
|
+
[ExtensionResourceTypeIdValues.Customer]: (ctx) => ({
|
|
111
|
+
id: ctx.id,
|
|
112
|
+
version: ctx.version,
|
|
113
|
+
email: SAMPLE.email,
|
|
114
|
+
firstName: "Sample",
|
|
115
|
+
lastName: "Customer",
|
|
116
|
+
authenticationMode: AuthenticationModeValues.Password,
|
|
117
|
+
addresses: [sampleAddress()],
|
|
118
|
+
}),
|
|
119
|
+
[ExtensionResourceTypeIdValues.CustomerGroup]: (ctx) => ({
|
|
120
|
+
id: ctx.id,
|
|
121
|
+
version: ctx.version,
|
|
122
|
+
key: "sample-customer-group",
|
|
123
|
+
name: "Sample customer group",
|
|
124
|
+
}),
|
|
125
|
+
[ExtensionResourceTypeIdValues.QuoteRequest]: (ctx) => ({
|
|
126
|
+
id: ctx.id,
|
|
127
|
+
version: ctx.version,
|
|
128
|
+
quoteRequestState: QuoteRequestStateValues.Submitted,
|
|
129
|
+
comment: "Sample quote request",
|
|
130
|
+
lineItems: [sampleCartLineItem()],
|
|
131
|
+
}),
|
|
132
|
+
[ExtensionResourceTypeIdValues.StagedQuote]: (ctx) => ({
|
|
133
|
+
id: ctx.id,
|
|
134
|
+
version: ctx.version,
|
|
135
|
+
stagedQuoteState: StagedQuoteStateValues.InProgress,
|
|
136
|
+
quoteRequest: {
|
|
137
|
+
typeId: ExtensionResourceTypeIdValues.QuoteRequest,
|
|
138
|
+
id: SAMPLE.quoteRequestId,
|
|
139
|
+
},
|
|
140
|
+
quotationCart: {
|
|
141
|
+
typeId: ExtensionResourceTypeIdValues.Cart,
|
|
142
|
+
id: SAMPLE.cartId,
|
|
143
|
+
},
|
|
144
|
+
}),
|
|
145
|
+
[ExtensionResourceTypeIdValues.Quote]: (ctx) => ({
|
|
146
|
+
id: ctx.id,
|
|
147
|
+
version: ctx.version,
|
|
148
|
+
quoteState: QuoteStateValues.Pending,
|
|
149
|
+
stagedQuote: {
|
|
150
|
+
typeId: ExtensionResourceTypeIdValues.StagedQuote,
|
|
151
|
+
id: SAMPLE.stagedQuoteId,
|
|
152
|
+
},
|
|
153
|
+
lineItems: [sampleCartLineItem()],
|
|
154
|
+
totalPrice: sampleMoney(),
|
|
155
|
+
}),
|
|
156
|
+
[ExtensionResourceTypeIdValues.BusinessUnit]: (ctx) => ({
|
|
157
|
+
id: ctx.id,
|
|
158
|
+
version: ctx.version,
|
|
159
|
+
key: "sample-business-unit",
|
|
160
|
+
name: "Sample business unit",
|
|
161
|
+
unitType: BusinessUnitTypeValues.Company,
|
|
162
|
+
}),
|
|
163
|
+
[ExtensionResourceTypeIdValues.ShoppingList]: (ctx) => ({
|
|
164
|
+
id: ctx.id,
|
|
165
|
+
version: ctx.version,
|
|
166
|
+
name: { en: "Sample shopping list" },
|
|
167
|
+
lineItems: [sampleShoppingListLineItem()],
|
|
168
|
+
}),
|
|
169
|
+
};
|
|
170
|
+
/** Build the expanded `resource.obj` for an API-Extension resource type. */
|
|
171
|
+
export function sampleExtensionResourceObj(resourceTypeId, ctx) {
|
|
172
|
+
const build = sampleObjBuilders[resourceTypeId];
|
|
173
|
+
if (!build) {
|
|
174
|
+
throw new Error(`no sample builder registered for resource type '${resourceTypeId}'`);
|
|
175
|
+
}
|
|
176
|
+
return build(ctx);
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=extensionInputSampleObj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensionInputSampleObj.js","sourceRoot":"","sources":["../../../src/lib/tooling/extensionInputSampleObj.ts"],"names":[],"mappings":"AACA,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,6BAA6B,EAC7B,mBAAmB,EACnB,gBAAgB,EAChB,yBAAyB,EACzB,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,aAAa,GACd,MAAM,6BAA6B,CAAC;AAUrC,MAAM,MAAM,GAAG;IACb,SAAS,EAAE,mBAAmB;IAC9B,aAAa,EAAE,wBAAwB;IACvC,UAAU,EAAE,qBAAqB;IACjC,MAAM,EAAE,gBAAgB;IACxB,GAAG,EAAE,YAAY;IACjB,QAAQ,EAAE,KAAK;IACf,KAAK,EAAE,6BAA6B;IACpC,cAAc,EAAE,yBAAyB;IACzC,aAAa,EAAE,wBAAwB;IACvC,SAAS,EAAE,0BAA0B;CAC7B,CAAC;AAEX,SAAS,WAAW,CAAC,UAAU,GAAG,IAAI;IACpC,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,YAAY,EAAE,MAAM,CAAC,QAAQ;QAC7B,UAAU;QACV,cAAc,EAAE,CAAC;KAClB,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,EAAE,GAAG,mBAAmB;IAC7C,OAAO;QACL,EAAE;QACF,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,eAAe;QAC3B,YAAY,EAAE,GAAG;QACjB,UAAU,EAAE,OAAO;KACpB,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB;IAC3B,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC;AAC9D,CAAC;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
|
|
2
|
+
/** The per-package entry the CLI expects under each `extensions/*` when nothing overrides it. */
|
|
3
|
+
export declare const DEFAULT_ENTRY_SEGMENT: string;
|
|
4
|
+
/**
|
|
5
|
+
* Reduce an `--entry` flag value to the path *within each* extension package that `--all`
|
|
6
|
+
* should build — the same source name applied uniformly across every discovered folder.
|
|
7
|
+
*
|
|
8
|
+
* The single-extension flag defaults to a cwd-absolute path (`<cwd>/src/extension.ts`),
|
|
9
|
+
* which only makes sense against N packages as its relative tail, so we relativise it to
|
|
10
|
+
* the monorepo root: the default collapses back to `src/extension.ts`, and a caller who
|
|
11
|
+
* passes a repo-relative `--entry` (e.g. `src/main.ts`) round-trips unchanged. Anything
|
|
12
|
+
* that doesn't sit under the root (an absolute path elsewhere) can't name a per-package
|
|
13
|
+
* source, so we fall back to the default rather than emit a `../…` segment.
|
|
14
|
+
*/
|
|
15
|
+
export declare function entrySegmentFor(root: string, entry: string): string;
|
|
2
16
|
/** An extension package discovered under the workspace's extensions/ directory. */
|
|
3
17
|
export interface DiscoveredExtension {
|
|
4
18
|
/** The package/directory name (used only for messages — the combined subgraph has one name). */
|
|
5
19
|
name: string;
|
|
6
|
-
/** The extension source entry (`<dir>/src/extension.ts`). */
|
|
20
|
+
/** The extension source entry (`<dir>/<entrySegment>`, e.g. `<dir>/src/extension.ts`). */
|
|
7
21
|
entry: string;
|
|
8
22
|
/** The esbuild bundle output for a standalone build (`<dir>/dist/extension.js`). */
|
|
9
23
|
outfile: string;
|
|
10
24
|
}
|
|
11
25
|
/**
|
|
12
|
-
* Discover every extension package under `<root>/<dirName>` that has
|
|
13
|
-
* `src/extension.ts
|
|
26
|
+
* Discover every extension package under `<root>/<dirName>` that has an entry at
|
|
27
|
+
* `<pkg>/<entrySegment>` (default `src/extension.ts`). Sorted by name for stable,
|
|
28
|
+
* deterministic merge output.
|
|
14
29
|
*/
|
|
15
|
-
export declare function discoverExtensions(root: string, dirName: string): Promise<DiscoveredExtension[]>;
|
|
30
|
+
export declare function discoverExtensions(root: string, dirName: string, entrySegment?: string): Promise<DiscoveredExtension[]>;
|
|
16
31
|
/** One extension's contribution to the combined subgraph. */
|
|
17
32
|
export interface ExtensionModule {
|
|
18
33
|
name: string;
|
|
@@ -65,7 +80,9 @@ export interface BundleForFlags extends CombinedBuildResult {
|
|
|
65
80
|
/**
|
|
66
81
|
* The single build step shared by `build`/`validate`/`push`: bundle either the one
|
|
67
82
|
* extension in the cwd (default) or — with `--all` — every extension under
|
|
68
|
-
* `<extensionsDir>/*` merged into the one combined bundle a project deploys.
|
|
83
|
+
* `<extensionsDir>/*` merged into the one combined bundle a project deploys. `--entry`
|
|
84
|
+
* carries over to `--all` as the per-package source segment (see {@link entrySegmentFor}),
|
|
85
|
+
* so a repo with a non-default entry name builds uniformly across every folder. Throws a
|
|
69
86
|
* clean message when `--all` finds nothing to build.
|
|
70
87
|
*/
|
|
71
88
|
export declare function bundleForFlags(opts: {
|