@eide/foir-cli 0.1.34 → 0.1.36
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/dist/cli.js +7469 -81
- package/dist/config/types.d.ts +7 -6
- package/dist/config/types.js +6 -14
- package/dist/generated-CPsQ9jfu.d.ts +195 -0
- package/dist/lib/extension-helpers.d.ts +10 -7
- package/dist/lib/extension-helpers.js +15 -85
- package/dist/lib/hook-helpers.d.ts +9 -6
- package/dist/lib/hook-helpers.js +12 -105
- package/dist/lib/seed-helpers.d.ts +10 -8
- package/dist/lib/seed-helpers.js +18 -124
- package/package.json +9 -7
- package/dist/auth/credentials.d.ts +0 -31
- package/dist/auth/credentials.d.ts.map +0 -1
- package/dist/auth/credentials.js +0 -139
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/codegen/fetch-customer-profile-schema.d.ts +0 -12
- package/dist/codegen/fetch-customer-profile-schema.d.ts.map +0 -1
- package/dist/codegen/fetch-customer-profile-schema.js +0 -21
- package/dist/codegen/fetch-models.d.ts +0 -58
- package/dist/codegen/fetch-models.d.ts.map +0 -1
- package/dist/codegen/fetch-models.js +0 -96
- package/dist/codegen/field-mapping.d.ts +0 -34
- package/dist/codegen/field-mapping.d.ts.map +0 -1
- package/dist/codegen/field-mapping.js +0 -250
- package/dist/codegen/generators/config.d.ts +0 -5
- package/dist/codegen/generators/config.d.ts.map +0 -1
- package/dist/codegen/generators/config.js +0 -82
- package/dist/codegen/generators/customer-profile-documents.d.ts +0 -5
- package/dist/codegen/generators/customer-profile-documents.d.ts.map +0 -1
- package/dist/codegen/generators/customer-profile-documents.js +0 -42
- package/dist/codegen/generators/customer-profile-hooks.d.ts +0 -5
- package/dist/codegen/generators/customer-profile-hooks.d.ts.map +0 -1
- package/dist/codegen/generators/customer-profile-hooks.js +0 -78
- package/dist/codegen/generators/customer-profile-loaders.d.ts +0 -5
- package/dist/codegen/generators/customer-profile-loaders.d.ts.map +0 -1
- package/dist/codegen/generators/customer-profile-loaders.js +0 -67
- package/dist/codegen/generators/customer-profile-operations.d.ts +0 -5
- package/dist/codegen/generators/customer-profile-operations.d.ts.map +0 -1
- package/dist/codegen/generators/customer-profile-operations.js +0 -126
- package/dist/codegen/generators/customer-profile-types.d.ts +0 -6
- package/dist/codegen/generators/customer-profile-types.d.ts.map +0 -1
- package/dist/codegen/generators/customer-profile-types.js +0 -45
- package/dist/codegen/generators/documents.d.ts +0 -12
- package/dist/codegen/generators/documents.d.ts.map +0 -1
- package/dist/codegen/generators/documents.js +0 -178
- package/dist/codegen/generators/field-types.d.ts +0 -5
- package/dist/codegen/generators/field-types.d.ts.map +0 -1
- package/dist/codegen/generators/field-types.js +0 -346
- package/dist/codegen/generators/model-index.d.ts +0 -6
- package/dist/codegen/generators/model-index.d.ts.map +0 -1
- package/dist/codegen/generators/model-index.js +0 -26
- package/dist/codegen/generators/model-types.d.ts +0 -12
- package/dist/codegen/generators/model-types.d.ts.map +0 -1
- package/dist/codegen/generators/model-types.js +0 -176
- package/dist/codegen/generators/public-schema-content.d.ts +0 -14
- package/dist/codegen/generators/public-schema-content.d.ts.map +0 -1
- package/dist/codegen/generators/public-schema-content.js +0 -22
- package/dist/codegen/generators/react-hooks-index.d.ts +0 -6
- package/dist/codegen/generators/react-hooks-index.d.ts.map +0 -1
- package/dist/codegen/generators/react-hooks-index.js +0 -20
- package/dist/codegen/generators/react-hooks.d.ts +0 -7
- package/dist/codegen/generators/react-hooks.d.ts.map +0 -1
- package/dist/codegen/generators/react-hooks.js +0 -139
- package/dist/codegen/generators/remix-loaders-index.d.ts +0 -6
- package/dist/codegen/generators/remix-loaders-index.d.ts.map +0 -1
- package/dist/codegen/generators/remix-loaders-index.js +0 -20
- package/dist/codegen/generators/remix-loaders.d.ts +0 -7
- package/dist/codegen/generators/remix-loaders.d.ts.map +0 -1
- package/dist/codegen/generators/remix-loaders.js +0 -107
- package/dist/codegen/generators/static-documents.d.ts +0 -14
- package/dist/codegen/generators/static-documents.d.ts.map +0 -1
- package/dist/codegen/generators/static-documents.js +0 -771
- package/dist/codegen/generators/swift-customer-profile.d.ts +0 -9
- package/dist/codegen/generators/swift-customer-profile.d.ts.map +0 -1
- package/dist/codegen/generators/swift-customer-profile.js +0 -152
- package/dist/codegen/generators/swift-field-types.d.ts +0 -5
- package/dist/codegen/generators/swift-field-types.d.ts.map +0 -1
- package/dist/codegen/generators/swift-field-types.js +0 -151
- package/dist/codegen/generators/swift-model-keys.d.ts +0 -6
- package/dist/codegen/generators/swift-model-keys.d.ts.map +0 -1
- package/dist/codegen/generators/swift-model-keys.js +0 -25
- package/dist/codegen/generators/swift-types.d.ts +0 -13
- package/dist/codegen/generators/swift-types.d.ts.map +0 -1
- package/dist/codegen/generators/swift-types.js +0 -188
- package/dist/codegen/generators/typed-operations-common.d.ts +0 -6
- package/dist/codegen/generators/typed-operations-common.d.ts.map +0 -1
- package/dist/codegen/generators/typed-operations-common.js +0 -84
- package/dist/codegen/generators/typed-operations-index.d.ts +0 -6
- package/dist/codegen/generators/typed-operations-index.d.ts.map +0 -1
- package/dist/codegen/generators/typed-operations-index.js +0 -22
- package/dist/codegen/generators/typed-operations.d.ts +0 -11
- package/dist/codegen/generators/typed-operations.d.ts.map +0 -1
- package/dist/codegen/generators/typed-operations.js +0 -263
- package/dist/codegen/swift-field-mapping.d.ts +0 -30
- package/dist/codegen/swift-field-mapping.d.ts.map +0 -1
- package/dist/codegen/swift-field-mapping.js +0 -150
- package/dist/codegen/write-files.d.ts +0 -15
- package/dist/codegen/write-files.d.ts.map +0 -1
- package/dist/codegen/write-files.js +0 -36
- package/dist/commands/api-keys.d.ts +0 -4
- package/dist/commands/api-keys.d.ts.map +0 -1
- package/dist/commands/api-keys.js +0 -129
- package/dist/commands/auth-config.d.ts +0 -4
- package/dist/commands/auth-config.d.ts.map +0 -1
- package/dist/commands/auth-config.js +0 -38
- package/dist/commands/auth-providers.d.ts +0 -4
- package/dist/commands/auth-providers.d.ts.map +0 -1
- package/dist/commands/auth-providers.js +0 -207
- package/dist/commands/context.d.ts +0 -4
- package/dist/commands/context.d.ts.map +0 -1
- package/dist/commands/context.js +0 -91
- package/dist/commands/create-extension.d.ts +0 -4
- package/dist/commands/create-extension.d.ts.map +0 -1
- package/dist/commands/create-extension.js +0 -60
- package/dist/commands/customer-profiles.d.ts +0 -4
- package/dist/commands/customer-profiles.d.ts.map +0 -1
- package/dist/commands/customer-profiles.js +0 -99
- package/dist/commands/customers.d.ts +0 -4
- package/dist/commands/customers.d.ts.map +0 -1
- package/dist/commands/customers.js +0 -126
- package/dist/commands/embeddings.d.ts +0 -4
- package/dist/commands/embeddings.d.ts.map +0 -1
- package/dist/commands/embeddings.js +0 -145
- package/dist/commands/experiments.d.ts +0 -4
- package/dist/commands/experiments.d.ts.map +0 -1
- package/dist/commands/experiments.js +0 -196
- package/dist/commands/extensions.d.ts +0 -4
- package/dist/commands/extensions.d.ts.map +0 -1
- package/dist/commands/extensions.js +0 -210
- package/dist/commands/files.d.ts +0 -4
- package/dist/commands/files.d.ts.map +0 -1
- package/dist/commands/files.js +0 -143
- package/dist/commands/hooks.d.ts +0 -4
- package/dist/commands/hooks.d.ts.map +0 -1
- package/dist/commands/hooks.js +0 -228
- package/dist/commands/locales.d.ts +0 -4
- package/dist/commands/locales.d.ts.map +0 -1
- package/dist/commands/locales.js +0 -140
- package/dist/commands/login.d.ts +0 -4
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js +0 -124
- package/dist/commands/logout.d.ts +0 -4
- package/dist/commands/logout.d.ts.map +0 -1
- package/dist/commands/logout.js +0 -16
- package/dist/commands/media.d.ts +0 -4
- package/dist/commands/media.d.ts.map +0 -1
- package/dist/commands/media.js +0 -44
- package/dist/commands/models.d.ts +0 -4
- package/dist/commands/models.d.ts.map +0 -1
- package/dist/commands/models.js +0 -153
- package/dist/commands/notes.d.ts +0 -4
- package/dist/commands/notes.d.ts.map +0 -1
- package/dist/commands/notes.js +0 -132
- package/dist/commands/notifications.d.ts +0 -4
- package/dist/commands/notifications.d.ts.map +0 -1
- package/dist/commands/notifications.js +0 -73
- package/dist/commands/operations.d.ts +0 -4
- package/dist/commands/operations.d.ts.map +0 -1
- package/dist/commands/operations.js +0 -341
- package/dist/commands/pull.d.ts +0 -4
- package/dist/commands/pull.d.ts.map +0 -1
- package/dist/commands/pull.js +0 -300
- package/dist/commands/records.d.ts +0 -4
- package/dist/commands/records.d.ts.map +0 -1
- package/dist/commands/records.js +0 -314
- package/dist/commands/schedules.d.ts +0 -4
- package/dist/commands/schedules.d.ts.map +0 -1
- package/dist/commands/schedules.js +0 -155
- package/dist/commands/search.d.ts +0 -4
- package/dist/commands/search.d.ts.map +0 -1
- package/dist/commands/search.js +0 -60
- package/dist/commands/segments.d.ts +0 -4
- package/dist/commands/segments.d.ts.map +0 -1
- package/dist/commands/segments.js +0 -155
- package/dist/commands/select-project.d.ts +0 -4
- package/dist/commands/select-project.d.ts.map +0 -1
- package/dist/commands/select-project.js +0 -144
- package/dist/commands/settings.d.ts +0 -4
- package/dist/commands/settings.d.ts.map +0 -1
- package/dist/commands/settings.js +0 -115
- package/dist/commands/variant-catalog.d.ts +0 -4
- package/dist/commands/variant-catalog.d.ts.map +0 -1
- package/dist/commands/variant-catalog.js +0 -118
- package/dist/commands/whoami.d.ts +0 -4
- package/dist/commands/whoami.d.ts.map +0 -1
- package/dist/commands/whoami.js +0 -51
- package/dist/config/pull-config.d.ts +0 -33
- package/dist/config/pull-config.d.ts.map +0 -1
- package/dist/config/pull-config.js +0 -119
- package/dist/config/types.d.ts.map +0 -1
- package/dist/graphql/generated.d.ts +0 -8330
- package/dist/graphql/generated.d.ts.map +0 -1
- package/dist/graphql/generated.js +0 -135
- package/dist/lib/client.d.ts +0 -18
- package/dist/lib/client.d.ts.map +0 -1
- package/dist/lib/client.js +0 -64
- package/dist/lib/config-loader.d.ts +0 -28
- package/dist/lib/config-loader.d.ts.map +0 -1
- package/dist/lib/config-loader.js +0 -49
- package/dist/lib/config.d.ts +0 -12
- package/dist/lib/config.d.ts.map +0 -1
- package/dist/lib/config.js +0 -8
- package/dist/lib/errors.d.ts +0 -6
- package/dist/lib/errors.d.ts.map +0 -1
- package/dist/lib/errors.js +0 -76
- package/dist/lib/extension-helpers.d.ts.map +0 -1
- package/dist/lib/hook-helpers.d.ts.map +0 -1
- package/dist/lib/input.d.ts +0 -38
- package/dist/lib/input.d.ts.map +0 -1
- package/dist/lib/input.js +0 -108
- package/dist/lib/output.d.ts +0 -31
- package/dist/lib/output.d.ts.map +0 -1
- package/dist/lib/output.js +0 -107
- package/dist/lib/seed-helpers.d.ts.map +0 -1
- package/dist/scaffold/package-manager.d.ts +0 -12
- package/dist/scaffold/package-manager.d.ts.map +0 -1
- package/dist/scaffold/package-manager.js +0 -51
- package/dist/scaffold/scaffold.d.ts +0 -4
- package/dist/scaffold/scaffold.d.ts.map +0 -1
- package/dist/scaffold/scaffold.js +0 -462
package/dist/commands/pull.js
DELETED
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'path';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { withErrorHandler } from '../lib/errors.js';
|
|
4
|
-
import { createClient } from '../lib/client.js';
|
|
5
|
-
import { loadPullConfig } from '../config/pull-config.js';
|
|
6
|
-
import { fetchModelsForCodegen, filterModels, } from '../codegen/fetch-models.js';
|
|
7
|
-
import { fetchCustomerProfileSchema } from '../codegen/fetch-customer-profile-schema.js';
|
|
8
|
-
import { toPascalCase } from '../codegen/field-mapping.js';
|
|
9
|
-
import { generateFieldTypesFile } from '../codegen/generators/field-types.js';
|
|
10
|
-
import { generateConfigFile } from '../codegen/generators/config.js';
|
|
11
|
-
import { generateModelTypes } from '../codegen/generators/model-types.js';
|
|
12
|
-
import { generateModelIndex } from '../codegen/generators/model-index.js';
|
|
13
|
-
import { generateModelDocuments, generateSharedFragments, } from '../codegen/generators/documents.js';
|
|
14
|
-
import { generateSwiftModelFile } from '../codegen/generators/swift-types.js';
|
|
15
|
-
import { generateSwiftFieldTypesFile } from '../codegen/generators/swift-field-types.js';
|
|
16
|
-
import { generateSwiftModelKeys } from '../codegen/generators/swift-model-keys.js';
|
|
17
|
-
import { generateCustomerProfileTypes } from '../codegen/generators/customer-profile-types.js';
|
|
18
|
-
import { generateSwiftCustomerProfileFile } from '../codegen/generators/swift-customer-profile.js';
|
|
19
|
-
import { generateCustomerProfileDocuments } from '../codegen/generators/customer-profile-documents.js';
|
|
20
|
-
import { generateStaticDocuments } from '../codegen/generators/static-documents.js';
|
|
21
|
-
import { generateTypedOperationsCommon } from '../codegen/generators/typed-operations-common.js';
|
|
22
|
-
import { generateTypedOperations, computeTypesRelPath, } from '../codegen/generators/typed-operations.js';
|
|
23
|
-
import { generateTypedOperationsIndex } from '../codegen/generators/typed-operations-index.js';
|
|
24
|
-
import { generateCustomerProfileOperations } from '../codegen/generators/customer-profile-operations.js';
|
|
25
|
-
import { generateReactHooks } from '../codegen/generators/react-hooks.js';
|
|
26
|
-
import { generateReactHooksIndex } from '../codegen/generators/react-hooks-index.js';
|
|
27
|
-
import { generateCustomerProfileHooks } from '../codegen/generators/customer-profile-hooks.js';
|
|
28
|
-
import { generateRemixLoaders } from '../codegen/generators/remix-loaders.js';
|
|
29
|
-
import { generateRemixLoadersIndex } from '../codegen/generators/remix-loaders-index.js';
|
|
30
|
-
import { generateCustomerProfileLoaders } from '../codegen/generators/customer-profile-loaders.js';
|
|
31
|
-
import { fetchPublicSchema } from '../codegen/generators/public-schema-content.js';
|
|
32
|
-
import { writeFiles } from '../codegen/write-files.js';
|
|
33
|
-
export function registerPullCommand(program, globalOpts) {
|
|
34
|
-
program
|
|
35
|
-
.command('pull')
|
|
36
|
-
.description('Generate TypeScript types, GraphQL documents, and Swift types from platform models')
|
|
37
|
-
.option('--config <path>', 'Path to config file')
|
|
38
|
-
.option('--only <models>', 'Comma-separated model keys to generate')
|
|
39
|
-
.option('--no-prettier', 'Skip Prettier formatting')
|
|
40
|
-
.option('--dry-run', 'Show what would be generated without writing')
|
|
41
|
-
.option('--out <dir>', 'Override output directory for types')
|
|
42
|
-
.option('--swift <dir>', 'Generate Swift files to directory')
|
|
43
|
-
.action(withErrorHandler(globalOpts, async (cmdOpts) => {
|
|
44
|
-
const opts = globalOpts();
|
|
45
|
-
const flags = {
|
|
46
|
-
config: cmdOpts.config,
|
|
47
|
-
only: cmdOpts.only,
|
|
48
|
-
noPrettier: cmdOpts.prettier === false,
|
|
49
|
-
dryRun: !!cmdOpts.dryRun,
|
|
50
|
-
out: cmdOpts.out,
|
|
51
|
-
swift: cmdOpts.swift,
|
|
52
|
-
};
|
|
53
|
-
const config = await loadPullConfig(flags);
|
|
54
|
-
// Fetch models + customer profile schema + public schema
|
|
55
|
-
const client = await createClient(opts);
|
|
56
|
-
console.log(chalk.dim('Fetching models…'));
|
|
57
|
-
const [allModels, cpSchema, publicSchema] = await Promise.all([
|
|
58
|
-
fetchModelsForCodegen(client),
|
|
59
|
-
fetchCustomerProfileSchema(client),
|
|
60
|
-
fetchPublicSchema(client),
|
|
61
|
-
]);
|
|
62
|
-
if (allModels.length === 0 && !cpSchema) {
|
|
63
|
-
console.log(chalk.yellow('No models found. Nothing to generate.'));
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const models = filterModels(allModels, {
|
|
67
|
-
only: config.only.length > 0 ? config.only : undefined,
|
|
68
|
-
includeInline: config.includeInline,
|
|
69
|
-
});
|
|
70
|
-
console.log(chalk.dim(`Found ${allModels.length} model(s), generating for ${models.length}.`));
|
|
71
|
-
// Collect files to write
|
|
72
|
-
const cwd = process.cwd();
|
|
73
|
-
const typesDir = resolve(cwd, config.output.types);
|
|
74
|
-
const docsDir = resolve(cwd, config.output.documents);
|
|
75
|
-
const opsDir = resolve(cwd, config.output.operations);
|
|
76
|
-
const hooksDir = config.output.hooks
|
|
77
|
-
? resolve(cwd, config.output.hooks)
|
|
78
|
-
: null;
|
|
79
|
-
const loadersDir = config.output.loaders
|
|
80
|
-
? resolve(cwd, config.output.loaders)
|
|
81
|
-
: null;
|
|
82
|
-
const files = [];
|
|
83
|
-
const hasCustomerProfile = !!(cpSchema && cpSchema.fields.length > 0);
|
|
84
|
-
const publicModels = models.filter((m) => m.config.publicApi && m.config.records);
|
|
85
|
-
// ─── Types ───────────────────────────────────────────────
|
|
86
|
-
// 1. Static files
|
|
87
|
-
files.push({
|
|
88
|
-
path: resolve(typesDir, 'field-types.ts'),
|
|
89
|
-
content: generateFieldTypesFile(),
|
|
90
|
-
});
|
|
91
|
-
files.push({
|
|
92
|
-
path: resolve(typesDir, 'config.ts'),
|
|
93
|
-
content: generateConfigFile(),
|
|
94
|
-
});
|
|
95
|
-
// 2. Per-model type files
|
|
96
|
-
for (const model of models) {
|
|
97
|
-
files.push({
|
|
98
|
-
path: resolve(typesDir, 'models', `${model.key}.ts`),
|
|
99
|
-
content: generateModelTypes(model, models),
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
// 3. Model index
|
|
103
|
-
files.push({
|
|
104
|
-
path: resolve(typesDir, 'models', 'index.ts'),
|
|
105
|
-
content: generateModelIndex(models),
|
|
106
|
-
});
|
|
107
|
-
// 4. Customer profile types
|
|
108
|
-
if (hasCustomerProfile) {
|
|
109
|
-
files.push({
|
|
110
|
-
path: resolve(typesDir, 'customer-profile.ts'),
|
|
111
|
-
content: generateCustomerProfileTypes(cpSchema),
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
// 5. Main index
|
|
115
|
-
files.push({
|
|
116
|
-
path: resolve(typesDir, 'index.ts'),
|
|
117
|
-
content: generateMainIndex(hasCustomerProfile),
|
|
118
|
-
});
|
|
119
|
-
// ─── Documents (.graphql) ────────────────────────────────
|
|
120
|
-
// 6. Per-model GraphQL documents
|
|
121
|
-
for (const model of publicModels) {
|
|
122
|
-
files.push({
|
|
123
|
-
path: resolve(docsDir, `${model.key}.graphql`),
|
|
124
|
-
content: generateModelDocuments(model),
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
// 6a. Shared fragments
|
|
128
|
-
const hasSharingModels = publicModels.some((m) => m.config.sharing?.enabled);
|
|
129
|
-
if (hasSharingModels) {
|
|
130
|
-
files.push({
|
|
131
|
-
path: resolve(docsDir, '_shared.graphql'),
|
|
132
|
-
content: generateSharedFragments(),
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
// 6b. Customer profile GraphQL documents
|
|
136
|
-
files.push({
|
|
137
|
-
path: resolve(docsDir, 'customer-profile.graphql'),
|
|
138
|
-
content: generateCustomerProfileDocuments(),
|
|
139
|
-
});
|
|
140
|
-
// 6c. Static domain documents
|
|
141
|
-
const staticDocs = generateStaticDocuments(config.domains);
|
|
142
|
-
for (const doc of staticDocs) {
|
|
143
|
-
files.push({
|
|
144
|
-
path: resolve(docsDir, doc.filename),
|
|
145
|
-
content: doc.content,
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
// 6d. Public schema (for consumer codegen)
|
|
149
|
-
if (publicSchema) {
|
|
150
|
-
files.push({
|
|
151
|
-
path: resolve(docsDir, 'public-schema.graphql'),
|
|
152
|
-
content: publicSchema,
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
// ─── Typed Operations ────────────────────────────────────
|
|
156
|
-
// 7. Operations common types
|
|
157
|
-
const typesRelPath = computeTypesRelPath(opsDir, typesDir);
|
|
158
|
-
files.push({
|
|
159
|
-
path: resolve(opsDir, '_common.ts'),
|
|
160
|
-
content: generateTypedOperationsCommon(typesRelPath),
|
|
161
|
-
});
|
|
162
|
-
// 7a. Per-model typed operations
|
|
163
|
-
for (const model of publicModels) {
|
|
164
|
-
files.push({
|
|
165
|
-
path: resolve(opsDir, `${model.key}.ts`),
|
|
166
|
-
content: generateTypedOperations(model, typesRelPath),
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
// 7b. Customer profile operations
|
|
170
|
-
if (hasCustomerProfile) {
|
|
171
|
-
files.push({
|
|
172
|
-
path: resolve(opsDir, 'customer-profile.ts'),
|
|
173
|
-
content: generateCustomerProfileOperations(typesRelPath),
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
// 7c. Operations index
|
|
177
|
-
files.push({
|
|
178
|
-
path: resolve(opsDir, 'index.ts'),
|
|
179
|
-
content: generateTypedOperationsIndex(publicModels, hasCustomerProfile),
|
|
180
|
-
});
|
|
181
|
-
// ─── React Hooks (when target includes 'react') ─────────
|
|
182
|
-
if (hooksDir) {
|
|
183
|
-
for (const model of publicModels) {
|
|
184
|
-
files.push({
|
|
185
|
-
path: resolve(hooksDir, `${model.key}.ts`),
|
|
186
|
-
content: generateReactHooks(model),
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
if (hasCustomerProfile) {
|
|
190
|
-
files.push({
|
|
191
|
-
path: resolve(hooksDir, 'customer-profile.ts'),
|
|
192
|
-
content: generateCustomerProfileHooks(),
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
files.push({
|
|
196
|
-
path: resolve(hooksDir, 'index.ts'),
|
|
197
|
-
content: generateReactHooksIndex(publicModels, hasCustomerProfile),
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
// ─── Remix Loaders (when target includes 'remix') ───────
|
|
201
|
-
if (loadersDir) {
|
|
202
|
-
for (const model of publicModels) {
|
|
203
|
-
files.push({
|
|
204
|
-
path: resolve(loadersDir, `${model.key}.ts`),
|
|
205
|
-
content: generateRemixLoaders(model),
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
if (hasCustomerProfile) {
|
|
209
|
-
files.push({
|
|
210
|
-
path: resolve(loadersDir, 'customer-profile.ts'),
|
|
211
|
-
content: generateCustomerProfileLoaders(),
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
files.push({
|
|
215
|
-
path: resolve(loadersDir, 'index.ts'),
|
|
216
|
-
content: generateRemixLoadersIndex(publicModels, hasCustomerProfile),
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
// ─── Swift (when configured) ────────────────────────────
|
|
220
|
-
if (config.output.swift) {
|
|
221
|
-
const swiftDir = resolve(cwd, config.output.swift);
|
|
222
|
-
files.push({
|
|
223
|
-
path: resolve(swiftDir, 'FieldTypes.swift'),
|
|
224
|
-
content: generateSwiftFieldTypesFile(),
|
|
225
|
-
});
|
|
226
|
-
files.push({
|
|
227
|
-
path: resolve(swiftDir, 'ModelKeys.swift'),
|
|
228
|
-
content: generateSwiftModelKeys(models),
|
|
229
|
-
});
|
|
230
|
-
for (const model of models) {
|
|
231
|
-
const swiftTypeName = toPascalCase(model.key);
|
|
232
|
-
files.push({
|
|
233
|
-
path: resolve(swiftDir, `${swiftTypeName}.swift`),
|
|
234
|
-
content: generateSwiftModelFile(model),
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
if (hasCustomerProfile) {
|
|
238
|
-
files.push({
|
|
239
|
-
path: resolve(swiftDir, 'CustomerProfile.swift'),
|
|
240
|
-
content: generateSwiftCustomerProfileFile(cpSchema),
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
// ─── Output ─────────────────────────────────────────────
|
|
245
|
-
// Dry run
|
|
246
|
-
if (config.dryRun) {
|
|
247
|
-
console.log(chalk.bold('\nDry run — files that would be generated:\n'));
|
|
248
|
-
for (const file of files) {
|
|
249
|
-
const rel = file.path.replace(cwd + '/', '');
|
|
250
|
-
console.log(` ${chalk.green('+')} ${rel}`);
|
|
251
|
-
}
|
|
252
|
-
console.log(`\n${chalk.dim(`${files.length} file(s) total`)}`);
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
// Write files
|
|
256
|
-
await writeFiles(files, config.prettier);
|
|
257
|
-
// Summary
|
|
258
|
-
const modelCount = models.length;
|
|
259
|
-
const docCount = publicModels.length + staticDocs.length;
|
|
260
|
-
const opsCount = publicModels.length + (hasCustomerProfile ? 1 : 0) + 2; // +2 for _common + index
|
|
261
|
-
const hookCount = hooksDir
|
|
262
|
-
? publicModels.length + (hasCustomerProfile ? 1 : 0) + 1
|
|
263
|
-
: 0;
|
|
264
|
-
const loaderCount = loadersDir
|
|
265
|
-
? publicModels.length + (hasCustomerProfile ? 1 : 0) + 1
|
|
266
|
-
: 0;
|
|
267
|
-
const swiftCount = config.output.swift ? models.length + 2 : 0;
|
|
268
|
-
const cpSuffix = hasCustomerProfile ? ', customer profile' : '';
|
|
269
|
-
console.log(chalk.green(`\nGenerated ${files.length} file(s)`) +
|
|
270
|
-
chalk.dim(` (${modelCount} type(s), ${docCount} document(s), ${opsCount} operation(s)${cpSuffix}${hookCount > 0 ? `, ${hookCount} hook(s)` : ''}${loaderCount > 0 ? `, ${loaderCount} loader(s)` : ''}${swiftCount > 0 ? `, ${swiftCount} Swift file(s)` : ''})`));
|
|
271
|
-
console.log(chalk.dim(` Types: ${typesDir}`));
|
|
272
|
-
console.log(chalk.dim(` Documents: ${docsDir}`));
|
|
273
|
-
console.log(chalk.dim(` Operations: ${opsDir}`));
|
|
274
|
-
if (hooksDir) {
|
|
275
|
-
console.log(chalk.dim(` Hooks: ${hooksDir}`));
|
|
276
|
-
}
|
|
277
|
-
if (loadersDir) {
|
|
278
|
-
console.log(chalk.dim(` Loaders: ${loadersDir}`));
|
|
279
|
-
}
|
|
280
|
-
if (config.output.swift) {
|
|
281
|
-
console.log(chalk.dim(` Swift: ${resolve(cwd, config.output.swift)}`));
|
|
282
|
-
}
|
|
283
|
-
}));
|
|
284
|
-
}
|
|
285
|
-
function generateMainIndex(includeCustomerProfile) {
|
|
286
|
-
let code = `/**
|
|
287
|
-
* Generated types and configs
|
|
288
|
-
*
|
|
289
|
-
* @generated by foir — DO NOT EDIT MANUALLY
|
|
290
|
-
*/
|
|
291
|
-
|
|
292
|
-
export * from './field-types.js';
|
|
293
|
-
export * from './config.js';
|
|
294
|
-
export * from './models/index.js';
|
|
295
|
-
`;
|
|
296
|
-
if (includeCustomerProfile) {
|
|
297
|
-
code += `export * from './customer-profile.js';\n`;
|
|
298
|
-
}
|
|
299
|
-
return code;
|
|
300
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../src/commands/records.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AA6BtD,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,aAAa,GAC9B,IAAI,CAuZN"}
|
package/dist/commands/records.js
DELETED
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
import { withErrorHandler } from '../lib/errors.js';
|
|
2
|
-
import { createClient } from '../lib/client.js';
|
|
3
|
-
import { formatOutput, formatList, timeAgo, success } from '../lib/output.js';
|
|
4
|
-
import { parseInputData, parseFilters, parseSort, isUUID, confirmAction, } from '../lib/input.js';
|
|
5
|
-
import { ListRecordsDocument, GetRecordDocument, GetRecordResolvedDocument, GetRecordByKeyDocument, GetRecordByKeyResolvedDocument, CreateRecordDocument, UpdateRecordDocument, DeleteRecordDocument, PublishVersionDocument, UnpublishRecordDocument, DuplicateRecordDocument, CreateVersionDocument, CreateVariantDocument, RecordVersionsDocument, RecordVariantsDocument, } from '../graphql/generated.js';
|
|
6
|
-
export function registerRecordsCommands(program, globalOpts) {
|
|
7
|
-
const records = program.command('records').description('Manage records');
|
|
8
|
-
// list
|
|
9
|
-
records
|
|
10
|
-
.command('list <modelKey>')
|
|
11
|
-
.description('List records for a model')
|
|
12
|
-
.option('--filter <expr>', 'Filter expression (e.g. status=active)')
|
|
13
|
-
.option('--sort <expr>', 'Sort expression (e.g. createdAt:desc)')
|
|
14
|
-
.option('--limit <n>', 'Max results', '20')
|
|
15
|
-
.option('--offset <n>', 'Skip results', '0')
|
|
16
|
-
.action(withErrorHandler(globalOpts, async (modelKey, cmdOpts) => {
|
|
17
|
-
const opts = globalOpts();
|
|
18
|
-
const client = await createClient(opts);
|
|
19
|
-
const variables = {
|
|
20
|
-
modelKey,
|
|
21
|
-
limit: parseInt(cmdOpts.limit ?? '20', 10),
|
|
22
|
-
offset: parseInt(cmdOpts.offset ?? '0', 10),
|
|
23
|
-
};
|
|
24
|
-
if (cmdOpts.filter)
|
|
25
|
-
variables.filters = parseFilters(cmdOpts.filter);
|
|
26
|
-
if (cmdOpts.sort)
|
|
27
|
-
variables.sort = parseSort(cmdOpts.sort);
|
|
28
|
-
const data = await client.request(ListRecordsDocument, variables);
|
|
29
|
-
formatList(data.records.items, opts, {
|
|
30
|
-
columns: [
|
|
31
|
-
{ key: 'id', header: 'ID', width: 28 },
|
|
32
|
-
{ key: 'naturalKey', header: 'Key', width: 24 },
|
|
33
|
-
{ key: 'versionNumber', header: 'Version', width: 8 },
|
|
34
|
-
{
|
|
35
|
-
key: 'updatedAt',
|
|
36
|
-
header: 'Updated',
|
|
37
|
-
width: 12,
|
|
38
|
-
format: (v) => timeAgo(v),
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
total: data.records.total,
|
|
42
|
-
});
|
|
43
|
-
}));
|
|
44
|
-
// get
|
|
45
|
-
records
|
|
46
|
-
.command('get <modelKey> <idOrKey>')
|
|
47
|
-
.description('Get a record by ID or natural key')
|
|
48
|
-
.option('--resolved', 'Include resolved content (published version)')
|
|
49
|
-
.option('--preview', 'Resolve latest draft instead of published version')
|
|
50
|
-
.option('--locale <locale>', 'Locale for field translations')
|
|
51
|
-
.action(withErrorHandler(globalOpts, async (modelKey, idOrKey, cmdOpts) => {
|
|
52
|
-
const opts = globalOpts();
|
|
53
|
-
const client = await createClient(opts);
|
|
54
|
-
let result;
|
|
55
|
-
const useResolved = !!cmdOpts.resolved || !!cmdOpts.preview;
|
|
56
|
-
if (isUUID(idOrKey)) {
|
|
57
|
-
if (useResolved) {
|
|
58
|
-
const variables = { id: idOrKey };
|
|
59
|
-
if (cmdOpts.locale)
|
|
60
|
-
variables.locale = cmdOpts.locale;
|
|
61
|
-
if (cmdOpts.preview)
|
|
62
|
-
variables.preview = true;
|
|
63
|
-
const data = await client.request(GetRecordResolvedDocument, variables);
|
|
64
|
-
result = data.record;
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
const data = await client.request(GetRecordDocument, {
|
|
68
|
-
id: idOrKey,
|
|
69
|
-
});
|
|
70
|
-
result = data.record;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
if (useResolved) {
|
|
75
|
-
const variables = {
|
|
76
|
-
modelKey,
|
|
77
|
-
naturalKey: idOrKey,
|
|
78
|
-
};
|
|
79
|
-
if (cmdOpts.locale)
|
|
80
|
-
variables.locale = cmdOpts.locale;
|
|
81
|
-
if (cmdOpts.preview)
|
|
82
|
-
variables.preview = true;
|
|
83
|
-
const data = await client.request(GetRecordByKeyResolvedDocument, variables);
|
|
84
|
-
result = data.recordByKey;
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
const data = await client.request(GetRecordByKeyDocument, {
|
|
88
|
-
modelKey,
|
|
89
|
-
naturalKey: idOrKey,
|
|
90
|
-
});
|
|
91
|
-
result = data.recordByKey;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (!result) {
|
|
95
|
-
throw new Error(`Record "${idOrKey}" not found in model "${modelKey}".`);
|
|
96
|
-
}
|
|
97
|
-
formatOutput(result, opts);
|
|
98
|
-
}));
|
|
99
|
-
// create
|
|
100
|
-
records
|
|
101
|
-
.command('create <modelKey>')
|
|
102
|
-
.description('Create a new record')
|
|
103
|
-
.option('-d, --data <json>', 'Record data as JSON')
|
|
104
|
-
.option('-f, --file <path>', 'Read data from file')
|
|
105
|
-
.action(withErrorHandler(globalOpts, async (modelKey, cmdOpts) => {
|
|
106
|
-
const opts = globalOpts();
|
|
107
|
-
const client = await createClient(opts);
|
|
108
|
-
const inputData = await parseInputData(cmdOpts);
|
|
109
|
-
const input = { modelKey, ...inputData };
|
|
110
|
-
const data = await client.request(CreateRecordDocument, {
|
|
111
|
-
input,
|
|
112
|
-
});
|
|
113
|
-
formatOutput(data.createRecord, opts);
|
|
114
|
-
if (!(opts.json || opts.jsonl || opts.quiet)) {
|
|
115
|
-
success(`Created record ${data.createRecord.record.id}`);
|
|
116
|
-
}
|
|
117
|
-
}));
|
|
118
|
-
// update
|
|
119
|
-
records
|
|
120
|
-
.command('update <modelKey> <id>')
|
|
121
|
-
.description('Update a record')
|
|
122
|
-
.option('-d, --data <json>', 'Record data as JSON')
|
|
123
|
-
.option('-f, --file <path>', 'Read data from file')
|
|
124
|
-
.action(withErrorHandler(globalOpts, async (_modelKey, id, cmdOpts) => {
|
|
125
|
-
const opts = globalOpts();
|
|
126
|
-
const client = await createClient(opts);
|
|
127
|
-
const inputData = await parseInputData(cmdOpts);
|
|
128
|
-
const input = { id, ...inputData };
|
|
129
|
-
const data = await client.request(UpdateRecordDocument, { input });
|
|
130
|
-
formatOutput(data.updateRecord, opts);
|
|
131
|
-
if (!(opts.json || opts.jsonl || opts.quiet)) {
|
|
132
|
-
success(`Updated record ${id}`);
|
|
133
|
-
}
|
|
134
|
-
}));
|
|
135
|
-
// delete
|
|
136
|
-
records
|
|
137
|
-
.command('delete <modelKey> <id>')
|
|
138
|
-
.description('Delete a record')
|
|
139
|
-
.option('--confirm', 'Skip confirmation prompt')
|
|
140
|
-
.action(withErrorHandler(globalOpts, async (_modelKey, id, cmdOpts) => {
|
|
141
|
-
const opts = globalOpts();
|
|
142
|
-
const confirmed = await confirmAction(`Delete record ${id}?`, {
|
|
143
|
-
confirm: !!cmdOpts.confirm,
|
|
144
|
-
});
|
|
145
|
-
if (!confirmed) {
|
|
146
|
-
console.log('Aborted.');
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
const client = await createClient(opts);
|
|
150
|
-
const data = await client.request(DeleteRecordDocument, { id });
|
|
151
|
-
formatOutput(data.deleteRecord, opts);
|
|
152
|
-
if (!(opts.json || opts.jsonl || opts.quiet)) {
|
|
153
|
-
success(`Deleted record ${id}`);
|
|
154
|
-
}
|
|
155
|
-
}));
|
|
156
|
-
// publish
|
|
157
|
-
records
|
|
158
|
-
.command('publish <versionId>')
|
|
159
|
-
.description('Publish a record version')
|
|
160
|
-
.action(withErrorHandler(globalOpts, async (versionId) => {
|
|
161
|
-
const opts = globalOpts();
|
|
162
|
-
const client = await createClient(opts);
|
|
163
|
-
await client.request(PublishVersionDocument, { versionId });
|
|
164
|
-
if (opts.json || opts.jsonl) {
|
|
165
|
-
formatOutput({ published: true, versionId }, opts);
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
success(`Published version ${versionId}`);
|
|
169
|
-
}
|
|
170
|
-
}));
|
|
171
|
-
// unpublish
|
|
172
|
-
records
|
|
173
|
-
.command('unpublish <id>')
|
|
174
|
-
.description('Unpublish a record')
|
|
175
|
-
.action(withErrorHandler(globalOpts, async (id) => {
|
|
176
|
-
const opts = globalOpts();
|
|
177
|
-
const client = await createClient(opts);
|
|
178
|
-
await client.request(UnpublishRecordDocument, { id });
|
|
179
|
-
if (opts.json || opts.jsonl) {
|
|
180
|
-
formatOutput({ unpublished: true, id }, opts);
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
success(`Unpublished record ${id}`);
|
|
184
|
-
}
|
|
185
|
-
}));
|
|
186
|
-
// duplicate
|
|
187
|
-
records
|
|
188
|
-
.command('duplicate <modelKey> <id>')
|
|
189
|
-
.description('Duplicate a record')
|
|
190
|
-
.option('--natural-key <key>', 'Natural key for the duplicate')
|
|
191
|
-
.action(withErrorHandler(globalOpts, async (_modelKey, id, cmdOpts) => {
|
|
192
|
-
const opts = globalOpts();
|
|
193
|
-
const client = await createClient(opts);
|
|
194
|
-
const naturalKey = cmdOpts.naturalKey ?? `${id}-copy`;
|
|
195
|
-
const data = await client.request(DuplicateRecordDocument, {
|
|
196
|
-
input: { recordId: id, naturalKey },
|
|
197
|
-
});
|
|
198
|
-
formatOutput(data.duplicateRecord, opts);
|
|
199
|
-
if (!(opts.json || opts.jsonl || opts.quiet)) {
|
|
200
|
-
success(`Duplicated → ${data.duplicateRecord.record.id}`);
|
|
201
|
-
}
|
|
202
|
-
}));
|
|
203
|
-
// versions
|
|
204
|
-
records
|
|
205
|
-
.command('versions <id>')
|
|
206
|
-
.description('List versions for a record')
|
|
207
|
-
.option('--limit <n>', 'Max results', '20')
|
|
208
|
-
.action(withErrorHandler(globalOpts, async (parentId, cmdOpts) => {
|
|
209
|
-
const opts = globalOpts();
|
|
210
|
-
const client = await createClient(opts);
|
|
211
|
-
const data = await client.request(RecordVersionsDocument, {
|
|
212
|
-
parentId,
|
|
213
|
-
limit: parseInt(cmdOpts.limit ?? '20', 10),
|
|
214
|
-
});
|
|
215
|
-
formatList(data.recordVersions.items, opts, {
|
|
216
|
-
columns: [
|
|
217
|
-
{ key: 'id', header: 'Version ID', width: 28 },
|
|
218
|
-
{ key: 'versionNumber', header: '#', width: 5 },
|
|
219
|
-
{ key: 'changeDescription', header: 'Description', width: 30 },
|
|
220
|
-
{
|
|
221
|
-
key: 'createdAt',
|
|
222
|
-
header: 'Created',
|
|
223
|
-
width: 12,
|
|
224
|
-
format: (v) => timeAgo(v),
|
|
225
|
-
},
|
|
226
|
-
],
|
|
227
|
-
});
|
|
228
|
-
}));
|
|
229
|
-
// variants
|
|
230
|
-
records
|
|
231
|
-
.command('variants <recordId>')
|
|
232
|
-
.description('List variants for a record')
|
|
233
|
-
.action(withErrorHandler(globalOpts, async (recordId) => {
|
|
234
|
-
const opts = globalOpts();
|
|
235
|
-
const client = await createClient(opts);
|
|
236
|
-
const data = await client.request(RecordVariantsDocument, { recordId });
|
|
237
|
-
formatList(data.recordVariants.items, opts, {
|
|
238
|
-
columns: [
|
|
239
|
-
{ key: 'id', header: 'Variant ID', width: 28 },
|
|
240
|
-
{ key: 'variantKey', header: 'Key', width: 20 },
|
|
241
|
-
{ key: 'isDefault', header: 'Default', width: 8 },
|
|
242
|
-
{
|
|
243
|
-
key: 'createdAt',
|
|
244
|
-
header: 'Created',
|
|
245
|
-
width: 12,
|
|
246
|
-
format: (v) => timeAgo(v),
|
|
247
|
-
},
|
|
248
|
-
],
|
|
249
|
-
});
|
|
250
|
-
}));
|
|
251
|
-
// create-version
|
|
252
|
-
records
|
|
253
|
-
.command('create-version <parentId>')
|
|
254
|
-
.description('Create a new version on a versioned record (or variant). parentId is the record or variant ID.')
|
|
255
|
-
.option('-d, --data <json>', 'Version content as JSON')
|
|
256
|
-
.option('-f, --file <path>', 'Read content from file')
|
|
257
|
-
.option('-m, --message <msg>', 'Change description')
|
|
258
|
-
.option('--source-version <id>', 'Source version ID to base off')
|
|
259
|
-
.action(withErrorHandler(globalOpts, async (parentId, cmdOpts) => {
|
|
260
|
-
const opts = globalOpts();
|
|
261
|
-
const client = await createClient(opts);
|
|
262
|
-
const inputData = await parseInputData(cmdOpts);
|
|
263
|
-
const input = {
|
|
264
|
-
parentId,
|
|
265
|
-
content: inputData,
|
|
266
|
-
};
|
|
267
|
-
if (cmdOpts.message)
|
|
268
|
-
input.changeDescription = cmdOpts.message;
|
|
269
|
-
if (cmdOpts.sourceVersion)
|
|
270
|
-
input.sourceVersionId = cmdOpts.sourceVersion;
|
|
271
|
-
const data = await client.request(CreateVersionDocument, {
|
|
272
|
-
input,
|
|
273
|
-
});
|
|
274
|
-
formatOutput(data.createVersion, opts);
|
|
275
|
-
if (!(opts.json || opts.jsonl || opts.quiet)) {
|
|
276
|
-
success(`Created version ${data.createVersion.id}`);
|
|
277
|
-
}
|
|
278
|
-
}));
|
|
279
|
-
// create-variant
|
|
280
|
-
records
|
|
281
|
-
.command('create-variant <recordId>')
|
|
282
|
-
.description('Create a new variant on a record')
|
|
283
|
-
.requiredOption('--key <variantKey>', 'Variant key (e.g. "uk-market")')
|
|
284
|
-
.option('--name <name>', 'Variant display name')
|
|
285
|
-
.option('--description <desc>', 'Variant description')
|
|
286
|
-
.option('--catalog-id <id>', 'Variant catalog entry ID')
|
|
287
|
-
.option('--priority <n>', 'Priority (lower = higher priority)')
|
|
288
|
-
.option('--default', 'Set as default variant')
|
|
289
|
-
.action(withErrorHandler(globalOpts, async (recordId, cmdOpts) => {
|
|
290
|
-
const opts = globalOpts();
|
|
291
|
-
const client = await createClient(opts);
|
|
292
|
-
const input = {
|
|
293
|
-
recordId,
|
|
294
|
-
variantKey: cmdOpts.key,
|
|
295
|
-
};
|
|
296
|
-
if (cmdOpts.name)
|
|
297
|
-
input.name = cmdOpts.name;
|
|
298
|
-
if (cmdOpts.description)
|
|
299
|
-
input.description = cmdOpts.description;
|
|
300
|
-
if (cmdOpts.catalogId)
|
|
301
|
-
input.catalogId = cmdOpts.catalogId;
|
|
302
|
-
if (cmdOpts.priority !== undefined)
|
|
303
|
-
input.priority = parseInt(cmdOpts.priority, 10);
|
|
304
|
-
if (cmdOpts.default)
|
|
305
|
-
input.isDefault = true;
|
|
306
|
-
const data = await client.request(CreateVariantDocument, {
|
|
307
|
-
input,
|
|
308
|
-
});
|
|
309
|
-
formatOutput(data.createVariant, opts);
|
|
310
|
-
if (!(opts.json || opts.jsonl || opts.quiet)) {
|
|
311
|
-
success(`Created variant ${data.createVariant.id}`);
|
|
312
|
-
}
|
|
313
|
-
}));
|
|
314
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schedules.d.ts","sourceRoot":"","sources":["../../src/commands/schedules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAgBtD,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,aAAa,GAC9B,IAAI,CAmLN"}
|