@tailor-platform/sdk 0.11.3 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/dist/cli/api.d.mts +54 -9
- package/dist/cli/api.mjs +8 -2
- package/dist/cli/api.mjs.map +1 -0
- package/dist/cli/index.d.mts +1 -1
- package/dist/cli/index.mjs +19 -2
- package/dist/cli/index.mjs.map +1 -1
- package/dist/configure/index.d.mts +4 -4
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{index-Bx9tHHe8.d.mts → index-15r0QXT5.d.mts} +6 -10
- package/dist/job-CSwByDTq.mjs.map +1 -1
- package/dist/{token-BJq9rpG5.mjs → list-6vWylIIR.mjs} +406 -125
- package/dist/list-6vWylIIR.mjs.map +1 -0
- package/dist/{types-C5oBGPO0.d.mts → types-BvH0p5R9.d.mts} +10 -13
- package/dist/{plugin-generated.d.ts → user-defined.d.ts} +4 -6
- package/dist/utils/test/index.d.mts +3 -3
- package/docs/cli-reference.md +65 -0
- package/docs/core-concepts.md +7 -7
- package/package.json +6 -5
- package/postinstall.mjs +6 -8
- package/dist/token-BJq9rpG5.mjs.map +0 -1
|
@@ -901,7 +901,7 @@ async function bundleSingleResolver(resolver, outputDir, tsconfig) {
|
|
|
901
901
|
//#endregion
|
|
902
902
|
//#region src/cli/bundler/workflow/ast-transformer.ts
|
|
903
903
|
/**
|
|
904
|
-
* Check if a module source is from
|
|
904
|
+
* Check if a module source is from \@tailor-platform/sdk (including subpaths)
|
|
905
905
|
*/
|
|
906
906
|
function isTailorSdkSource(source) {
|
|
907
907
|
return /^@tailor-platform\/sdk(\/|$)/.test(source);
|
|
@@ -932,7 +932,7 @@ function unwrapAwait(node) {
|
|
|
932
932
|
return node;
|
|
933
933
|
}
|
|
934
934
|
/**
|
|
935
|
-
* Collect all import bindings for createWorkflowJob from
|
|
935
|
+
* Collect all import bindings for createWorkflowJob from \@tailor-platform/sdk
|
|
936
936
|
* Returns a Set of local names that refer to createWorkflowJob
|
|
937
937
|
*/
|
|
938
938
|
function collectCreateWorkflowJobBindings(program) {
|
|
@@ -1033,7 +1033,7 @@ function findProperty(properties, name) {
|
|
|
1033
1033
|
return null;
|
|
1034
1034
|
}
|
|
1035
1035
|
/**
|
|
1036
|
-
* Find all workflow jobs by detecting createWorkflowJob calls from
|
|
1036
|
+
* Find all workflow jobs by detecting createWorkflowJob calls from \@tailor-platform/sdk
|
|
1037
1037
|
*/
|
|
1038
1038
|
function findAllJobs(program, _sourceText) {
|
|
1039
1039
|
const jobs = [];
|
|
@@ -1457,7 +1457,7 @@ var EnumConstantsGenerator = class {
|
|
|
1457
1457
|
aggregate(args) {
|
|
1458
1458
|
const files = [];
|
|
1459
1459
|
const allEnums = [];
|
|
1460
|
-
for (const
|
|
1460
|
+
for (const nsResult of args.input.tailordb) if (nsResult.types && nsResult.types.enums.length > 0) allEnums.push(...nsResult.types.enums);
|
|
1461
1461
|
if (allEnums.length > 0) {
|
|
1462
1462
|
const content = EnumProcessor.generateUnifiedEnumConstants(allEnums);
|
|
1463
1463
|
files.push({
|
|
@@ -1597,7 +1597,7 @@ var FileUtilsGenerator = class {
|
|
|
1597
1597
|
aggregate(args) {
|
|
1598
1598
|
const files = [];
|
|
1599
1599
|
const allNamespaceData = [];
|
|
1600
|
-
for (const
|
|
1600
|
+
for (const nsResult of args.input.tailordb) if (nsResult.types) try {
|
|
1601
1601
|
const parsed = JSON.parse(nsResult.types);
|
|
1602
1602
|
if (parsed.namespace && parsed.types) allNamespaceData.push(parsed);
|
|
1603
1603
|
} catch {}
|
|
@@ -1838,7 +1838,7 @@ var KyselyGenerator = class {
|
|
|
1838
1838
|
aggregate(args) {
|
|
1839
1839
|
const files = [];
|
|
1840
1840
|
const allNamespaceData = [];
|
|
1841
|
-
for (const
|
|
1841
|
+
for (const nsResult of args.input.tailordb) if (nsResult.types && nsResult.types.types.length > 0) allNamespaceData.push(nsResult.types);
|
|
1842
1842
|
if (allNamespaceData.length > 0) {
|
|
1843
1843
|
const content = TypeProcessor.generateUnifiedTypes(allNamespaceData);
|
|
1844
1844
|
files.push({
|
|
@@ -1879,6 +1879,74 @@ function processGqlIngest(type) {
|
|
|
1879
1879
|
};
|
|
1880
1880
|
}
|
|
1881
1881
|
|
|
1882
|
+
//#endregion
|
|
1883
|
+
//#region src/cli/generator/builtin/seed/idp-user-processor.ts
|
|
1884
|
+
/**
|
|
1885
|
+
* Processes auth configuration to generate IdP user seed metadata
|
|
1886
|
+
*/
|
|
1887
|
+
function processIdpUser(auth) {
|
|
1888
|
+
if (auth.idProvider?.kind !== "BuiltInIdP" || !auth.userProfile) return;
|
|
1889
|
+
const { typeName, usernameField } = auth.userProfile;
|
|
1890
|
+
return {
|
|
1891
|
+
name: "_User",
|
|
1892
|
+
dependencies: [typeName],
|
|
1893
|
+
mapping: {
|
|
1894
|
+
dataFile: "data/_User.jsonl",
|
|
1895
|
+
dataFormat: "jsonl",
|
|
1896
|
+
graphqlFile: "graphql/_User.graphql",
|
|
1897
|
+
mapping: { input: "$" }
|
|
1898
|
+
},
|
|
1899
|
+
graphql: `mutation CreateUser($input: _CreateUserInput!) {
|
|
1900
|
+
_createUser(input: $input) {
|
|
1901
|
+
id
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
`,
|
|
1905
|
+
schema: {
|
|
1906
|
+
usernameField,
|
|
1907
|
+
userTypeName: typeName
|
|
1908
|
+
}
|
|
1909
|
+
};
|
|
1910
|
+
}
|
|
1911
|
+
/**
|
|
1912
|
+
* Generates the schema file content for IdP users with foreign key
|
|
1913
|
+
*/
|
|
1914
|
+
function generateIdpUserSchemaFile(usernameField, userTypeName) {
|
|
1915
|
+
return ml`
|
|
1916
|
+
import { t } from "@tailor-platform/sdk";
|
|
1917
|
+
import { createStandardSchema } from "@tailor-platform/sdk/test";
|
|
1918
|
+
import { defineSchema } from "@toiroakr/lines-db";
|
|
1919
|
+
|
|
1920
|
+
const schemaType = t.object({
|
|
1921
|
+
name: t.string(),
|
|
1922
|
+
password: t.string(),
|
|
1923
|
+
});
|
|
1924
|
+
|
|
1925
|
+
// Simple identity hook for _User (no TailorDB backing type)
|
|
1926
|
+
const hook = <T>(data: unknown) => data as T;
|
|
1927
|
+
|
|
1928
|
+
export const schema = defineSchema(
|
|
1929
|
+
createStandardSchema(schemaType, hook),
|
|
1930
|
+
{
|
|
1931
|
+
primaryKey: "name",
|
|
1932
|
+
indexes: [
|
|
1933
|
+
{ name: "_user_name_unique_idx", columns: ["name"], unique: true },
|
|
1934
|
+
],
|
|
1935
|
+
foreignKeys: [
|
|
1936
|
+
{
|
|
1937
|
+
column: "name",
|
|
1938
|
+
references: {
|
|
1939
|
+
table: "${userTypeName}",
|
|
1940
|
+
column: "${usernameField}",
|
|
1941
|
+
},
|
|
1942
|
+
},
|
|
1943
|
+
],
|
|
1944
|
+
}
|
|
1945
|
+
);
|
|
1946
|
+
|
|
1947
|
+
`;
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1882
1950
|
//#endregion
|
|
1883
1951
|
//#region src/cli/generator/builtin/seed/lines-db-processor.ts
|
|
1884
1952
|
/**
|
|
@@ -1976,15 +2044,37 @@ const SeedGeneratorID = "@tailor-platform/seed";
|
|
|
1976
2044
|
* Combines GraphQL Ingest and lines-db schema generation.
|
|
1977
2045
|
*/
|
|
1978
2046
|
/**
|
|
1979
|
-
* Generates the exec.
|
|
2047
|
+
* Generates the exec.mjs script content (Node.js executable)
|
|
1980
2048
|
*/
|
|
1981
2049
|
function generateExecScript(machineUserName, configDir) {
|
|
1982
|
-
return
|
|
2050
|
+
return ml`
|
|
2051
|
+
import { execSync } from "node:child_process";
|
|
2052
|
+
import { show, machineUserToken } from "@tailor-platform/sdk/cli";
|
|
1983
2053
|
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
2054
|
+
console.log("Starting seed data generation...");
|
|
2055
|
+
|
|
2056
|
+
const appInfo = await show();
|
|
2057
|
+
const endpoint = \`\${appInfo.url}/query\`;
|
|
2058
|
+
|
|
2059
|
+
const tokenInfo = await machineUserToken({ name: "${machineUserName}" });
|
|
2060
|
+
const headers = JSON.stringify({ Authorization: \`Bearer \${tokenInfo.accessToken}\` });
|
|
2061
|
+
|
|
2062
|
+
// Build command with platform-specific quoting
|
|
2063
|
+
const headersArg = process.platform === "win32"
|
|
2064
|
+
? \`"\${headers.replace(/"/g, '\\\\"')}"\` // Windows: escape " as \\"
|
|
2065
|
+
: \`'\${headers}'\`; // Unix: use single quotes
|
|
2066
|
+
|
|
2067
|
+
const cmd = \`npx gql-ingest -c ${configDir} -e "\${endpoint}" --headers \${headersArg}\`;
|
|
2068
|
+
console.log("Running:", cmd);
|
|
2069
|
+
|
|
2070
|
+
try {
|
|
2071
|
+
execSync(cmd, { stdio: "inherit" });
|
|
2072
|
+
} catch (error) {
|
|
2073
|
+
console.error("Seed failed with exit code:", error.status);
|
|
2074
|
+
process.exit(error.status ?? 1);
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
`;
|
|
1988
2078
|
}
|
|
1989
2079
|
function createSeedGenerator(options) {
|
|
1990
2080
|
return {
|
|
@@ -2001,10 +2091,10 @@ function createSeedGenerator(options) {
|
|
|
2001
2091
|
processTailorDBNamespace: ({ types }) => types,
|
|
2002
2092
|
processExecutor: (_executor) => void 0,
|
|
2003
2093
|
processResolver: (_args) => void 0,
|
|
2004
|
-
aggregate: ({
|
|
2094
|
+
aggregate: ({ input }) => {
|
|
2005
2095
|
const entityDependencies = {};
|
|
2006
2096
|
const files = [];
|
|
2007
|
-
for (const
|
|
2097
|
+
for (const nsResult of input.tailordb) {
|
|
2008
2098
|
if (!nsResult.types) continue;
|
|
2009
2099
|
const outputBaseDir = options.distPath;
|
|
2010
2100
|
if (!(outputBaseDir in entityDependencies)) entityDependencies[outputBaseDir] = {};
|
|
@@ -2031,6 +2121,31 @@ function createSeedGenerator(options) {
|
|
|
2031
2121
|
});
|
|
2032
2122
|
}
|
|
2033
2123
|
}
|
|
2124
|
+
if (input.auth) {
|
|
2125
|
+
const idpUser = processIdpUser(input.auth);
|
|
2126
|
+
if (idpUser) {
|
|
2127
|
+
const outputBaseDir = options.distPath;
|
|
2128
|
+
if (!(outputBaseDir in entityDependencies)) entityDependencies[outputBaseDir] = {};
|
|
2129
|
+
entityDependencies[outputBaseDir][idpUser.name] = idpUser.dependencies;
|
|
2130
|
+
files.push({
|
|
2131
|
+
path: path.join(outputBaseDir, idpUser.mapping.graphqlFile),
|
|
2132
|
+
content: idpUser.graphql
|
|
2133
|
+
});
|
|
2134
|
+
files.push({
|
|
2135
|
+
path: path.join(outputBaseDir, "mappings", `${idpUser.name}.json`),
|
|
2136
|
+
content: JSON.stringify(idpUser.mapping, null, 2) + "\n"
|
|
2137
|
+
});
|
|
2138
|
+
files.push({
|
|
2139
|
+
path: path.join(outputBaseDir, idpUser.mapping.dataFile),
|
|
2140
|
+
content: "",
|
|
2141
|
+
skipIfExists: true
|
|
2142
|
+
});
|
|
2143
|
+
files.push({
|
|
2144
|
+
path: path.join(outputBaseDir, "data", `${idpUser.name}.schema.ts`),
|
|
2145
|
+
content: generateIdpUserSchemaFile(idpUser.schema.usernameField, idpUser.schema.userTypeName)
|
|
2146
|
+
});
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2034
2149
|
for (const [outputDir, dependencies] of Object.entries(entityDependencies)) {
|
|
2035
2150
|
files.push({
|
|
2036
2151
|
path: path.join(outputDir, "config.yaml"),
|
|
@@ -2039,9 +2154,8 @@ function createSeedGenerator(options) {
|
|
|
2039
2154
|
`
|
|
2040
2155
|
});
|
|
2041
2156
|
if (options.machineUserName) files.push({
|
|
2042
|
-
path: path.join(outputDir, "exec.
|
|
2043
|
-
content: generateExecScript(options.machineUserName, path.basename(outputDir))
|
|
2044
|
-
executable: true
|
|
2157
|
+
path: path.join(outputDir, "exec.mjs"),
|
|
2158
|
+
content: generateExecScript(options.machineUserName, path.basename(outputDir))
|
|
2045
2159
|
});
|
|
2046
2160
|
}
|
|
2047
2161
|
return { files };
|
|
@@ -2100,32 +2214,30 @@ function extractAttributesFromConfig(config) {
|
|
|
2100
2214
|
return collectAttributesFromConfig(config);
|
|
2101
2215
|
}
|
|
2102
2216
|
function generateTypeDefinition(attributeMap, attributeList, env) {
|
|
2103
|
-
const mapFields = attributeMap ? Object.entries(attributeMap).map(([key, value]) => `
|
|
2217
|
+
const mapFields = attributeMap ? Object.entries(attributeMap).map(([key, value]) => ` ${key}: ${value};`).join("\n") : "";
|
|
2104
2218
|
const mapBody = !attributeMap || Object.keys(attributeMap).length === 0 ? "{}" : `{
|
|
2105
2219
|
${mapFields}
|
|
2106
|
-
|
|
2220
|
+
}`;
|
|
2107
2221
|
const listBody = `{
|
|
2108
|
-
|
|
2109
|
-
|
|
2222
|
+
__tuple?: ${attributeList ? `[${attributeList.map(() => "string").join(", ")}]` : "[]"};
|
|
2223
|
+
}`;
|
|
2110
2224
|
const envFields = env ? Object.entries(env).map(([key, value]) => {
|
|
2111
2225
|
const valueType = typeof value === "string" ? `"${value}"` : String(value);
|
|
2112
|
-
return `
|
|
2226
|
+
return ` ${key}: ${valueType};`;
|
|
2113
2227
|
}).join("\n") : "";
|
|
2114
2228
|
const envBody = !env || Object.keys(env).length === 0 ? "{}" : `{
|
|
2115
2229
|
${envFields}
|
|
2116
|
-
|
|
2230
|
+
}`;
|
|
2117
2231
|
return ml`
|
|
2118
2232
|
/* eslint-disable @typescript-eslint/no-empty-object-type */
|
|
2119
2233
|
// This file is auto-generated by @tailor-platform/sdk
|
|
2120
2234
|
// Do not edit this file manually
|
|
2121
2235
|
// Regenerated automatically when running 'tailor-sdk apply' or 'tailor-sdk generate'
|
|
2122
2236
|
|
|
2123
|
-
declare
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
interface Env ${envBody}
|
|
2128
|
-
}
|
|
2237
|
+
declare module "@tailor-platform/sdk" {
|
|
2238
|
+
interface AttributeMap ${mapBody}
|
|
2239
|
+
interface AttributeList ${listBody}
|
|
2240
|
+
interface Env ${envBody}
|
|
2129
2241
|
}
|
|
2130
2242
|
|
|
2131
2243
|
export {};
|
|
@@ -2165,8 +2277,8 @@ function resolveTypeDefinitionPath(configPath) {
|
|
|
2165
2277
|
if (typePath) return path.resolve(process.cwd(), typePath);
|
|
2166
2278
|
const configDir = path.dirname(path.resolve(configPath));
|
|
2167
2279
|
const packageDir = resolvePackageDirectory(configDir);
|
|
2168
|
-
if (!packageDir) return path.join(configDir, "node_modules", "@tailor-platform", "sdk", "dist", "
|
|
2169
|
-
return path.join(packageDir, "dist", "
|
|
2280
|
+
if (!packageDir) return path.join(configDir, "node_modules", "@tailor-platform", "sdk", "dist", "user-defined.d.ts");
|
|
2281
|
+
return path.join(packageDir, "dist", "user-defined.d.ts");
|
|
2170
2282
|
}
|
|
2171
2283
|
async function generateUserTypes(config, configPath) {
|
|
2172
2284
|
try {
|
|
@@ -6271,8 +6383,11 @@ var DependencyWatcher = class {
|
|
|
6271
6383
|
//#region src/cli/generator/index.ts
|
|
6272
6384
|
var GenerationManager = class {
|
|
6273
6385
|
application;
|
|
6274
|
-
|
|
6275
|
-
|
|
6386
|
+
services = {
|
|
6387
|
+
tailordb: {},
|
|
6388
|
+
resolver: {},
|
|
6389
|
+
executor: {}
|
|
6390
|
+
};
|
|
6276
6391
|
baseDir;
|
|
6277
6392
|
constructor(config, generators = [], configPath) {
|
|
6278
6393
|
this.generators = generators;
|
|
@@ -6285,45 +6400,39 @@ var GenerationManager = class {
|
|
|
6285
6400
|
console.log("");
|
|
6286
6401
|
console.log("Generation for application:", styleText("cyanBright", this.application.config.name));
|
|
6287
6402
|
console.log("");
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
};
|
|
6302
|
-
} catch (error) {
|
|
6303
|
-
console.error(styleText("red", "Error loading types for TailorDB service"), styleText("redBright", namespace));
|
|
6304
|
-
console.error(error);
|
|
6305
|
-
if (!watch) throw error;
|
|
6306
|
-
}
|
|
6403
|
+
const app = this.application;
|
|
6404
|
+
for (const db of app.tailorDBServices) {
|
|
6405
|
+
const namespace = db.namespace;
|
|
6406
|
+
try {
|
|
6407
|
+
await db.loadTypes();
|
|
6408
|
+
this.services.tailordb[namespace] = {
|
|
6409
|
+
types: db.getTypes(),
|
|
6410
|
+
sourceInfo: db.getTypeSourceInfo()
|
|
6411
|
+
};
|
|
6412
|
+
} catch (error) {
|
|
6413
|
+
console.error(styleText("red", "Error loading types for TailorDB service"), styleText("redBright", namespace));
|
|
6414
|
+
console.error(error);
|
|
6415
|
+
if (!watch) throw error;
|
|
6307
6416
|
}
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
}
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6417
|
+
}
|
|
6418
|
+
for (const resolverService of app.resolverServices) {
|
|
6419
|
+
const namespace = resolverService.namespace;
|
|
6420
|
+
try {
|
|
6421
|
+
await resolverService.loadResolvers();
|
|
6422
|
+
this.services.resolver[namespace] = {};
|
|
6423
|
+
Object.entries(resolverService.getResolvers()).forEach(([_, resolver]) => {
|
|
6424
|
+
this.services.resolver[namespace][resolver.name] = resolver;
|
|
6425
|
+
});
|
|
6426
|
+
} catch (error) {
|
|
6427
|
+
console.error(styleText("red", "Error loading resolvers for Resolver service"), styleText("redBright", namespace));
|
|
6428
|
+
console.error(error);
|
|
6429
|
+
if (!watch) throw error;
|
|
6321
6430
|
}
|
|
6322
|
-
if (app.authService) await app.authService.resolveNamespaces();
|
|
6323
6431
|
}
|
|
6432
|
+
if (app.authService) await app.authService.resolveNamespaces();
|
|
6324
6433
|
const executors = await this.application.executorService?.loadExecutors();
|
|
6325
6434
|
Object.entries(executors ?? {}).forEach(([filePath, executor]) => {
|
|
6326
|
-
this.
|
|
6435
|
+
this.services.executor[filePath] = executor;
|
|
6327
6436
|
});
|
|
6328
6437
|
await this.processGenerators();
|
|
6329
6438
|
}
|
|
@@ -6334,84 +6443,75 @@ var GenerationManager = class {
|
|
|
6334
6443
|
async processGenerator(gen) {
|
|
6335
6444
|
try {
|
|
6336
6445
|
this.generatorResults[gen.id] = {
|
|
6337
|
-
|
|
6446
|
+
tailordbResults: {},
|
|
6447
|
+
resolverResults: {},
|
|
6448
|
+
tailordbNamespaceResults: {},
|
|
6449
|
+
resolverNamespaceResults: {},
|
|
6338
6450
|
executorResults: {}
|
|
6339
6451
|
};
|
|
6340
|
-
for (const [
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
resolverResults: {},
|
|
6344
|
-
tailordbNamespaceResults: {},
|
|
6345
|
-
resolverNamespaceResults: {}
|
|
6346
|
-
};
|
|
6347
|
-
for (const [namespace, types] of Object.entries(appData.tailordbNamespaces)) await this.processTailorDBNamespace(gen, appNamespace, namespace, types);
|
|
6348
|
-
for (const [namespace, resolvers] of Object.entries(appData.resolverNamespaces)) await this.processResolverNamespace(gen, appNamespace, namespace, resolvers);
|
|
6349
|
-
await this.processExecutors(gen);
|
|
6350
|
-
}
|
|
6452
|
+
for (const [namespace, types] of Object.entries(this.services.tailordb)) await this.processTailorDBNamespace(gen, namespace, types);
|
|
6453
|
+
for (const [namespace, resolvers] of Object.entries(this.services.resolver)) await this.processResolverNamespace(gen, namespace, resolvers);
|
|
6454
|
+
await this.processExecutors(gen);
|
|
6351
6455
|
await this.aggregate(gen);
|
|
6352
6456
|
} catch (error) {
|
|
6353
6457
|
console.error(styleText("red", "Error processing generator"), styleText("redBright", gen.id));
|
|
6354
6458
|
console.error(error);
|
|
6355
6459
|
}
|
|
6356
6460
|
}
|
|
6357
|
-
async processTailorDBNamespace(gen,
|
|
6358
|
-
const results = this.generatorResults[gen.id]
|
|
6461
|
+
async processTailorDBNamespace(gen, namespace, typeInfo) {
|
|
6462
|
+
const results = this.generatorResults[gen.id];
|
|
6359
6463
|
results.tailordbResults[namespace] = {};
|
|
6360
6464
|
await Promise.allSettled(Object.entries(typeInfo.types).map(async ([typeName, type]) => {
|
|
6361
6465
|
try {
|
|
6362
6466
|
results.tailordbResults[namespace][typeName] = await gen.processType({
|
|
6363
6467
|
type,
|
|
6364
|
-
applicationNamespace: appNamespace,
|
|
6365
6468
|
namespace,
|
|
6366
6469
|
source: typeInfo.sourceInfo[typeName]
|
|
6367
6470
|
});
|
|
6368
6471
|
} catch (error) {
|
|
6369
|
-
console.error(styleText("red", `Error processing type`), styleText("redBright", typeName), styleText("red", `in ${
|
|
6472
|
+
console.error(styleText("red", `Error processing type`), styleText("redBright", typeName), styleText("red", `in ${namespace} with generator ${gen.id}`));
|
|
6370
6473
|
console.error(error);
|
|
6371
6474
|
}
|
|
6372
6475
|
}));
|
|
6373
6476
|
if (gen.processTailorDBNamespace) try {
|
|
6374
6477
|
results.tailordbNamespaceResults[namespace] = await gen.processTailorDBNamespace({
|
|
6375
|
-
applicationNamespace: appNamespace,
|
|
6376
6478
|
namespace,
|
|
6377
6479
|
types: results.tailordbResults[namespace]
|
|
6378
6480
|
});
|
|
6379
6481
|
} catch (error) {
|
|
6380
|
-
console.error(styleText("red", `Error processing TailorDB namespace`), styleText("redBright", namespace), styleText("red", `
|
|
6482
|
+
console.error(styleText("red", `Error processing TailorDB namespace`), styleText("redBright", namespace), styleText("red", `with generator ${gen.id}`));
|
|
6381
6483
|
console.error(error);
|
|
6382
6484
|
}
|
|
6383
6485
|
else results.tailordbNamespaceResults[namespace] = results.tailordbResults[namespace];
|
|
6384
6486
|
}
|
|
6385
|
-
async processResolverNamespace(gen,
|
|
6386
|
-
const results = this.generatorResults[gen.id]
|
|
6487
|
+
async processResolverNamespace(gen, namespace, resolvers) {
|
|
6488
|
+
const results = this.generatorResults[gen.id];
|
|
6387
6489
|
results.resolverResults[namespace] = {};
|
|
6388
6490
|
await Promise.allSettled(Object.entries(resolvers).map(async ([resolverName, resolver]) => {
|
|
6389
6491
|
try {
|
|
6390
6492
|
results.resolverResults[namespace][resolverName] = await gen.processResolver({
|
|
6391
6493
|
resolver,
|
|
6392
|
-
applicationNamespace: appNamespace,
|
|
6393
6494
|
namespace
|
|
6394
6495
|
});
|
|
6395
6496
|
} catch (error) {
|
|
6396
|
-
console.error(styleText("red", `Error processing resolver`), styleText("redBright", resolverName), styleText("red", `in ${
|
|
6497
|
+
console.error(styleText("red", `Error processing resolver`), styleText("redBright", resolverName), styleText("red", `in ${namespace} with generator ${gen.id}`));
|
|
6397
6498
|
console.error(error);
|
|
6398
6499
|
}
|
|
6399
6500
|
}));
|
|
6400
6501
|
if (gen.processResolverNamespace) try {
|
|
6401
6502
|
results.resolverNamespaceResults[namespace] = await gen.processResolverNamespace({
|
|
6402
|
-
applicationNamespace: appNamespace,
|
|
6403
6503
|
namespace,
|
|
6404
6504
|
resolvers: results.resolverResults[namespace]
|
|
6405
6505
|
});
|
|
6406
6506
|
} catch (error) {
|
|
6407
|
-
console.error(styleText("red", `Error processing Resolver namespace`), styleText("redBright", namespace), styleText("red", `
|
|
6507
|
+
console.error(styleText("red", `Error processing Resolver namespace`), styleText("redBright", namespace), styleText("red", `with generator ${gen.id}`));
|
|
6408
6508
|
console.error(error);
|
|
6409
6509
|
}
|
|
6410
6510
|
else results.resolverNamespaceResults[namespace] = results.resolverResults[namespace];
|
|
6411
6511
|
}
|
|
6412
6512
|
async processExecutors(gen) {
|
|
6413
6513
|
const results = this.generatorResults[gen.id];
|
|
6414
|
-
await Promise.allSettled(Object.entries(this.
|
|
6514
|
+
await Promise.allSettled(Object.entries(this.services.executor).map(async ([executorId, executor]) => {
|
|
6415
6515
|
try {
|
|
6416
6516
|
results.executorResults[executorId] = await gen.processExecutor(executor);
|
|
6417
6517
|
} catch (error) {
|
|
@@ -6420,28 +6520,42 @@ var GenerationManager = class {
|
|
|
6420
6520
|
}
|
|
6421
6521
|
}));
|
|
6422
6522
|
}
|
|
6523
|
+
getAuthInput() {
|
|
6524
|
+
const authService = this.application.authService;
|
|
6525
|
+
if (!authService) return void 0;
|
|
6526
|
+
const config = authService.config;
|
|
6527
|
+
return {
|
|
6528
|
+
name: config.name,
|
|
6529
|
+
userProfile: authService.userProfile ? {
|
|
6530
|
+
typeName: authService.userProfile.type.name,
|
|
6531
|
+
namespace: authService.userProfile.namespace,
|
|
6532
|
+
usernameField: authService.userProfile.usernameField
|
|
6533
|
+
} : void 0,
|
|
6534
|
+
machineUsers: config.machineUsers,
|
|
6535
|
+
oauth2Clients: config.oauth2Clients,
|
|
6536
|
+
idProvider: config.idProvider
|
|
6537
|
+
};
|
|
6538
|
+
}
|
|
6423
6539
|
async aggregate(gen) {
|
|
6424
|
-
const
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
});
|
|
6441
|
-
}
|
|
6540
|
+
const results = this.generatorResults[gen.id];
|
|
6541
|
+
const tailordbResults = [];
|
|
6542
|
+
const resolverResults = [];
|
|
6543
|
+
for (const [namespace, types] of Object.entries(results.tailordbNamespaceResults)) tailordbResults.push({
|
|
6544
|
+
namespace,
|
|
6545
|
+
types
|
|
6546
|
+
});
|
|
6547
|
+
for (const [namespace, resolvers] of Object.entries(results.resolverNamespaceResults)) resolverResults.push({
|
|
6548
|
+
namespace,
|
|
6549
|
+
resolvers
|
|
6550
|
+
});
|
|
6551
|
+
const input = {
|
|
6552
|
+
tailordb: tailordbResults,
|
|
6553
|
+
resolver: resolverResults,
|
|
6554
|
+
auth: this.getAuthInput()
|
|
6555
|
+
};
|
|
6442
6556
|
const result = await gen.aggregate({
|
|
6443
|
-
|
|
6444
|
-
executorInputs: Object.values(
|
|
6557
|
+
input,
|
|
6558
|
+
executorInputs: Object.values(results.executorResults),
|
|
6445
6559
|
baseDir: path.join(this.baseDir, gen.id)
|
|
6446
6560
|
});
|
|
6447
6561
|
await Promise.all(result.files.map(async (file) => {
|
|
@@ -6483,15 +6597,14 @@ var GenerationManager = class {
|
|
|
6483
6597
|
this.restartWatchProcess();
|
|
6484
6598
|
});
|
|
6485
6599
|
if (this.configPath) await this.watcher.addWatchGroup("Config", [this.configPath]);
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
}
|
|
6600
|
+
const app = this.application;
|
|
6601
|
+
for (const db of app.tailorDBServices) {
|
|
6602
|
+
const dbNamespace = db.namespace;
|
|
6603
|
+
await this.watcher?.addWatchGroup(`TailorDB/${dbNamespace}`, db.config.files);
|
|
6604
|
+
}
|
|
6605
|
+
for (const resolverService of app.resolverServices) {
|
|
6606
|
+
const resolverNamespace = resolverService.namespace;
|
|
6607
|
+
await this.watcher?.addWatchGroup(`Resolver/${resolverNamespace}`, resolverService["config"].files);
|
|
6495
6608
|
}
|
|
6496
6609
|
await new Promise(() => {});
|
|
6497
6610
|
}
|
|
@@ -6828,7 +6941,7 @@ async function workspaceList() {
|
|
|
6828
6941
|
return [workspaces, nextPageToken];
|
|
6829
6942
|
})).map(workspaceInfo);
|
|
6830
6943
|
}
|
|
6831
|
-
const listCommand$
|
|
6944
|
+
const listCommand$2 = defineCommand({
|
|
6832
6945
|
meta: {
|
|
6833
6946
|
name: "list",
|
|
6834
6947
|
description: "List all Tailor Platform workspaces"
|
|
@@ -6935,7 +7048,7 @@ async function machineUserList(options) {
|
|
|
6935
7048
|
return [machineUsers, nextPageToken];
|
|
6936
7049
|
})).map(machineUserInfo);
|
|
6937
7050
|
}
|
|
6938
|
-
const listCommand = defineCommand({
|
|
7051
|
+
const listCommand$1 = defineCommand({
|
|
6939
7052
|
meta: {
|
|
6940
7053
|
name: "list",
|
|
6941
7054
|
description: "List all machine users"
|
|
@@ -7053,5 +7166,173 @@ const tokenCommand = defineCommand({
|
|
|
7053
7166
|
});
|
|
7054
7167
|
|
|
7055
7168
|
//#endregion
|
|
7056
|
-
|
|
7057
|
-
|
|
7169
|
+
//#region src/cli/oauth2client/transform.ts
|
|
7170
|
+
const grantTypeToString = (grantType) => {
|
|
7171
|
+
switch (grantType) {
|
|
7172
|
+
case AuthOAuth2Client_GrantType.AUTHORIZATION_CODE: return "authorization_code";
|
|
7173
|
+
case AuthOAuth2Client_GrantType.REFRESH_TOKEN: return "refresh_token";
|
|
7174
|
+
default: return "unknown";
|
|
7175
|
+
}
|
|
7176
|
+
};
|
|
7177
|
+
function toOAuth2ClientInfo(client) {
|
|
7178
|
+
return {
|
|
7179
|
+
name: client.name,
|
|
7180
|
+
description: client.description,
|
|
7181
|
+
clientId: client.clientId,
|
|
7182
|
+
grantTypes: client.grantTypes.map(grantTypeToString),
|
|
7183
|
+
redirectUris: client.redirectUris,
|
|
7184
|
+
createdAt: client.createdAt ? timestampDate(client.createdAt).toISOString() : "N/A"
|
|
7185
|
+
};
|
|
7186
|
+
}
|
|
7187
|
+
function toOAuth2ClientCredentials(client) {
|
|
7188
|
+
return {
|
|
7189
|
+
name: client.name,
|
|
7190
|
+
description: client.description,
|
|
7191
|
+
clientId: client.clientId,
|
|
7192
|
+
clientSecret: client.clientSecret,
|
|
7193
|
+
grantTypes: client.grantTypes.map(grantTypeToString),
|
|
7194
|
+
redirectUris: client.redirectUris,
|
|
7195
|
+
createdAt: client.createdAt ? timestampDate(client.createdAt).toISOString() : "N/A"
|
|
7196
|
+
};
|
|
7197
|
+
}
|
|
7198
|
+
|
|
7199
|
+
//#endregion
|
|
7200
|
+
//#region src/cli/oauth2client/get.ts
|
|
7201
|
+
async function oauth2ClientGet(options) {
|
|
7202
|
+
const accessToken = await loadAccessToken({
|
|
7203
|
+
useProfile: true,
|
|
7204
|
+
profile: options.profile
|
|
7205
|
+
});
|
|
7206
|
+
const client = await initOperatorClient(accessToken);
|
|
7207
|
+
const workspaceId = loadWorkspaceId({
|
|
7208
|
+
workspaceId: options.workspaceId,
|
|
7209
|
+
profile: options.profile
|
|
7210
|
+
});
|
|
7211
|
+
const configPath = loadConfigPath(options.configPath);
|
|
7212
|
+
const { config } = await loadConfig(configPath);
|
|
7213
|
+
const { application } = await client.getApplication({
|
|
7214
|
+
workspaceId,
|
|
7215
|
+
applicationName: config.name
|
|
7216
|
+
});
|
|
7217
|
+
if (!application?.authNamespace) throw new Error(`Application ${config.name} does not have an auth configuration.`);
|
|
7218
|
+
try {
|
|
7219
|
+
const { oauth2Client } = await client.getAuthOAuth2Client({
|
|
7220
|
+
workspaceId,
|
|
7221
|
+
namespaceName: application.authNamespace,
|
|
7222
|
+
name: options.name
|
|
7223
|
+
});
|
|
7224
|
+
return toOAuth2ClientCredentials(oauth2Client);
|
|
7225
|
+
} catch (error) {
|
|
7226
|
+
if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`OAuth2 client '${options.name}' not found.`);
|
|
7227
|
+
throw error;
|
|
7228
|
+
}
|
|
7229
|
+
}
|
|
7230
|
+
const getCommand = defineCommand({
|
|
7231
|
+
meta: {
|
|
7232
|
+
name: "get",
|
|
7233
|
+
description: "Get OAuth2 client credentials"
|
|
7234
|
+
},
|
|
7235
|
+
args: {
|
|
7236
|
+
...commonArgs,
|
|
7237
|
+
...formatArgs,
|
|
7238
|
+
name: {
|
|
7239
|
+
type: "positional",
|
|
7240
|
+
description: "OAuth2 client name",
|
|
7241
|
+
required: true
|
|
7242
|
+
},
|
|
7243
|
+
"workspace-id": {
|
|
7244
|
+
type: "string",
|
|
7245
|
+
description: "Workspace ID",
|
|
7246
|
+
alias: "w"
|
|
7247
|
+
},
|
|
7248
|
+
profile: {
|
|
7249
|
+
type: "string",
|
|
7250
|
+
description: "Workspace profile",
|
|
7251
|
+
alias: "p"
|
|
7252
|
+
},
|
|
7253
|
+
config: {
|
|
7254
|
+
type: "string",
|
|
7255
|
+
description: "Path to SDK config file",
|
|
7256
|
+
alias: "c",
|
|
7257
|
+
default: "tailor.config.ts"
|
|
7258
|
+
}
|
|
7259
|
+
},
|
|
7260
|
+
run: withCommonArgs(async (args) => {
|
|
7261
|
+
const format = parseFormat(args.format);
|
|
7262
|
+
const credentials = await oauth2ClientGet({
|
|
7263
|
+
name: args.name,
|
|
7264
|
+
workspaceId: args["workspace-id"],
|
|
7265
|
+
profile: args.profile,
|
|
7266
|
+
configPath: args.config
|
|
7267
|
+
});
|
|
7268
|
+
printWithFormat(credentials, format);
|
|
7269
|
+
})
|
|
7270
|
+
});
|
|
7271
|
+
|
|
7272
|
+
//#endregion
|
|
7273
|
+
//#region src/cli/oauth2client/list.ts
|
|
7274
|
+
async function oauth2ClientList(options) {
|
|
7275
|
+
const accessToken = await loadAccessToken({
|
|
7276
|
+
useProfile: true,
|
|
7277
|
+
profile: options?.profile
|
|
7278
|
+
});
|
|
7279
|
+
const client = await initOperatorClient(accessToken);
|
|
7280
|
+
const workspaceId = loadWorkspaceId({
|
|
7281
|
+
workspaceId: options?.workspaceId,
|
|
7282
|
+
profile: options?.profile
|
|
7283
|
+
});
|
|
7284
|
+
const configPath = loadConfigPath(options?.configPath);
|
|
7285
|
+
const { config } = await loadConfig(configPath);
|
|
7286
|
+
const { application } = await client.getApplication({
|
|
7287
|
+
workspaceId,
|
|
7288
|
+
applicationName: config.name
|
|
7289
|
+
});
|
|
7290
|
+
if (!application?.authNamespace) throw new Error(`Application ${config.name} does not have an auth configuration.`);
|
|
7291
|
+
return (await fetchAll(async (pageToken) => {
|
|
7292
|
+
const { oauth2Clients, nextPageToken } = await client.listAuthOAuth2Clients({
|
|
7293
|
+
workspaceId,
|
|
7294
|
+
pageToken,
|
|
7295
|
+
namespaceName: application.authNamespace
|
|
7296
|
+
});
|
|
7297
|
+
return [oauth2Clients, nextPageToken];
|
|
7298
|
+
})).map(toOAuth2ClientInfo);
|
|
7299
|
+
}
|
|
7300
|
+
const listCommand = defineCommand({
|
|
7301
|
+
meta: {
|
|
7302
|
+
name: "list",
|
|
7303
|
+
description: "List all OAuth2 clients"
|
|
7304
|
+
},
|
|
7305
|
+
args: {
|
|
7306
|
+
...commonArgs,
|
|
7307
|
+
...formatArgs,
|
|
7308
|
+
"workspace-id": {
|
|
7309
|
+
type: "string",
|
|
7310
|
+
description: "Workspace ID",
|
|
7311
|
+
alias: "w"
|
|
7312
|
+
},
|
|
7313
|
+
profile: {
|
|
7314
|
+
type: "string",
|
|
7315
|
+
description: "Workspace profile",
|
|
7316
|
+
alias: "p"
|
|
7317
|
+
},
|
|
7318
|
+
config: {
|
|
7319
|
+
type: "string",
|
|
7320
|
+
description: "Path to SDK config file",
|
|
7321
|
+
alias: "c",
|
|
7322
|
+
default: "tailor.config.ts"
|
|
7323
|
+
}
|
|
7324
|
+
},
|
|
7325
|
+
run: withCommonArgs(async (args) => {
|
|
7326
|
+
const format = parseFormat(args.format);
|
|
7327
|
+
const oauth2Clients = await oauth2ClientList({
|
|
7328
|
+
workspaceId: args["workspace-id"],
|
|
7329
|
+
profile: args.profile,
|
|
7330
|
+
configPath: args.config
|
|
7331
|
+
});
|
|
7332
|
+
printWithFormat(oauth2Clients, format);
|
|
7333
|
+
})
|
|
7334
|
+
});
|
|
7335
|
+
|
|
7336
|
+
//#endregion
|
|
7337
|
+
export { PATScope, apply, applyCommand, commonArgs, createCommand, deleteCommand, fetchAll, fetchLatestToken, fetchUserInfo, formatArgs, generate, generateCommand, generateUserTypes, getCommand, initOAuth2Client, initOperatorClient, listCommand, listCommand$1, listCommand$2, loadAccessToken, loadConfig, loadConfigPath, loadWorkspaceId, machineUserList, machineUserToken, oauth2ClientGet, oauth2ClientList, parseFormat, printWithFormat, readPackageJson, readPlatformConfig, remove, removeCommand, show, showCommand, tokenCommand, withCommonArgs, workspaceCreate, workspaceDelete, workspaceList, writePlatformConfig };
|
|
7338
|
+
//# sourceMappingURL=list-6vWylIIR.mjs.map
|