@tailor-platform/sdk 1.54.2 → 1.55.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/CHANGELOG.md +24 -0
- package/dist/{actor-Cjae_LGD.d.mts → actor-J2gJ0eK5.d.mts} +2 -2
- package/dist/application-DM8q9GDI.mjs +4 -0
- package/dist/{application-BfGje3iZ.mjs → application-DzUlASfA.mjs} +333 -4
- package/dist/application-DzUlASfA.mjs.map +1 -0
- package/dist/brand-DlnJ375c.mjs.map +1 -1
- package/dist/cli/index.mjs +5 -5
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +1334 -176
- package/dist/cli/lib.mjs +3 -3
- package/dist/{client-CGO7gniI.mjs → client-DLPEPJ_s.mjs} +24 -19
- package/dist/client-DLPEPJ_s.mjs.map +1 -0
- package/dist/{client-yfFdZU9s.mjs → client-DrzwCD1W.mjs} +1 -1
- package/dist/configure/index.d.mts +5 -4
- package/dist/configure/index.mjs +48 -2
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{crashreport-DGdAgX8Y.mjs → crashreport-Bm2mN5tg.mjs} +2 -2
- package/dist/{crashreport-DGdAgX8Y.mjs.map → crashreport-Bm2mN5tg.mjs.map} +1 -1
- package/dist/{crashreport-DnwIxpzF.mjs → crashreport-C5oHvHUC.mjs} +1 -1
- package/dist/{index-qQYMbkT-.d.mts → index-BE-fpxIo.d.mts} +2 -2
- package/dist/{index-BTLgs0DP.d.mts → index-BLsnrEtc.d.mts} +97 -5
- package/dist/{index-DrYHpTja.d.mts → index-D9xG-a6Y.d.mts} +2 -2
- package/dist/{index-CyyoHrPK.d.mts → index-S6-FtUpA.d.mts} +2 -2
- package/dist/{index-Cf1Lo_XT.d.mts → index-cHqh66cF.d.mts} +2 -2
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
- package/dist/plugin/builtin/seed/index.d.mts +1 -1
- package/dist/plugin/index.d.mts +2 -2
- package/dist/plugin-BuE5ZOnW.d.mts +634 -0
- package/dist/{runtime-DLFzjgEo.mjs → runtime-BZsl7Mh9.mjs} +320 -155
- package/dist/runtime-BZsl7Mh9.mjs.map +1 -0
- package/dist/{schema-CQrYG_55.mjs → schema-DKsNhbav.mjs} +5 -3
- package/dist/{schema-CQrYG_55.mjs.map → schema-DKsNhbav.mjs.map} +1 -1
- package/dist/seed-DfLyRh63.mjs.map +1 -1
- package/dist/tailordb-BlBGmQK-.d.mts +863 -0
- package/dist/utils/test/index.d.mts +3 -3
- package/dist/vitest/index.d.mts +25 -1
- package/dist/vitest/index.mjs +57 -12
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/{workflow.generated-dBixCwUo.d.mts → workflow.generated-CQg1_Ami.d.mts} +185 -8
- package/docs/services/http-adapter.md +100 -0
- package/package.json +1 -1
- package/dist/application-BfGje3iZ.mjs.map +0 -1
- package/dist/application-BsipSxp3.mjs +0 -4
- package/dist/client-CGO7gniI.mjs.map +0 -1
- package/dist/runtime-DLFzjgEo.mjs.map +0 -1
- package/dist/tailor-db-field-D0qg8s4U.d.mts +0 -1639
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
import { t as db } from "./schema-
|
|
3
|
-
import { $ as FilterSchema, A as FunctionExecution_Status, B as AuthOAuth2Client_GrantType, C as TailorDBType_Permission_Operator, D as IdPLang, E as PipelineResolver_OperationType, F as AuthConnection_Type, H as AuthSCIMAttribute_Type, I as AuthHookPoint, J as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, K as TenantProviderConfig_TenantProviderType, L as AuthIDPConfig_AuthType, M as ExecutorJobStatus, N as ExecutorTargetType, O as IdPPermissionOperator, P as ExecutorTriggerType, Q as Condition_Operator, R as AuthInvokerSchema, S as TailorDBGQLPermission_Permit, T as TailorDBType_PermitAction, U as AuthSCIMAttribute_Uniqueness, V as AuthSCIMAttribute_Mutability, W as AuthSCIMConfig_AuthorizationType, X as Subgraph_ServiceType, Y as ApplicationSchemaUpdateAttemptStatus, Z as ConditionSchema, _ as WorkspacePlatformUserRole, a as fetchMachineUserToken, b as TailorDBGQLPermission_Action, d as initOperatorClient, et as PageDirection, g as OperatorService, h as userAgent, i as fetchAll, k as IdPPermissionPermit, m as resolveStaticWebsiteUrls, o as fetchPaged, p as platformBaseUrl, q as UserProfileProviderConfig_UserProfileProviderType, v as WorkflowExecution_Status, w as TailorDBType_Permission_Permit, x as TailorDBGQLPermission_Operator, y as WorkflowJobExecution_Status, z as AuthOAuth2Client_ClientType } from "./client-
|
|
2
|
+
import { t as db } from "./schema-DKsNhbav.mjs";
|
|
3
|
+
import { $ as FilterSchema, A as FunctionExecution_Status, B as AuthOAuth2Client_GrantType, C as TailorDBType_Permission_Operator, D as IdPLang, E as PipelineResolver_OperationType, F as AuthConnection_Type, H as AuthSCIMAttribute_Type, I as AuthHookPoint, J as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, K as TenantProviderConfig_TenantProviderType, L as AuthIDPConfig_AuthType, M as ExecutorJobStatus, N as ExecutorTargetType, O as IdPPermissionOperator, P as ExecutorTriggerType, Q as Condition_Operator, R as AuthInvokerSchema, S as TailorDBGQLPermission_Permit, T as TailorDBType_PermitAction, U as AuthSCIMAttribute_Uniqueness, V as AuthSCIMAttribute_Mutability, W as AuthSCIMConfig_AuthorizationType, X as Subgraph_ServiceType, Y as ApplicationSchemaUpdateAttemptStatus, Z as ConditionSchema, _ as WorkspacePlatformUserRole, a as fetchMachineUserToken, b as TailorDBGQLPermission_Action, d as initOperatorClient, et as PageDirection, g as OperatorService, h as userAgent, i as fetchAll, k as IdPPermissionPermit, m as resolveStaticWebsiteUrls, o as fetchPaged, p as platformBaseUrl, q as UserProfileProviderConfig_UserProfileProviderType, v as WorkflowExecution_Status, w as TailorDBType_Permission_Permit, x as TailorDBGQLPermission_Operator, y as WorkflowJobExecution_Status, z as AuthOAuth2Client_ClientType } from "./client-DLPEPJ_s.mjs";
|
|
4
4
|
import { a as parseBoolean, i as symbols, n as logger, r as styles, t as CIPromptError } from "./logger-DpJyJvNz.mjs";
|
|
5
|
-
import { C as
|
|
5
|
+
import { C as loadAccessToken, E as readPlatformConfig, T as loadWorkspaceId, _ as createBundleCache, b as loadConfig, c as createExecutorService, d as buildExecutorArgsExpr, f as buildResolverOperationHookExpr, g as loadFilesWithIgnores, h as stringifyFunction, k as writePlatformConfig, m as TailorDBTypeSchema, n as generatePluginFilesIfNeeded, p as OAuth2ClientSchema, r as loadApplication, s as HTTP_METHODS, t as defineApplication, v as getDistDir, w as loadConfigPath, y as hashFile } from "./application-DzUlASfA.mjs";
|
|
6
6
|
import { t as multiline } from "./multiline-Cf9ODpr1.mjs";
|
|
7
7
|
import { t as readPackageJson } from "./package-json-DcQApfPQ.mjs";
|
|
8
8
|
import { n as isCLIError, t as createCLIError } from "./errors-EsY4XO6O.mjs";
|
|
@@ -1608,10 +1608,14 @@ function createChangeSet(title) {
|
|
|
1608
1608
|
print: () => {
|
|
1609
1609
|
if (isEmpty()) return;
|
|
1610
1610
|
logger.log(styles.bold(`${title}:`));
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1611
|
+
const printItem = (symbol, item) => {
|
|
1612
|
+
logger.log(` ${symbol} ${item.name}`);
|
|
1613
|
+
for (const detail of item.details ?? []) logger.log(` ${detail}`);
|
|
1614
|
+
};
|
|
1615
|
+
creates.forEach((item) => printItem(symbols.create, item));
|
|
1616
|
+
deletes.forEach((item) => printItem(symbols.delete, item));
|
|
1617
|
+
updates.forEach((item) => printItem(symbols.update, item));
|
|
1618
|
+
replaces.forEach((item) => printItem(symbols.replace, item));
|
|
1615
1619
|
}
|
|
1616
1620
|
};
|
|
1617
1621
|
}
|
|
@@ -1799,6 +1803,17 @@ function normalizeSubgraphs(subgraphs) {
|
|
|
1799
1803
|
return left.serviceNamespace.localeCompare(right.serviceNamespace);
|
|
1800
1804
|
});
|
|
1801
1805
|
}
|
|
1806
|
+
function normalizeHttpAdapters(httpAdapters) {
|
|
1807
|
+
return [...httpAdapters ?? []].map((adapter) => ({
|
|
1808
|
+
name: adapter.name ?? "",
|
|
1809
|
+
pathPattern: adapter.pathPattern ?? "",
|
|
1810
|
+
methods: sortStrings(adapter.methods),
|
|
1811
|
+
inputScript: adapter.inputScript ?? "",
|
|
1812
|
+
outputScript: adapter.outputScript ?? "",
|
|
1813
|
+
enabled: adapter.enabled ?? true,
|
|
1814
|
+
priority: adapter.priority ?? 0
|
|
1815
|
+
})).sort((left, right) => left.name.localeCompare(right.name));
|
|
1816
|
+
}
|
|
1802
1817
|
function toComparableApplication(input) {
|
|
1803
1818
|
return {
|
|
1804
1819
|
authNamespace: input.authNamespace,
|
|
@@ -1807,10 +1822,11 @@ function toComparableApplication(input) {
|
|
|
1807
1822
|
subgraphs: [...input.subgraphs],
|
|
1808
1823
|
allowedIpAddresses: sortStrings(input.allowedIpAddresses),
|
|
1809
1824
|
disableIntrospection: input.disableIntrospection,
|
|
1810
|
-
disabled: input.disabled
|
|
1825
|
+
disabled: input.disabled,
|
|
1826
|
+
httpAdapters: [...input.httpAdapters]
|
|
1811
1827
|
};
|
|
1812
1828
|
}
|
|
1813
|
-
function normalizeComparableApplication(application, authNamespace, authIdpConfigName, cors) {
|
|
1829
|
+
function normalizeComparableApplication(application, authNamespace, authIdpConfigName, cors, httpAdapters) {
|
|
1814
1830
|
return toComparableApplication({
|
|
1815
1831
|
authNamespace: authNamespace ?? "",
|
|
1816
1832
|
authIdpConfigName: authIdpConfigName ?? "",
|
|
@@ -1818,7 +1834,8 @@ function normalizeComparableApplication(application, authNamespace, authIdpConfi
|
|
|
1818
1834
|
subgraphs: normalizeSubgraphs(application.subgraphs.map((subgraph) => protoSubgraph(subgraph))),
|
|
1819
1835
|
allowedIpAddresses: application.config.allowedIpAddresses ?? [],
|
|
1820
1836
|
disableIntrospection: application.config.disableIntrospection ?? false,
|
|
1821
|
-
disabled: false
|
|
1837
|
+
disabled: false,
|
|
1838
|
+
httpAdapters: normalizeHttpAdapters(httpAdapters)
|
|
1822
1839
|
});
|
|
1823
1840
|
}
|
|
1824
1841
|
function normalizeComparableExistingApplication(app) {
|
|
@@ -1829,7 +1846,8 @@ function normalizeComparableExistingApplication(app) {
|
|
|
1829
1846
|
subgraphs: normalizeSubgraphs(app.subgraphs),
|
|
1830
1847
|
allowedIpAddresses: app.allowedIpAddresses,
|
|
1831
1848
|
disableIntrospection: app.disableIntrospection,
|
|
1832
|
-
disabled: app.disabled
|
|
1849
|
+
disabled: app.disabled,
|
|
1850
|
+
httpAdapters: normalizeHttpAdapters(app.httpAdapters)
|
|
1833
1851
|
});
|
|
1834
1852
|
}
|
|
1835
1853
|
function areApplicationsEqual(existing, desired) {
|
|
@@ -1838,9 +1856,10 @@ function areApplicationsEqual(existing, desired) {
|
|
|
1838
1856
|
/**
|
|
1839
1857
|
* Plan application changes based on current and desired state.
|
|
1840
1858
|
* @param context - Planning context
|
|
1859
|
+
* @param httpAdapterBuildResult - Bundled HTTP adapter scripts to embed on the Application
|
|
1841
1860
|
* @returns Planned changes
|
|
1842
1861
|
*/
|
|
1843
|
-
async function planApplication(context) {
|
|
1862
|
+
async function planApplication(context, httpAdapterBuildResult) {
|
|
1844
1863
|
const { client, workspaceId, application, forRemoval } = context;
|
|
1845
1864
|
const changeSet = createChangeSet("Applications");
|
|
1846
1865
|
const existingApplications = await fetchAll(async (pageToken, maxPageSize) => {
|
|
@@ -1902,7 +1921,8 @@ async function planApplication(context) {
|
|
|
1902
1921
|
});
|
|
1903
1922
|
const expectedLocalWebsites = new Set(application.staticWebsiteServices.map((website) => website.name));
|
|
1904
1923
|
const resolvedCors = await resolveStaticWebsiteUrls(client, workspaceId, application.config.cors, "CORS", { expectedLocalNames: expectedLocalWebsites });
|
|
1905
|
-
const
|
|
1924
|
+
const httpAdapters = buildHttpAdapters(application, httpAdapterBuildResult);
|
|
1925
|
+
const desired = normalizeComparableApplication(application, authNamespace, authIdpConfigName, resolvedCors, httpAdapters);
|
|
1906
1926
|
const request = {
|
|
1907
1927
|
workspaceId,
|
|
1908
1928
|
applicationName: application.name,
|
|
@@ -1911,7 +1931,8 @@ async function planApplication(context) {
|
|
|
1911
1931
|
cors: application.config.cors,
|
|
1912
1932
|
subgraphs: application.subgraphs.map((subgraph) => protoSubgraph(subgraph)),
|
|
1913
1933
|
allowedIpAddresses: application.config.allowedIpAddresses,
|
|
1914
|
-
disableIntrospection: application.config.disableIntrospection
|
|
1934
|
+
disableIntrospection: application.config.disableIntrospection,
|
|
1935
|
+
httpAdapters
|
|
1915
1936
|
};
|
|
1916
1937
|
const existing = existingApplications.find((app) => app.name === application.name);
|
|
1917
1938
|
if (application.id) {
|
|
@@ -1935,12 +1956,20 @@ async function planApplication(context) {
|
|
|
1935
1956
|
metaRequest
|
|
1936
1957
|
};
|
|
1937
1958
|
if (isOwnedByApp(labels, application.name, application.id) && hasMatchingSdkVersion(labels, metaRequest.labels) && areApplicationsEqual(existing, desired)) changeSet.unchanged.push(update);
|
|
1938
|
-
else
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
}
|
|
1959
|
+
else {
|
|
1960
|
+
const details = diffHttpAdapterDisplay(existing.httpAdapters, httpAdapters);
|
|
1961
|
+
if (details.length > 0) update.details = details;
|
|
1962
|
+
changeSet.updates.push(update);
|
|
1963
|
+
}
|
|
1964
|
+
} else {
|
|
1965
|
+
const details = diffHttpAdapterDisplay(void 0, httpAdapters);
|
|
1966
|
+
changeSet.creates.push({
|
|
1967
|
+
name: application.name,
|
|
1968
|
+
request,
|
|
1969
|
+
metaRequest,
|
|
1970
|
+
details: details.length > 0 ? details : void 0
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1944
1973
|
return changeSet;
|
|
1945
1974
|
}
|
|
1946
1975
|
async function fetchAppLabels(client, workspaceId, appName) {
|
|
@@ -1952,6 +1981,59 @@ async function fetchAppLabels(client, workspaceId, appName) {
|
|
|
1952
1981
|
throw error;
|
|
1953
1982
|
}
|
|
1954
1983
|
}
|
|
1984
|
+
/**
|
|
1985
|
+
* Build per-adapter diff lines for the application plan display. The platform
|
|
1986
|
+
* models HTTP adapters as an embedded Application field (no dedicated RPC), so
|
|
1987
|
+
* adapter changes surface as an Application update; these lines show which
|
|
1988
|
+
* adapter actually changed instead of just `~ <app>`.
|
|
1989
|
+
* @param existingAdapters - HTTP adapters currently deployed on the application
|
|
1990
|
+
* @param desiredAdapters - HTTP adapters built from the local config
|
|
1991
|
+
* @returns Indented diff lines (`+`/`~`/`-` per adapter), sorted by name
|
|
1992
|
+
*/
|
|
1993
|
+
function diffHttpAdapterDisplay(existingAdapters, desiredAdapters) {
|
|
1994
|
+
const existingByName = new Map((existingAdapters ?? []).map((a) => [a.name ?? "", a]));
|
|
1995
|
+
const desiredByName = new Map(desiredAdapters.map((a) => [a.name ?? "", a]));
|
|
1996
|
+
const entries = [];
|
|
1997
|
+
for (const [name, desired] of desiredByName) {
|
|
1998
|
+
const existing = existingByName.get(name);
|
|
1999
|
+
if (!existing) entries.push({
|
|
2000
|
+
name,
|
|
2001
|
+
symbol: symbols.create
|
|
2002
|
+
});
|
|
2003
|
+
else if (!areNormalizedEqual(normalizeHttpAdapters([existing])[0], normalizeHttpAdapters([desired])[0])) entries.push({
|
|
2004
|
+
name,
|
|
2005
|
+
symbol: symbols.update
|
|
2006
|
+
});
|
|
2007
|
+
}
|
|
2008
|
+
for (const name of existingByName.keys()) if (!desiredByName.has(name)) entries.push({
|
|
2009
|
+
name,
|
|
2010
|
+
symbol: symbols.delete
|
|
2011
|
+
});
|
|
2012
|
+
return entries.sort((left, right) => left.name.localeCompare(right.name)).map((entry) => `${entry.symbol} ${entry.name} (httpAdapter)`);
|
|
2013
|
+
}
|
|
2014
|
+
function buildHttpAdapters(application, httpAdapterBuildResult) {
|
|
2015
|
+
const adapters = application.httpAdapterService?.adapters ?? [];
|
|
2016
|
+
if (adapters.length === 0) return [];
|
|
2017
|
+
return adapters.map((loaded) => {
|
|
2018
|
+
const inputScript = httpAdapterBuildResult?.bundledInputs.get(loaded.adapter.name);
|
|
2019
|
+
if (!inputScript) throw new Error(`HTTP adapter "${loaded.adapter.name}" was loaded but no bundled input script is available`);
|
|
2020
|
+
let outputScript = "";
|
|
2021
|
+
if (loaded.hasOutput) {
|
|
2022
|
+
const bundled = httpAdapterBuildResult?.bundledOutputs.get(loaded.adapter.name);
|
|
2023
|
+
if (!bundled) throw new Error(`HTTP adapter "${loaded.adapter.name}" declares an output handler but no bundled output script is available`);
|
|
2024
|
+
outputScript = bundled;
|
|
2025
|
+
}
|
|
2026
|
+
return {
|
|
2027
|
+
name: loaded.adapter.name,
|
|
2028
|
+
pathPattern: loaded.adapter.pathPattern,
|
|
2029
|
+
methods: loaded.methods.map((m) => HTTP_METHODS[m]),
|
|
2030
|
+
inputScript,
|
|
2031
|
+
outputScript,
|
|
2032
|
+
enabled: loaded.adapter.enabled,
|
|
2033
|
+
priority: loaded.adapter.priority
|
|
2034
|
+
};
|
|
2035
|
+
});
|
|
2036
|
+
}
|
|
1955
2037
|
function protoSubgraph(subgraph) {
|
|
1956
2038
|
let serviceType;
|
|
1957
2039
|
switch (subgraph.Type) {
|
|
@@ -4732,6 +4814,88 @@ function normalizeAuthInvoker(authInvoker, authNamespace, context) {
|
|
|
4732
4814
|
return authInvoker;
|
|
4733
4815
|
}
|
|
4734
4816
|
|
|
4817
|
+
//#endregion
|
|
4818
|
+
//#region src/cli/commands/deploy/owned-resource.ts
|
|
4819
|
+
/**
|
|
4820
|
+
* Fetch a workspace-scoped resource list and attach SDK ownership metadata.
|
|
4821
|
+
* @template T
|
|
4822
|
+
* @param params - Resource fetch parameters
|
|
4823
|
+
* @param params.client - Operator client instance
|
|
4824
|
+
* @param params.workspaceId - Workspace ID
|
|
4825
|
+
* @param params.fetchPage - Function that fetches one resource page
|
|
4826
|
+
* @param params.getName - Function that extracts the resource name
|
|
4827
|
+
* @param params.getTrn - Function that builds the resource TRN
|
|
4828
|
+
* @returns Existing resources keyed by resource name, with SDK labels attached
|
|
4829
|
+
*/
|
|
4830
|
+
async function fetchExistingResourcesWithLabels(params) {
|
|
4831
|
+
const { client, workspaceId, fetchPage, getName, getTrn } = params;
|
|
4832
|
+
const withoutLabel = await fetchAll(async (pageToken, maxPageSize) => {
|
|
4833
|
+
try {
|
|
4834
|
+
return await fetchPage(pageToken, maxPageSize);
|
|
4835
|
+
} catch (error) {
|
|
4836
|
+
if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
|
|
4837
|
+
throw error;
|
|
4838
|
+
}
|
|
4839
|
+
});
|
|
4840
|
+
const existingResources = {};
|
|
4841
|
+
await Promise.all(withoutLabel.map(async (resource) => {
|
|
4842
|
+
const name = getName(resource);
|
|
4843
|
+
if (!name) return;
|
|
4844
|
+
const { metadata } = await client.getMetadata({ trn: getTrn(workspaceId, name) });
|
|
4845
|
+
existingResources[name] = {
|
|
4846
|
+
resource,
|
|
4847
|
+
label: metadata?.labels[sdkNameLabelKey],
|
|
4848
|
+
allLabels: metadata?.labels
|
|
4849
|
+
};
|
|
4850
|
+
}));
|
|
4851
|
+
return existingResources;
|
|
4852
|
+
}
|
|
4853
|
+
/**
|
|
4854
|
+
* Determine whether a same-named existing resource is managed by this app.
|
|
4855
|
+
* Records the user-facing confirmation data when ownership does not match.
|
|
4856
|
+
* @param params - Ownership classification inputs
|
|
4857
|
+
* @param params.labels - Existing resource labels
|
|
4858
|
+
* @param params.ownerLabel - Existing `sdk-name` label, when present
|
|
4859
|
+
* @param params.appName - Current application name
|
|
4860
|
+
* @param params.appId - Current application id, when present
|
|
4861
|
+
* @param params.resourceType - Resource kind for confirmation messages
|
|
4862
|
+
* @param params.resourceName - Resource name for confirmation messages
|
|
4863
|
+
* @param params.conflicts - Conflict accumulator
|
|
4864
|
+
* @param params.unmanaged - Unmanaged-resource accumulator
|
|
4865
|
+
* @returns True when the resource is owned by the current app
|
|
4866
|
+
*/
|
|
4867
|
+
function trackDesiredResourceOwnership(params) {
|
|
4868
|
+
const { labels, ownerLabel, appName, appId, resourceType, resourceName, conflicts, unmanaged } = params;
|
|
4869
|
+
const owned = isOwnedByApp(labels, appName, appId);
|
|
4870
|
+
if (!owned) if (!ownerLabel) unmanaged.push({
|
|
4871
|
+
resourceType,
|
|
4872
|
+
resourceName
|
|
4873
|
+
});
|
|
4874
|
+
else conflicts.push({
|
|
4875
|
+
resourceType,
|
|
4876
|
+
resourceName,
|
|
4877
|
+
currentOwner: ownerLabel
|
|
4878
|
+
});
|
|
4879
|
+
return owned;
|
|
4880
|
+
}
|
|
4881
|
+
/**
|
|
4882
|
+
* Determine whether a remote-only resource is still owned by this app.
|
|
4883
|
+
* Also records other SDK owners so renamed-empty applications can be handled.
|
|
4884
|
+
* @param params - Ownership classification inputs
|
|
4885
|
+
* @param params.labels - Existing resource labels
|
|
4886
|
+
* @param params.ownerLabel - Existing `sdk-name` label, when present
|
|
4887
|
+
* @param params.appName - Current application name
|
|
4888
|
+
* @param params.appId - Current application id, when present
|
|
4889
|
+
* @param params.resourceOwners - Other-owner accumulator
|
|
4890
|
+
* @returns True when the resource is owned by the current app
|
|
4891
|
+
*/
|
|
4892
|
+
function trackRemainingResourceOwner(params) {
|
|
4893
|
+
const { labels, ownerLabel, appName, appId, resourceOwners } = params;
|
|
4894
|
+
const owned = isOwnedByApp(labels, appName, appId);
|
|
4895
|
+
if (ownerLabel && !owned) resourceOwners.add(ownerLabel);
|
|
4896
|
+
return owned;
|
|
4897
|
+
}
|
|
4898
|
+
|
|
4735
4899
|
//#endregion
|
|
4736
4900
|
//#region src/cli/commands/deploy/executor.ts
|
|
4737
4901
|
/**
|
|
@@ -4766,28 +4930,20 @@ async function planExecutor(context) {
|
|
|
4766
4930
|
const conflicts = [];
|
|
4767
4931
|
const unmanaged = [];
|
|
4768
4932
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
4769
|
-
const
|
|
4770
|
-
|
|
4933
|
+
const existingExecutors = await fetchExistingResourcesWithLabels({
|
|
4934
|
+
client,
|
|
4935
|
+
workspaceId,
|
|
4936
|
+
fetchPage: async (pageToken, pageSize) => {
|
|
4771
4937
|
const { executors, nextPageToken } = await client.listExecutorExecutors({
|
|
4772
4938
|
workspaceId,
|
|
4773
4939
|
pageToken,
|
|
4774
|
-
pageSize
|
|
4940
|
+
pageSize
|
|
4775
4941
|
});
|
|
4776
4942
|
return [executors, nextPageToken];
|
|
4777
|
-
}
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
}
|
|
4943
|
+
},
|
|
4944
|
+
getName: (resource) => resource.name,
|
|
4945
|
+
getTrn: trn$3
|
|
4781
4946
|
});
|
|
4782
|
-
const existingExecutors = {};
|
|
4783
|
-
await Promise.all(withoutLabel.map(async (resource) => {
|
|
4784
|
-
const { metadata } = await client.getMetadata({ trn: trn$3(workspaceId, resource.name) });
|
|
4785
|
-
existingExecutors[resource.name] = {
|
|
4786
|
-
resource,
|
|
4787
|
-
label: metadata?.labels[sdkNameLabelKey],
|
|
4788
|
-
allLabels: metadata?.labels
|
|
4789
|
-
};
|
|
4790
|
-
}));
|
|
4791
4947
|
const executors = forRemoval ? {} : await application.executorService?.loadExecutors() ?? {};
|
|
4792
4948
|
for (const executor of Object.values(executors)) {
|
|
4793
4949
|
const existing = existingExecutors[executor.name];
|
|
@@ -4798,17 +4954,16 @@ async function planExecutor(context) {
|
|
|
4798
4954
|
});
|
|
4799
4955
|
const desiredExecutor = protoExecutor(application, executor);
|
|
4800
4956
|
if (existing) {
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
else conflicts.push({
|
|
4957
|
+
if (trackDesiredResourceOwnership({
|
|
4958
|
+
labels: existing.allLabels,
|
|
4959
|
+
ownerLabel: existing.label,
|
|
4960
|
+
appName: application.name,
|
|
4961
|
+
appId: application.id,
|
|
4807
4962
|
resourceType: "Executor",
|
|
4808
4963
|
resourceName: executor.name,
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4964
|
+
conflicts,
|
|
4965
|
+
unmanaged
|
|
4966
|
+
}) && hasMatchingSdkVersion(existing.allLabels, metaRequest.labels) && areExecutorsEqual(existing.resource, desiredExecutor)) changeSet.unchanged.push({ name: executor.name });
|
|
4812
4967
|
else changeSet.updates.push({
|
|
4813
4968
|
name: executor.name,
|
|
4814
4969
|
request: {
|
|
@@ -4830,9 +4985,13 @@ async function planExecutor(context) {
|
|
|
4830
4985
|
Object.entries(existingExecutors).forEach(([name]) => {
|
|
4831
4986
|
const entry = existingExecutors[name];
|
|
4832
4987
|
const label = entry?.label;
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4988
|
+
if (trackRemainingResourceOwner({
|
|
4989
|
+
labels: entry?.allLabels,
|
|
4990
|
+
ownerLabel: label,
|
|
4991
|
+
appName: application.name,
|
|
4992
|
+
appId: application.id,
|
|
4993
|
+
resourceOwners
|
|
4994
|
+
})) changeSet.deletes.push({
|
|
4836
4995
|
name,
|
|
4837
4996
|
request: {
|
|
4838
4997
|
workspaceId,
|
|
@@ -5779,28 +5938,20 @@ async function planStaticWebsite(context) {
|
|
|
5779
5938
|
const conflicts = [];
|
|
5780
5939
|
const unmanaged = [];
|
|
5781
5940
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
5782
|
-
const
|
|
5783
|
-
|
|
5941
|
+
const existingWebsites = await fetchExistingResourcesWithLabels({
|
|
5942
|
+
client,
|
|
5943
|
+
workspaceId,
|
|
5944
|
+
fetchPage: async (pageToken, pageSize) => {
|
|
5784
5945
|
const { staticwebsites, nextPageToken } = await client.listStaticWebsites({
|
|
5785
5946
|
workspaceId,
|
|
5786
5947
|
pageToken,
|
|
5787
|
-
pageSize
|
|
5948
|
+
pageSize
|
|
5788
5949
|
});
|
|
5789
5950
|
return [staticwebsites, nextPageToken];
|
|
5790
|
-
}
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
}
|
|
5951
|
+
},
|
|
5952
|
+
getName: (resource) => resource.name,
|
|
5953
|
+
getTrn: trn$1
|
|
5794
5954
|
});
|
|
5795
|
-
const existingWebsites = {};
|
|
5796
|
-
await Promise.all(withoutLabel.map(async (resource) => {
|
|
5797
|
-
const { metadata } = await client.getMetadata({ trn: trn$1(workspaceId, resource.name) });
|
|
5798
|
-
existingWebsites[resource.name] = {
|
|
5799
|
-
resource,
|
|
5800
|
-
label: metadata?.labels[sdkNameLabelKey],
|
|
5801
|
-
allLabels: metadata?.labels
|
|
5802
|
-
};
|
|
5803
|
-
}));
|
|
5804
5955
|
const staticWebsiteServices = forRemoval ? [] : application.staticWebsiteServices;
|
|
5805
5956
|
for (const websiteService of staticWebsiteServices) {
|
|
5806
5957
|
const config = websiteService;
|
|
@@ -5821,17 +5972,16 @@ async function planStaticWebsite(context) {
|
|
|
5821
5972
|
}
|
|
5822
5973
|
};
|
|
5823
5974
|
if (existing) {
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
else conflicts.push({
|
|
5975
|
+
if (trackDesiredResourceOwnership({
|
|
5976
|
+
labels: existing.allLabels,
|
|
5977
|
+
ownerLabel: existing.label,
|
|
5978
|
+
appName: application.name,
|
|
5979
|
+
appId: application.id,
|
|
5830
5980
|
resourceType: "StaticWebsite",
|
|
5831
5981
|
resourceName: name,
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5982
|
+
conflicts,
|
|
5983
|
+
unmanaged
|
|
5984
|
+
}) && hasMatchingSdkVersion(existing.allLabels, metaRequest.labels) && areStaticWebsitesEqual(existing.resource, desired)) changeSet.unchanged.push({ name });
|
|
5835
5985
|
else changeSet.updates.push({
|
|
5836
5986
|
name,
|
|
5837
5987
|
request,
|
|
@@ -5847,9 +5997,13 @@ async function planStaticWebsite(context) {
|
|
|
5847
5997
|
Object.entries(existingWebsites).forEach(([name]) => {
|
|
5848
5998
|
const entry = existingWebsites[name];
|
|
5849
5999
|
const label = entry?.label;
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
6000
|
+
if (trackRemainingResourceOwner({
|
|
6001
|
+
labels: entry?.allLabels,
|
|
6002
|
+
ownerLabel: label,
|
|
6003
|
+
appName: application.name,
|
|
6004
|
+
appId: application.id,
|
|
6005
|
+
resourceOwners
|
|
6006
|
+
})) changeSet.deletes.push({
|
|
5853
6007
|
name,
|
|
5854
6008
|
request: {
|
|
5855
6009
|
workspaceId,
|
|
@@ -5939,19 +6093,11 @@ function formatDiffChange(change) {
|
|
|
5939
6093
|
case "type_removed": return ` - [Type] ${change.typeName} (removed)`;
|
|
5940
6094
|
case "type_modified": return ` ~ [Type] ${change.typeName}: ${change.reason}`;
|
|
5941
6095
|
case "field_added": {
|
|
5942
|
-
const
|
|
5943
|
-
const typeStr = formatFieldType(field);
|
|
6096
|
+
const typeStr = formatFieldType(change.after);
|
|
5944
6097
|
return ` + ${change.fieldName}: ${typeStr}`;
|
|
5945
6098
|
}
|
|
5946
|
-
case "field_removed": {
|
|
5947
|
-
|
|
5948
|
-
return ` - ${change.fieldName}: ${field.type}`;
|
|
5949
|
-
}
|
|
5950
|
-
case "field_modified": {
|
|
5951
|
-
const before = change.before;
|
|
5952
|
-
const after = change.after;
|
|
5953
|
-
return ` ~ ${change.fieldName}: ${formatFieldModification(before, after)}`;
|
|
5954
|
-
}
|
|
6099
|
+
case "field_removed": return ` - ${change.fieldName}: ${change.before.type}`;
|
|
6100
|
+
case "field_modified": return ` ~ ${change.fieldName}: ${formatFieldModification(change.before, change.after)}`;
|
|
5955
6101
|
case "index_added": return ` + [Index] ${change.indexName}`;
|
|
5956
6102
|
case "index_removed": return ` - [Index] ${change.indexName}`;
|
|
5957
6103
|
case "index_modified": return ` ~ [Index] ${change.indexName}: ${change.reason ?? "modified"}`;
|
|
@@ -5962,7 +6108,10 @@ function formatDiffChange(change) {
|
|
|
5962
6108
|
case "relationship_removed": return ` - [Relationship${change.relationshipType ? ` (${change.relationshipType})` : ""}] ${change.relationshipName}`;
|
|
5963
6109
|
case "relationship_modified": return ` ~ [Relationship${change.relationshipType ? ` (${change.relationshipType})` : ""}] ${change.relationshipName}: ${change.reason ?? "modified"}`;
|
|
5964
6110
|
case "permission_modified": return ` ~ [Permission] ${change.reason ?? "modified"}`;
|
|
5965
|
-
default:
|
|
6111
|
+
default: {
|
|
6112
|
+
const unknown = change;
|
|
6113
|
+
return ` ? ${unknown.typeName}.${unknown.fieldName ?? ""}`;
|
|
6114
|
+
}
|
|
5966
6115
|
}
|
|
5967
6116
|
}
|
|
5968
6117
|
/**
|
|
@@ -6066,6 +6215,28 @@ function formatDiffSummary(diff) {
|
|
|
6066
6215
|
return parts.length > 0 ? parts.join(", ") : "No changes";
|
|
6067
6216
|
}
|
|
6068
6217
|
|
|
6218
|
+
//#endregion
|
|
6219
|
+
//#region src/cli/commands/tailordb/migrate/migration-number.ts
|
|
6220
|
+
/**
|
|
6221
|
+
* Format migration number as 4-digit string.
|
|
6222
|
+
* @param num - Migration number
|
|
6223
|
+
* @returns 4-digit padded string
|
|
6224
|
+
*/
|
|
6225
|
+
function formatMigrationNumber(num) {
|
|
6226
|
+
return num.toString().padStart(4, "0");
|
|
6227
|
+
}
|
|
6228
|
+
|
|
6229
|
+
//#endregion
|
|
6230
|
+
//#region src/cli/commands/tailordb/migrate/snapshot-types.ts
|
|
6231
|
+
/**
|
|
6232
|
+
* Type guard: is the operand a field-reference (object) operand?
|
|
6233
|
+
* @param {SnapshotPermissionOperand} operand - Operand to test
|
|
6234
|
+
* @returns {boolean} True if operand is a field-ref (not a value operand)
|
|
6235
|
+
*/
|
|
6236
|
+
function isSnapshotFieldRefOperand(operand) {
|
|
6237
|
+
return typeof operand === "object" && operand !== null && !Array.isArray(operand);
|
|
6238
|
+
}
|
|
6239
|
+
|
|
6069
6240
|
//#endregion
|
|
6070
6241
|
//#region src/cli/commands/tailordb/migrate/snapshot.ts
|
|
6071
6242
|
/**
|
|
@@ -6121,14 +6292,6 @@ function normalizeSnapshotType(type) {
|
|
|
6121
6292
|
for (const field of Object.values(type.fields)) normalizeSnapshotField(field);
|
|
6122
6293
|
}
|
|
6123
6294
|
/**
|
|
6124
|
-
* Type guard: is the operand a field-reference (object) operand?
|
|
6125
|
-
* @param {SnapshotPermissionOperand} operand - Operand to test
|
|
6126
|
-
* @returns {boolean} True if operand is a field-ref (not a value operand)
|
|
6127
|
-
*/
|
|
6128
|
-
function isSnapshotFieldRefOperand(operand) {
|
|
6129
|
-
return typeof operand === "object" && operand !== null && !Array.isArray(operand);
|
|
6130
|
-
}
|
|
6131
|
-
/**
|
|
6132
6295
|
* Validate that a migration number follows the expected format (4-digit number)
|
|
6133
6296
|
* @param {string} numberStr - Migration number string to validate
|
|
6134
6297
|
* @returns {boolean} True if number matches expected format
|
|
@@ -6137,14 +6300,6 @@ function isValidMigrationNumber(numberStr) {
|
|
|
6137
6300
|
return MIGRATION_NUMBER_PATTERN.test(numberStr);
|
|
6138
6301
|
}
|
|
6139
6302
|
/**
|
|
6140
|
-
* Format migration number as 4-digit string
|
|
6141
|
-
* @param {number} num - Migration number
|
|
6142
|
-
* @returns {string} 4-digit padded string (e.g., "0001")
|
|
6143
|
-
*/
|
|
6144
|
-
function formatMigrationNumber(num) {
|
|
6145
|
-
return num.toString().padStart(4, "0");
|
|
6146
|
-
}
|
|
6147
|
-
/**
|
|
6148
6303
|
* Map of migration file types to their file names
|
|
6149
6304
|
*/
|
|
6150
6305
|
const MIGRATION_FILE_NAMES = {
|
|
@@ -7359,6 +7514,15 @@ const PRE_MIGRATION_FIELD_KINDS = new Set([
|
|
|
7359
7514
|
"field_removed"
|
|
7360
7515
|
]);
|
|
7361
7516
|
/**
|
|
7517
|
+
* Type guard: is the change a field-level change that needs pre-migration
|
|
7518
|
+
* schema adjustment?
|
|
7519
|
+
* @param {DiffChange} change - Diff change to test
|
|
7520
|
+
* @returns {boolean} True if the change is a field-level change
|
|
7521
|
+
*/
|
|
7522
|
+
function isPreMigrationFieldChange(change) {
|
|
7523
|
+
return PRE_MIGRATION_FIELD_KINDS.has(change.kind);
|
|
7524
|
+
}
|
|
7525
|
+
/**
|
|
7362
7526
|
* Build a map of field changes that require pre-migration schema adjustment.
|
|
7363
7527
|
* @param {PendingMigration[]} pendingMigrations - Pending migrations to scan
|
|
7364
7528
|
* @returns {PreMigrationChangesMap} Map of changes keyed by typeName/fieldName
|
|
@@ -7366,7 +7530,7 @@ const PRE_MIGRATION_FIELD_KINDS = new Set([
|
|
|
7366
7530
|
function buildPreMigrationChangesMap(pendingMigrations) {
|
|
7367
7531
|
const map = /* @__PURE__ */ new Map();
|
|
7368
7532
|
for (const migration of pendingMigrations) for (const change of migration.diff.changes) {
|
|
7369
|
-
if (!
|
|
7533
|
+
if (!isPreMigrationFieldChange(change)) continue;
|
|
7370
7534
|
if (!change.fieldName) continue;
|
|
7371
7535
|
const perType = map.get(change.typeName) ?? /* @__PURE__ */ new Map();
|
|
7372
7536
|
perType.set(change.fieldName, change);
|
|
@@ -7385,24 +7549,21 @@ function buildPreMigrationChangesMap(pendingMigrations) {
|
|
|
7385
7549
|
* - Modified fields keep the looser side of unique/required/enum.
|
|
7386
7550
|
*
|
|
7387
7551
|
* @param {Record<string, MessageInitShape<typeof TailorDBType_FieldConfigSchema>>} fields - Field map to adjust (mutated in place)
|
|
7388
|
-
* @param {Map<string,
|
|
7552
|
+
* @param {Map<string, FieldDiffChange>} typeChanges - Changes for this type, keyed by fieldName
|
|
7389
7553
|
*/
|
|
7390
7554
|
function applyPreMigrationFieldAdjustments(fields, typeChanges) {
|
|
7391
7555
|
for (const [fieldName, change] of typeChanges) {
|
|
7392
7556
|
if (change.kind === "field_removed") {
|
|
7393
|
-
|
|
7394
|
-
if (before) fields[fieldName] = convertFieldConfigToProto(before);
|
|
7557
|
+
if (change.before) fields[fieldName] = convertFieldConfigToProto(change.before);
|
|
7395
7558
|
continue;
|
|
7396
7559
|
}
|
|
7397
7560
|
const field = fields[fieldName];
|
|
7398
7561
|
if (!field) continue;
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
if (change.kind === "field_added" && after?.required) {
|
|
7402
|
-
field.required = false;
|
|
7562
|
+
if (change.kind === "field_added") {
|
|
7563
|
+
if (change.after?.required) field.required = false;
|
|
7403
7564
|
continue;
|
|
7404
7565
|
}
|
|
7405
|
-
|
|
7566
|
+
const { before, after } = change;
|
|
7406
7567
|
if (!before?.required && after?.required) field.required = false;
|
|
7407
7568
|
if (!(before?.unique ?? false) && (after?.unique ?? false)) field.unique = false;
|
|
7408
7569
|
if (before?.allowedValues && after?.allowedValues) {
|
|
@@ -9403,23 +9564,20 @@ async function planWorkflow(client, workspaceId, appName, appId, workflows, main
|
|
|
9403
9564
|
const unmanaged = [];
|
|
9404
9565
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
9405
9566
|
const unchangedWorkflowJobNames = /* @__PURE__ */ new Set();
|
|
9406
|
-
const
|
|
9407
|
-
|
|
9408
|
-
|
|
9409
|
-
|
|
9410
|
-
|
|
9411
|
-
|
|
9412
|
-
|
|
9567
|
+
const existingWorkflows = await fetchExistingResourcesWithLabels({
|
|
9568
|
+
client,
|
|
9569
|
+
workspaceId,
|
|
9570
|
+
fetchPage: async (pageToken, pageSize) => {
|
|
9571
|
+
const response = await client.listWorkflows({
|
|
9572
|
+
workspaceId,
|
|
9573
|
+
pageToken,
|
|
9574
|
+
pageSize
|
|
9575
|
+
});
|
|
9576
|
+
return [response.workflows, response.nextPageToken];
|
|
9577
|
+
},
|
|
9578
|
+
getName: (resource) => resource.name,
|
|
9579
|
+
getTrn: workflowTrn$1
|
|
9413
9580
|
});
|
|
9414
|
-
const existingWorkflows = {};
|
|
9415
|
-
await Promise.all(withoutLabel.map(async (resource) => {
|
|
9416
|
-
const { metadata } = await client.getMetadata({ trn: workflowTrn$1(workspaceId, resource.name) });
|
|
9417
|
-
existingWorkflows[resource.name] = {
|
|
9418
|
-
resource,
|
|
9419
|
-
label: metadata?.labels[sdkNameLabelKey],
|
|
9420
|
-
allLabels: metadata?.labels
|
|
9421
|
-
};
|
|
9422
|
-
}));
|
|
9423
9581
|
for (const workflow of Object.values(workflows)) {
|
|
9424
9582
|
const existing = existingWorkflows[workflow.name];
|
|
9425
9583
|
const metaRequest = await buildMetaRequest({
|
|
@@ -9430,17 +9588,16 @@ async function planWorkflow(client, workspaceId, appName, appId, workflows, main
|
|
|
9430
9588
|
const usedJobNames = mainJobDeps[workflow.mainJob.name];
|
|
9431
9589
|
if (!usedJobNames) throw new Error(`Job "${workflow.mainJob.name}" (mainJob of workflow "${workflow.name}") was not found.\n\nPossible causes:\n - The job is not exported as a named export\n - The file containing the job is not included in workflow.files glob pattern\n\nSolution:\n export const ${workflow.mainJob.name} = createWorkflowJob({ name: "${workflow.mainJob.name}", ... })`);
|
|
9432
9590
|
if (existing) {
|
|
9433
|
-
|
|
9434
|
-
|
|
9435
|
-
|
|
9436
|
-
|
|
9437
|
-
|
|
9438
|
-
else conflicts.push({
|
|
9591
|
+
if (trackDesiredResourceOwnership({
|
|
9592
|
+
labels: existing.allLabels,
|
|
9593
|
+
ownerLabel: existing.label,
|
|
9594
|
+
appName,
|
|
9595
|
+
appId,
|
|
9439
9596
|
resourceType: "Workflow",
|
|
9440
9597
|
resourceName: workflow.name,
|
|
9441
|
-
|
|
9442
|
-
|
|
9443
|
-
|
|
9598
|
+
conflicts,
|
|
9599
|
+
unmanaged
|
|
9600
|
+
}) && hasMatchingSdkVersion(existing.allLabels, metaRequest.labels) && canTreatWorkflowAsUnchanged(existing.resource, workflow, usedJobNames, unchangedJobFunctions)) {
|
|
9444
9601
|
changeSet.unchanged.push({ name: workflow.name });
|
|
9445
9602
|
for (const jobName of usedJobNames) unchangedWorkflowJobNames.add(jobName);
|
|
9446
9603
|
} else changeSet.updates.push({
|
|
@@ -9461,10 +9618,13 @@ async function planWorkflow(client, workspaceId, appName, appId, workflows, main
|
|
|
9461
9618
|
}
|
|
9462
9619
|
Object.values(existingWorkflows).forEach((existing) => {
|
|
9463
9620
|
if (!existing) return;
|
|
9464
|
-
|
|
9465
|
-
|
|
9466
|
-
|
|
9467
|
-
|
|
9621
|
+
if (trackRemainingResourceOwner({
|
|
9622
|
+
labels: existing.allLabels,
|
|
9623
|
+
ownerLabel: existing.label,
|
|
9624
|
+
appName,
|
|
9625
|
+
appId,
|
|
9626
|
+
resourceOwners
|
|
9627
|
+
})) changeSet.deletes.push({
|
|
9468
9628
|
name: existing.resource.name,
|
|
9469
9629
|
workspaceId,
|
|
9470
9630
|
workflowId: existing.resource.id,
|
|
@@ -9754,7 +9914,7 @@ function summarizePlanResults(results, displayEntries, serviceActions) {
|
|
|
9754
9914
|
async function deploy(options) {
|
|
9755
9915
|
return withSpan("deploy", async (rootSpan) => {
|
|
9756
9916
|
rootSpan.setAttribute("deploy.dry_run", options?.dryRun ?? false);
|
|
9757
|
-
const { config, application, workflowBuildResult, bundledScripts, buildOnly } = await withSpan("build", async () => {
|
|
9917
|
+
const { config, application, workflowBuildResult, httpAdapterBuildResult, bundledScripts, buildOnly } = await withSpan("build", async () => {
|
|
9758
9918
|
const dryRun = options?.dryRun ?? false;
|
|
9759
9919
|
const buildOnly = options?.buildOnly ?? parseBoolean(process.env.TAILOR_PLATFORM_SDK_BUILD_ONLY) === true;
|
|
9760
9920
|
const { config, plugins } = await withSpan("build.loadConfig", async () => {
|
|
@@ -9791,6 +9951,7 @@ async function deploy(options) {
|
|
|
9791
9951
|
}));
|
|
9792
9952
|
let application;
|
|
9793
9953
|
let workflowBuildResult;
|
|
9954
|
+
let httpAdapterBuildResult;
|
|
9794
9955
|
let bundledScripts;
|
|
9795
9956
|
try {
|
|
9796
9957
|
const result = await withSpan("build.loadApplication", () => loadApplication({
|
|
@@ -9800,6 +9961,7 @@ async function deploy(options) {
|
|
|
9800
9961
|
}));
|
|
9801
9962
|
application = result.application;
|
|
9802
9963
|
workflowBuildResult = result.workflowBuildResult;
|
|
9964
|
+
httpAdapterBuildResult = result.httpAdapterBuildResult;
|
|
9803
9965
|
bundledScripts = result.bundledScripts;
|
|
9804
9966
|
} finally {
|
|
9805
9967
|
cacheManager.finalize();
|
|
@@ -9809,6 +9971,7 @@ async function deploy(options) {
|
|
|
9809
9971
|
plugins,
|
|
9810
9972
|
application,
|
|
9811
9973
|
workflowBuildResult,
|
|
9974
|
+
httpAdapterBuildResult,
|
|
9812
9975
|
bundledScripts,
|
|
9813
9976
|
dryRun,
|
|
9814
9977
|
buildOnly
|
|
@@ -9850,7 +10013,7 @@ async function deploy(options) {
|
|
|
9850
10013
|
withSpan("plan.idp", () => planIdP(ctx)),
|
|
9851
10014
|
withSpan("plan.auth", () => planAuth(ctx)),
|
|
9852
10015
|
withSpan("plan.pipeline", () => planPipeline(ctx)),
|
|
9853
|
-
withSpan("plan.application", () => planApplication(ctx)),
|
|
10016
|
+
withSpan("plan.application", () => planApplication(ctx, httpAdapterBuildResult)),
|
|
9854
10017
|
withSpan("plan.executor", () => planExecutor(ctx)),
|
|
9855
10018
|
withSpan("plan.workflow", () => planWorkflow(client, workspaceId, application.name, application.id, workflowService?.workflows ?? {}, workflowBuildResult?.mainJobDeps ?? {}, unchangedWorkflowJobs)),
|
|
9856
10019
|
withSpan("plan.secretManager", () => planSecretManager(ctx))
|
|
@@ -13752,8 +13915,7 @@ function extractBreakingChangeFields(diff) {
|
|
|
13752
13915
|
const addedRequiredFields = /* @__PURE__ */ new Map();
|
|
13753
13916
|
const enumValueChanges = /* @__PURE__ */ new Map();
|
|
13754
13917
|
for (const change of diff.changes) if (change.kind === "field_modified" && change.fieldName) {
|
|
13755
|
-
const before = change
|
|
13756
|
-
const after = change.after;
|
|
13918
|
+
const { before, after } = change;
|
|
13757
13919
|
if (before && after && !before.required && after.required) {
|
|
13758
13920
|
if (!optionalToRequired.has(change.typeName)) optionalToRequired.set(change.typeName, /* @__PURE__ */ new Set());
|
|
13759
13921
|
optionalToRequired.get(change.typeName).add(change.fieldName);
|
|
@@ -13772,7 +13934,7 @@ function extractBreakingChangeFields(diff) {
|
|
|
13772
13934
|
}
|
|
13773
13935
|
}
|
|
13774
13936
|
} else if (change.kind === "field_added" && change.fieldName) {
|
|
13775
|
-
const after = change
|
|
13937
|
+
const { after } = change;
|
|
13776
13938
|
if (after && after.required) {
|
|
13777
13939
|
if (!addedRequiredFields.has(change.typeName)) addedRequiredFields.set(change.typeName, /* @__PURE__ */ new Map());
|
|
13778
13940
|
addedRequiredFields.get(change.typeName).set(change.fieldName, after);
|
|
@@ -14127,8 +14289,7 @@ function generateChangeScript(change) {
|
|
|
14127
14289
|
return null;
|
|
14128
14290
|
}
|
|
14129
14291
|
if (change.kind !== "field_modified") return null;
|
|
14130
|
-
const before = change
|
|
14131
|
-
const after = change.after;
|
|
14292
|
+
const { before, after } = change;
|
|
14132
14293
|
if (!before.required && after.required) return ` // Set ${change.fieldName} for ${change.typeName} records where it is null
|
|
14133
14294
|
await trx
|
|
14134
14295
|
.updateTable("${change.typeName}")
|
|
@@ -14160,8 +14321,8 @@ function generateChangeScript(change) {
|
|
|
14160
14321
|
}
|
|
14161
14322
|
}`;
|
|
14162
14323
|
if (before.type === "enum" && after.type === "enum") {
|
|
14163
|
-
const beforeValues = before.allowedValues ?? [];
|
|
14164
|
-
const afterValues = after.allowedValues ?? [];
|
|
14324
|
+
const beforeValues = (before.allowedValues ?? []).map((v) => v.value);
|
|
14325
|
+
const afterValues = (after.allowedValues ?? []).map((v) => v.value);
|
|
14165
14326
|
const removedValues = beforeValues.filter((v) => !afterValues.includes(v));
|
|
14166
14327
|
if (removedValues.length > 0) {
|
|
14167
14328
|
const defaultValue = afterValues[0] ?? "NEW_VALUE";
|
|
@@ -14258,7 +14419,7 @@ async function generate(options) {
|
|
|
14258
14419
|
if (options.init) await handleInitOption(namespacesWithMigrations, options.yes);
|
|
14259
14420
|
let pluginManager;
|
|
14260
14421
|
if (plugins.length > 0) pluginManager = new PluginManager(plugins);
|
|
14261
|
-
const { defineApplication } = await import("./application-
|
|
14422
|
+
const { defineApplication } = await import("./application-DM8q9GDI.mjs");
|
|
14262
14423
|
const application = defineApplication({
|
|
14263
14424
|
config,
|
|
14264
14425
|
pluginManager
|
|
@@ -15862,9 +16023,13 @@ async function loadTypeFieldOrder(config, namespace) {
|
|
|
15862
16023
|
return fieldOrder;
|
|
15863
16024
|
}
|
|
15864
16025
|
|
|
16026
|
+
//#endregion
|
|
16027
|
+
//#region src/cli/query/types.ts
|
|
16028
|
+
const queryEngines = ["sql", "gql"];
|
|
16029
|
+
|
|
15865
16030
|
//#endregion
|
|
15866
16031
|
//#region src/cli/query/index.ts
|
|
15867
|
-
const queryEngineSchema = z.enum(
|
|
16032
|
+
const queryEngineSchema = z.enum(queryEngines);
|
|
15868
16033
|
const queryBaseOptionsSchema = z.object({
|
|
15869
16034
|
workspaceId: z.string().optional(),
|
|
15870
16035
|
profile: z.string().optional(),
|
|
@@ -16444,5 +16609,5 @@ function isDeno() {
|
|
|
16444
16609
|
}
|
|
16445
16610
|
|
|
16446
16611
|
//#endregion
|
|
16447
|
-
export { listCommand$5 as $, compareSnapshots as $t, truncate as A, workspaceArgs as An, startCommand as At, logBetaWarning as B, getExecutor as Bt, listCommand$2 as C, configArg as Cn, triggerExecutor as Ct, resumeWorkflow as D, pagedLogArgs as Dn, jobsCommand as Dt, resumeCommand as E, isVerbose as En, getExecutorJob as Et, writeDbTypesFile as F, getWorkflowExecution as Ft, organizationTree as G, parseMigrationLabelNumber as Gt, removeCommand$1 as H, executeScript as Ht, getConfiguredEditorCommand as I, listWorkflowExecutions as It, listOrganizations as J, DIFF_FILE_NAME as Jt, treeCommand as K, bundleMigrationScript as Kt, openInConfiguredEditor as L, functionExecutionStatusToString as Lt, generate as M, getCommand$5 as Mt, generateCommand as N, getWorkflow as Nt, listCommand$3 as O, paginationArgs as On, listExecutorJobs as Ot, generateMigrationScript as P, executionsCommand as Pt, updateFolder as Q, compareLocalTypesWithSnapshot as Qt, show as R, formatKeyValueTable as Rt, listApps as S, commonArgs as Sn, triggerCommand as St, healthCommand as T, deploymentArgs as Tn, listExecutors as Tt, updateCommand$1 as U, waitForExecution$1 as Ut, remove as V, deploy as Vt, updateOrganization as W, MIGRATION_LABEL_KEY as Wt, getOrganization as X, MIGRATE_FILE_NAME as Xt, getCommand$1 as Y, INITIAL_SCHEMA_NUMBER as Yt, updateCommand$2 as Z, SCHEMA_FILE_NAME as Zt, getWorkspace as _, prompt as _n, listFunctionRegistries as _t, updateUser as a,
|
|
16448
|
-
//# sourceMappingURL=runtime-
|
|
16612
|
+
export { listCommand$5 as $, compareSnapshots as $t, truncate as A, workspaceArgs as An, startCommand as At, logBetaWarning as B, getExecutor as Bt, listCommand$2 as C, configArg as Cn, triggerExecutor as Ct, resumeWorkflow as D, pagedLogArgs as Dn, jobsCommand as Dt, resumeCommand as E, isVerbose as En, getExecutorJob as Et, writeDbTypesFile as F, getWorkflowExecution as Ft, organizationTree as G, parseMigrationLabelNumber as Gt, removeCommand$1 as H, executeScript as Ht, getConfiguredEditorCommand as I, listWorkflowExecutions as It, listOrganizations as J, DIFF_FILE_NAME as Jt, treeCommand as K, bundleMigrationScript as Kt, openInConfiguredEditor as L, functionExecutionStatusToString as Lt, generate as M, getCommand$5 as Mt, generateCommand as N, getWorkflow as Nt, listCommand$3 as O, paginationArgs as On, listExecutorJobs as Ot, generateMigrationScript as P, executionsCommand as Pt, updateFolder as Q, compareLocalTypesWithSnapshot as Qt, show as R, formatKeyValueTable as Rt, listApps as S, commonArgs as Sn, triggerCommand as St, healthCommand as T, deploymentArgs as Tn, listExecutors as Tt, updateCommand$1 as U, waitForExecution$1 as Ut, remove as V, deploy as Vt, updateOrganization as W, MIGRATION_LABEL_KEY as Wt, getOrganization as X, MIGRATE_FILE_NAME as Xt, getCommand$1 as Y, INITIAL_SCHEMA_NUMBER as Yt, updateCommand$2 as Z, SCHEMA_FILE_NAME as Zt, getWorkspace as _, prompt as _n, listFunctionRegistries as _t, updateUser as a, getNextMigrationNumber as an, createCommand$1 as at, createCommand as b, assertWritable as bn, listWebhookExecutors as bt, listCommand as c, reconstructSnapshotFromMigrations as cn, listOAuth2Clients as ct, inviteUser as d, formatMigrationDiff as dn, getMachineUserToken as dt, createSnapshotFromLocalTypes as en, listFolders as et, restoreCommand as f, hasChanges as fn, tokenCommand as ft, getCommand as g, generateUserTypes as gn, listCommand$8 as gt, listWorkspaces as h, trnPrefix as hn, generate$1 as ht, updateCommand as i, getMigrationFiles as in, deleteFolder as it, truncateCommand as j, startWorkflow as jt, listWorkflows as k, toPageDirection as kn, watchExecutorJob as kt, listUsers as l, formatMigrationNumber as ln, getCommand$3 as lt, listCommand$1 as m, sdkNameLabelKey as mn, listMachineUsers as mt, query as n, getMigrationDirPath as nn, getFolder as nt, removeCommand as o, isValidMigrationNumber as on, createFolder as ot, restoreWorkspace as p, getNamespacesWithMigrations as pn, listCommand$7 as pt, listCommand$4 as q, DB_TYPES_FILE_NAME as qt, queryCommand as r, getMigrationFilePath as rn, deleteCommand$1 as rt, removeUser as s, loadDiff as sn, listCommand$6 as st, isNativeTypeScriptRuntime as t, getLatestMigrationNumber as tn, getCommand$2 as tt, inviteCommand as u, formatDiffSummary as un, getOAuth2Client as ut, deleteCommand as v, apiCommand as vn, getCommand$4 as vt, getAppHealth as w, confirmationArgs as wn, listCommand$9 as wt, createWorkspace as x, defineAppCommand as xn, webhookCommand as xt, deleteWorkspace as y, apiCall as yn, getFunctionRegistry as yt, showCommand as z, getCommand$6 as zt };
|
|
16613
|
+
//# sourceMappingURL=runtime-BZsl7Mh9.mjs.map
|