@eide/foir-cli 0.1.35 → 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 +7467 -42
- 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 -8
- 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 -177
- 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/playground.d.ts +0 -4
- package/dist/commands/playground.d.ts.map +0 -1
- package/dist/commands/playground.js +0 -270
- 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/register-commands.d.ts +0 -7
- package/dist/commands/register-commands.d.ts.map +0 -1
- package/dist/commands/register-commands.js +0 -259
- 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 -6074
- package/dist/graphql/generated.d.ts.map +0 -1
- package/dist/graphql/generated.js +0 -355
- 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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-config.d.ts","sourceRoot":"","sources":["../../src/commands/auth-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAStD,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,aAAa,GAC9B,IAAI,CA2CN"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { withErrorHandler } from '../lib/errors.js';
|
|
2
|
-
import { createClient } from '../lib/client.js';
|
|
3
|
-
import { formatOutput } from '../lib/output.js';
|
|
4
|
-
import { GetCustomerAuthConfigDocument, VerifyCustomerTokenDocument, } from '../graphql/generated.js';
|
|
5
|
-
export function registerAuthConfigCommands(program, globalOpts) {
|
|
6
|
-
const auth = program
|
|
7
|
-
.command('auth')
|
|
8
|
-
.description('Customer auth configuration');
|
|
9
|
-
// config
|
|
10
|
-
auth
|
|
11
|
-
.command('config')
|
|
12
|
-
.description('Get customer auth signing configuration')
|
|
13
|
-
.option('--show-key', 'Show the full signing key (masked by default)')
|
|
14
|
-
.action(withErrorHandler(globalOpts, async (cmdOpts) => {
|
|
15
|
-
const opts = globalOpts();
|
|
16
|
-
const client = await createClient(opts);
|
|
17
|
-
const data = await client.request(GetCustomerAuthConfigDocument);
|
|
18
|
-
const config = data.customerAuthConfig;
|
|
19
|
-
// Mask the signing key unless --show-key is passed
|
|
20
|
-
if (!cmdOpts.showKey && config.signingKey) {
|
|
21
|
-
const key = config.signingKey;
|
|
22
|
-
config.signingKey = key.slice(0, 4) + '…' + key.slice(-4);
|
|
23
|
-
}
|
|
24
|
-
formatOutput(config, opts);
|
|
25
|
-
}));
|
|
26
|
-
// verify-token
|
|
27
|
-
auth
|
|
28
|
-
.command('verify-token <token>')
|
|
29
|
-
.description('Verify a customer JWT token')
|
|
30
|
-
.action(withErrorHandler(globalOpts, async (token) => {
|
|
31
|
-
const opts = globalOpts();
|
|
32
|
-
const client = await createClient(opts);
|
|
33
|
-
const data = await client.request(VerifyCustomerTokenDocument, {
|
|
34
|
-
token,
|
|
35
|
-
});
|
|
36
|
-
formatOutput(data.verifyCustomerToken, opts);
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-providers.d.ts","sourceRoot":"","sources":["../../src/commands/auth-providers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAsBtD,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,aAAa,GAC9B,IAAI,CAyQN"}
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { withErrorHandler } from '../lib/errors.js';
|
|
3
|
-
import { createClient } from '../lib/client.js';
|
|
4
|
-
import { formatOutput, formatList, success } from '../lib/output.js';
|
|
5
|
-
import { parseInputData, confirmAction } from '../lib/input.js';
|
|
6
|
-
import { ListAuthProvidersDocument, GetAuthProviderDocument, CreateAuthProviderDocument, UpdateAuthProviderDocument, DeleteAuthProviderDocument, } from '../graphql/generated.js';
|
|
7
|
-
const VALID_TYPES = [
|
|
8
|
-
'OAUTH2',
|
|
9
|
-
'TOKEN_SSO',
|
|
10
|
-
'SAML',
|
|
11
|
-
'OTP_VERIFY',
|
|
12
|
-
'OIDC',
|
|
13
|
-
'EXTERNAL',
|
|
14
|
-
];
|
|
15
|
-
export function registerAuthProvidersCommands(program, globalOpts) {
|
|
16
|
-
const authProviders = program
|
|
17
|
-
.command('auth-providers')
|
|
18
|
-
.description('Manage customer auth providers');
|
|
19
|
-
// list
|
|
20
|
-
authProviders
|
|
21
|
-
.command('list')
|
|
22
|
-
.description('List auth providers')
|
|
23
|
-
.option('--enabled-only', 'Show only enabled providers')
|
|
24
|
-
.action(withErrorHandler(globalOpts, async (cmdOpts) => {
|
|
25
|
-
const opts = globalOpts();
|
|
26
|
-
const client = await createClient(opts);
|
|
27
|
-
const data = await client.request(ListAuthProvidersDocument, {
|
|
28
|
-
enabledOnly: !!cmdOpts.enabledOnly,
|
|
29
|
-
});
|
|
30
|
-
formatList(data.customerAuthProviders, opts, {
|
|
31
|
-
columns: [
|
|
32
|
-
{ key: 'id', header: 'ID', width: 28 },
|
|
33
|
-
{ key: 'key', header: 'Key', width: 20 },
|
|
34
|
-
{ key: 'name', header: 'Name', width: 24 },
|
|
35
|
-
{ key: 'type', header: 'Type', width: 12 },
|
|
36
|
-
{
|
|
37
|
-
key: 'enabled',
|
|
38
|
-
header: 'Enabled',
|
|
39
|
-
width: 8,
|
|
40
|
-
format: (v) => (v ? 'yes' : 'no'),
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
key: 'isDefault',
|
|
44
|
-
header: 'Default',
|
|
45
|
-
width: 8,
|
|
46
|
-
format: (v) => (v ? 'yes' : 'no'),
|
|
47
|
-
},
|
|
48
|
-
{ key: 'priority', header: 'Priority', width: 8 },
|
|
49
|
-
],
|
|
50
|
-
});
|
|
51
|
-
}));
|
|
52
|
-
// get
|
|
53
|
-
authProviders
|
|
54
|
-
.command('get <id>')
|
|
55
|
-
.description('Get auth provider details')
|
|
56
|
-
.action(withErrorHandler(globalOpts, async (id) => {
|
|
57
|
-
const opts = globalOpts();
|
|
58
|
-
const client = await createClient(opts);
|
|
59
|
-
const data = await client.request(GetAuthProviderDocument, { id });
|
|
60
|
-
if (!data.customerAuthProvider) {
|
|
61
|
-
throw new Error(`Auth provider not found: ${id}`);
|
|
62
|
-
}
|
|
63
|
-
if (opts.json || opts.jsonl) {
|
|
64
|
-
formatOutput(data.customerAuthProvider, opts);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
const p = data.customerAuthProvider;
|
|
68
|
-
console.log(chalk.bold(`${p.name}`) + chalk.gray(` (${p.key})`));
|
|
69
|
-
console.log(` Type: ${p.type}`);
|
|
70
|
-
console.log(` Enabled: ${p.enabled ? 'yes' : 'no'}`);
|
|
71
|
-
console.log(` Default: ${p.isDefault ? 'yes' : 'no'}`);
|
|
72
|
-
console.log(` Priority: ${p.priority}`);
|
|
73
|
-
console.log(` Verify External Customer: ${p.verifyExternalCustomer ? 'yes' : 'no'}`);
|
|
74
|
-
console.log(` Capture Metadata: ${p.captureMetadata ? 'yes' : 'no'}`);
|
|
75
|
-
if (p.configDisplay) {
|
|
76
|
-
console.log(` Config:`);
|
|
77
|
-
console.log(chalk.gray(JSON.stringify(p.configDisplay, null, 2).replace(/^/gm, ' ')));
|
|
78
|
-
}
|
|
79
|
-
console.log(chalk.gray(` Created: ${p.createdAt}`));
|
|
80
|
-
console.log(chalk.gray(` Updated: ${p.updatedAt}`));
|
|
81
|
-
}
|
|
82
|
-
}));
|
|
83
|
-
// create
|
|
84
|
-
authProviders
|
|
85
|
-
.command('create')
|
|
86
|
-
.description('Create a new auth provider')
|
|
87
|
-
.requiredOption('--key <key>', 'Unique provider key')
|
|
88
|
-
.requiredOption('--name <name>', 'Display name')
|
|
89
|
-
.requiredOption('--type <type>', `Provider type (${VALID_TYPES.join(', ')})`)
|
|
90
|
-
.option('-d, --data <json>', 'Provider config as JSON string')
|
|
91
|
-
.option('--file <path>', 'Provider config from JSON file')
|
|
92
|
-
.option('--enabled', 'Enable the provider')
|
|
93
|
-
.option('--is-default', 'Set as default provider')
|
|
94
|
-
.option('--priority <n>', 'Display priority (higher = first)')
|
|
95
|
-
.option('--verify-external-customer', 'Verify customer exists in external system')
|
|
96
|
-
.option('--capture-metadata', 'Capture metadata from provider during auth')
|
|
97
|
-
.action(withErrorHandler(globalOpts, async (cmdOpts) => {
|
|
98
|
-
const opts = globalOpts();
|
|
99
|
-
const type = cmdOpts.type.toUpperCase();
|
|
100
|
-
if (!VALID_TYPES.includes(type)) {
|
|
101
|
-
throw new Error(`Invalid type "${cmdOpts.type}". Valid types: ${VALID_TYPES.join(', ')}`);
|
|
102
|
-
}
|
|
103
|
-
const config = await parseInputData({
|
|
104
|
-
data: cmdOpts.data,
|
|
105
|
-
file: cmdOpts.file,
|
|
106
|
-
});
|
|
107
|
-
const input = {
|
|
108
|
-
key: cmdOpts.key,
|
|
109
|
-
name: cmdOpts.name,
|
|
110
|
-
type,
|
|
111
|
-
config,
|
|
112
|
-
};
|
|
113
|
-
if (cmdOpts.enabled !== undefined)
|
|
114
|
-
input.enabled = true;
|
|
115
|
-
if (cmdOpts.isDefault !== undefined)
|
|
116
|
-
input.isDefault = true;
|
|
117
|
-
if (cmdOpts.priority !== undefined)
|
|
118
|
-
input.priority = parseInt(String(cmdOpts.priority), 10);
|
|
119
|
-
if (cmdOpts.verifyExternalCustomer !== undefined)
|
|
120
|
-
input.verifyExternalCustomer = true;
|
|
121
|
-
if (cmdOpts.captureMetadata !== undefined)
|
|
122
|
-
input.captureMetadata = true;
|
|
123
|
-
const client = await createClient(opts);
|
|
124
|
-
const data = await client.request(CreateAuthProviderDocument, {
|
|
125
|
-
input,
|
|
126
|
-
});
|
|
127
|
-
if (opts.json || opts.jsonl) {
|
|
128
|
-
formatOutput(data.createCustomerAuthProvider, opts);
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
success(`Created auth provider: ${data.createCustomerAuthProvider.name} (${data.createCustomerAuthProvider.key})`);
|
|
132
|
-
}
|
|
133
|
-
}));
|
|
134
|
-
// update
|
|
135
|
-
authProviders
|
|
136
|
-
.command('update <id>')
|
|
137
|
-
.description('Update an auth provider')
|
|
138
|
-
.option('--name <name>', 'Display name')
|
|
139
|
-
.option('-d, --data <json>', 'Provider config as JSON string')
|
|
140
|
-
.option('--file <path>', 'Provider config from JSON file')
|
|
141
|
-
.option('--enabled', 'Enable the provider')
|
|
142
|
-
.option('--no-enabled', 'Disable the provider')
|
|
143
|
-
.option('--is-default', 'Set as default provider')
|
|
144
|
-
.option('--priority <n>', 'Display priority (higher = first)')
|
|
145
|
-
.option('--verify-external-customer', 'Verify customer exists in external system')
|
|
146
|
-
.option('--capture-metadata', 'Capture metadata from provider during auth')
|
|
147
|
-
.action(withErrorHandler(globalOpts, async (id, cmdOpts) => {
|
|
148
|
-
const opts = globalOpts();
|
|
149
|
-
const input = {};
|
|
150
|
-
if (cmdOpts.name !== undefined)
|
|
151
|
-
input.name = cmdOpts.name;
|
|
152
|
-
if (cmdOpts.isDefault !== undefined)
|
|
153
|
-
input.isDefault = true;
|
|
154
|
-
if (cmdOpts.priority !== undefined)
|
|
155
|
-
input.priority = parseInt(String(cmdOpts.priority), 10);
|
|
156
|
-
if (cmdOpts.verifyExternalCustomer !== undefined)
|
|
157
|
-
input.verifyExternalCustomer = true;
|
|
158
|
-
if (cmdOpts.captureMetadata !== undefined)
|
|
159
|
-
input.captureMetadata = true;
|
|
160
|
-
// Commander's --no-enabled sets enabled=false, --enabled sets enabled=true
|
|
161
|
-
if (cmdOpts.enabled !== undefined) {
|
|
162
|
-
input.enabled = !!cmdOpts.enabled;
|
|
163
|
-
}
|
|
164
|
-
// Config from --data or --file (optional for update)
|
|
165
|
-
if (cmdOpts.data || cmdOpts.file) {
|
|
166
|
-
input.config = await parseInputData({
|
|
167
|
-
data: cmdOpts.data,
|
|
168
|
-
file: cmdOpts.file,
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
if (Object.keys(input).length === 0) {
|
|
172
|
-
throw new Error('No update fields provided.');
|
|
173
|
-
}
|
|
174
|
-
const client = await createClient(opts);
|
|
175
|
-
const data = await client.request(UpdateAuthProviderDocument, {
|
|
176
|
-
id,
|
|
177
|
-
input,
|
|
178
|
-
});
|
|
179
|
-
if (opts.json || opts.jsonl) {
|
|
180
|
-
formatOutput(data.updateCustomerAuthProvider, opts);
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
success(`Updated auth provider: ${data.updateCustomerAuthProvider.name} (${data.updateCustomerAuthProvider.key})`);
|
|
184
|
-
}
|
|
185
|
-
}));
|
|
186
|
-
// delete
|
|
187
|
-
authProviders
|
|
188
|
-
.command('delete <id>')
|
|
189
|
-
.description('Delete an auth provider')
|
|
190
|
-
.option('--confirm', 'Skip confirmation prompt')
|
|
191
|
-
.action(withErrorHandler(globalOpts, async (id, cmdOpts) => {
|
|
192
|
-
const opts = globalOpts();
|
|
193
|
-
const confirmed = await confirmAction(`Delete auth provider ${id}? This cannot be undone.`, { confirm: !!cmdOpts.confirm });
|
|
194
|
-
if (!confirmed) {
|
|
195
|
-
console.log('Aborted.');
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
const client = await createClient(opts);
|
|
199
|
-
const data = await client.request(DeleteAuthProviderDocument, { id });
|
|
200
|
-
if (opts.json || opts.jsonl) {
|
|
201
|
-
formatOutput({ deleted: data.deleteCustomerAuthProvider, id }, opts);
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
success(`Deleted auth provider ${id}`);
|
|
205
|
-
}
|
|
206
|
-
}));
|
|
207
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/commands/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAC;AA8B1B,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,aAAa,GAC9B,IAAI,CAkIN"}
|
package/dist/commands/context.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { getCredentials, getProjectContext, writeProjectContext, } from '../auth/credentials.js';
|
|
2
|
-
import { getApiUrl, getGraphQLEndpoint, } from '../lib/config.js';
|
|
3
|
-
import { withErrorHandler } from '../lib/errors.js';
|
|
4
|
-
import { formatList, success } from '../lib/output.js';
|
|
5
|
-
async function gqlRequest(apiUrl, accessToken, query, extraHeaders) {
|
|
6
|
-
const response = await fetch(getGraphQLEndpoint(apiUrl), {
|
|
7
|
-
method: 'POST',
|
|
8
|
-
headers: {
|
|
9
|
-
'Content-Type': 'application/json',
|
|
10
|
-
Authorization: `Bearer ${accessToken}`,
|
|
11
|
-
...extraHeaders,
|
|
12
|
-
},
|
|
13
|
-
body: JSON.stringify({ query }),
|
|
14
|
-
});
|
|
15
|
-
if (!response.ok)
|
|
16
|
-
throw new Error(`Request failed: ${response.statusText}`);
|
|
17
|
-
const result = (await response.json());
|
|
18
|
-
if (result.errors?.length)
|
|
19
|
-
throw new Error(result.errors[0].message);
|
|
20
|
-
return result.data;
|
|
21
|
-
}
|
|
22
|
-
export function registerContextCommands(program, globalOpts) {
|
|
23
|
-
const context = program
|
|
24
|
-
.command('context')
|
|
25
|
-
.description('Manage project and tenant context');
|
|
26
|
-
// projects list
|
|
27
|
-
context
|
|
28
|
-
.command('projects')
|
|
29
|
-
.description('List available projects')
|
|
30
|
-
.action(withErrorHandler(globalOpts, async () => {
|
|
31
|
-
const opts = globalOpts();
|
|
32
|
-
const credentials = await getCredentials();
|
|
33
|
-
if (!credentials)
|
|
34
|
-
throw new Error('Not logged in. Run `foir login` first.');
|
|
35
|
-
const apiUrl = getApiUrl(opts);
|
|
36
|
-
const data = await gqlRequest(apiUrl, credentials.accessToken, `query { sessionContext { projectId availableProjects { id name tenantId } } }`);
|
|
37
|
-
const projectContext = await getProjectContext();
|
|
38
|
-
const projects = data.sessionContext.availableProjects.map((p) => ({
|
|
39
|
-
...p,
|
|
40
|
-
current: p.id === projectContext?.id ? '*' : '',
|
|
41
|
-
}));
|
|
42
|
-
formatList(projects, opts, {
|
|
43
|
-
columns: [
|
|
44
|
-
{ key: 'current', header: '', width: 2 },
|
|
45
|
-
{ key: 'id', header: 'ID', width: 28 },
|
|
46
|
-
{ key: 'name', header: 'Name', width: 30 },
|
|
47
|
-
{ key: 'tenantId', header: 'Tenant', width: 28 },
|
|
48
|
-
],
|
|
49
|
-
});
|
|
50
|
-
}));
|
|
51
|
-
// switch project
|
|
52
|
-
context
|
|
53
|
-
.command('switch <projectId>')
|
|
54
|
-
.description('Switch to a different project')
|
|
55
|
-
.action(withErrorHandler(globalOpts, async (projectId) => {
|
|
56
|
-
const opts = globalOpts();
|
|
57
|
-
const credentials = await getCredentials();
|
|
58
|
-
if (!credentials)
|
|
59
|
-
throw new Error('Not logged in. Run `foir login` first.');
|
|
60
|
-
const apiUrl = getApiUrl(opts);
|
|
61
|
-
const data = await gqlRequest(apiUrl, credentials.accessToken, `query { sessionContext { availableProjects { id name tenantId } } }`);
|
|
62
|
-
const project = data.sessionContext.availableProjects.find((p) => p.id === projectId);
|
|
63
|
-
if (!project)
|
|
64
|
-
throw new Error(`Project "${projectId}" not found.`);
|
|
65
|
-
await writeProjectContext({
|
|
66
|
-
id: project.id,
|
|
67
|
-
name: project.name,
|
|
68
|
-
tenantId: project.tenantId,
|
|
69
|
-
});
|
|
70
|
-
success(`Switched to project: ${project.name}`);
|
|
71
|
-
console.log('Run `foir select-project` to provision a new API key for this project.');
|
|
72
|
-
}));
|
|
73
|
-
// tenants
|
|
74
|
-
context
|
|
75
|
-
.command('tenants')
|
|
76
|
-
.description('List available tenants')
|
|
77
|
-
.action(withErrorHandler(globalOpts, async () => {
|
|
78
|
-
const opts = globalOpts();
|
|
79
|
-
const credentials = await getCredentials();
|
|
80
|
-
if (!credentials)
|
|
81
|
-
throw new Error('Not logged in. Run `foir login` first.');
|
|
82
|
-
const apiUrl = getApiUrl(opts);
|
|
83
|
-
const data = await gqlRequest(apiUrl, credentials.accessToken, `query { sessionContext { availableTenants { id name } } }`);
|
|
84
|
-
formatList(data.sessionContext.availableTenants, opts, {
|
|
85
|
-
columns: [
|
|
86
|
-
{ key: 'id', header: 'ID', width: 28 },
|
|
87
|
-
{ key: 'name', header: 'Name', width: 30 },
|
|
88
|
-
],
|
|
89
|
-
});
|
|
90
|
-
}));
|
|
91
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-extension.d.ts","sourceRoot":"","sources":["../../src/commands/create-extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAgBtD,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,aAAa,GAC9B,IAAI,CA8DN"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import inquirer from 'inquirer';
|
|
3
|
-
import { withErrorHandler } from '../lib/errors.js';
|
|
4
|
-
import { scaffold } from '../scaffold/scaffold.js';
|
|
5
|
-
const EXTENSION_TYPES = [
|
|
6
|
-
'custom-editor',
|
|
7
|
-
'workflow',
|
|
8
|
-
'widget',
|
|
9
|
-
];
|
|
10
|
-
function isValidExtensionType(value) {
|
|
11
|
-
return EXTENSION_TYPES.includes(value);
|
|
12
|
-
}
|
|
13
|
-
export function registerCreateExtensionCommand(program, globalOpts) {
|
|
14
|
-
program
|
|
15
|
-
.command('create-extension [name]')
|
|
16
|
-
.description('Scaffold a new Foir extension')
|
|
17
|
-
.option('--type <type>', 'Extension type: custom-editor, workflow, widget')
|
|
18
|
-
.option('--api-url <url>', 'Platform API URL', 'http://localhost:4000/graphql')
|
|
19
|
-
.action(withErrorHandler(globalOpts, async (name, cmdOpts) => {
|
|
20
|
-
console.log();
|
|
21
|
-
console.log(chalk.bold(' Create Foir Extension'));
|
|
22
|
-
console.log(chalk.gray(' ---------------------'));
|
|
23
|
-
console.log();
|
|
24
|
-
// Resolve name — use arg or prompt
|
|
25
|
-
let extensionName = name;
|
|
26
|
-
if (!extensionName) {
|
|
27
|
-
const { inputName } = await inquirer.prompt([
|
|
28
|
-
{
|
|
29
|
-
type: 'input',
|
|
30
|
-
name: 'inputName',
|
|
31
|
-
message: 'Extension name:',
|
|
32
|
-
default: 'my-extension',
|
|
33
|
-
},
|
|
34
|
-
]);
|
|
35
|
-
extensionName = inputName;
|
|
36
|
-
}
|
|
37
|
-
// Resolve type — use flag or prompt
|
|
38
|
-
let extensionType;
|
|
39
|
-
if (cmdOpts?.type && isValidExtensionType(cmdOpts.type)) {
|
|
40
|
-
extensionType = cmdOpts.type;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
const { selectedType } = await inquirer.prompt([
|
|
44
|
-
{
|
|
45
|
-
type: 'list',
|
|
46
|
-
name: 'selectedType',
|
|
47
|
-
message: 'Extension type:',
|
|
48
|
-
choices: EXTENSION_TYPES,
|
|
49
|
-
default: 'custom-editor',
|
|
50
|
-
},
|
|
51
|
-
]);
|
|
52
|
-
extensionType = selectedType;
|
|
53
|
-
}
|
|
54
|
-
const apiUrl = cmdOpts?.apiUrl ?? 'http://localhost:4000/graphql';
|
|
55
|
-
console.log();
|
|
56
|
-
console.log(` Scaffolding ${chalk.cyan(`"${extensionName}"`)} (${extensionType})...`);
|
|
57
|
-
console.log();
|
|
58
|
-
await scaffold(extensionName, extensionType, apiUrl);
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customer-profiles.d.ts","sourceRoot":"","sources":["../../src/commands/customer-profiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAYtD,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,aAAa,GAC9B,IAAI,CAwIN"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { withErrorHandler } from '../lib/errors.js';
|
|
2
|
-
import { createClient } from '../lib/client.js';
|
|
3
|
-
import { formatOutput, success } from '../lib/output.js';
|
|
4
|
-
import { parseInputData } from '../lib/input.js';
|
|
5
|
-
import { GetCustomerProfileSchemaDocument, UpdateCustomerProfileSchemaDocument, GetCustomerProfileDocument, SetCustomerProfileDocument, } from '../graphql/generated.js';
|
|
6
|
-
export function registerCustomerProfilesCommands(program, globalOpts) {
|
|
7
|
-
const cp = program
|
|
8
|
-
.command('customer-profiles')
|
|
9
|
-
.alias('cp')
|
|
10
|
-
.description('Manage customer profile schema and profiles');
|
|
11
|
-
// --- Schema subcommands ---
|
|
12
|
-
const schema = cp
|
|
13
|
-
.command('schema')
|
|
14
|
-
.description('Manage the customer profile schema');
|
|
15
|
-
// schema get
|
|
16
|
-
schema
|
|
17
|
-
.command('get')
|
|
18
|
-
.description('Get the customer profile schema for the current project')
|
|
19
|
-
.action(withErrorHandler(globalOpts, async () => {
|
|
20
|
-
const opts = globalOpts();
|
|
21
|
-
const client = await createClient(opts);
|
|
22
|
-
const data = await client.request(GetCustomerProfileSchemaDocument);
|
|
23
|
-
if (!data.customerProfileSchema) {
|
|
24
|
-
if (opts.json || opts.jsonl) {
|
|
25
|
-
formatOutput(null, opts);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
console.log('No customer profile schema defined. Use "customer-profiles schema update" to create one.');
|
|
29
|
-
}
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
formatOutput(data.customerProfileSchema, opts);
|
|
33
|
-
}));
|
|
34
|
-
// schema update
|
|
35
|
-
schema
|
|
36
|
-
.command('update')
|
|
37
|
-
.description('Update the customer profile schema. Accepts a JSON object with "fields" (required) and "publicFields" (optional).')
|
|
38
|
-
.option('-d, --data <json>', 'Schema data as JSON')
|
|
39
|
-
.option('-f, --file <path>', 'Read data from file')
|
|
40
|
-
.action(withErrorHandler(globalOpts, async (cmdOpts) => {
|
|
41
|
-
const opts = globalOpts();
|
|
42
|
-
const client = await createClient(opts);
|
|
43
|
-
const inputData = await parseInputData(cmdOpts);
|
|
44
|
-
if (!inputData.fields || !Array.isArray(inputData.fields)) {
|
|
45
|
-
throw new Error('Input must be an object with a "fields" array. ' +
|
|
46
|
-
'Example: {"fields":[{"key":"name","label":"Name","type":"text"}],"publicFields":["name"]}');
|
|
47
|
-
}
|
|
48
|
-
const variables = {
|
|
49
|
-
fields: inputData.fields,
|
|
50
|
-
publicFields: inputData.publicFields ?? undefined,
|
|
51
|
-
};
|
|
52
|
-
const data = await client.request(UpdateCustomerProfileSchemaDocument, variables);
|
|
53
|
-
formatOutput(data.updateCustomerProfileSchema, opts);
|
|
54
|
-
if (!(opts.json || opts.jsonl || opts.quiet)) {
|
|
55
|
-
const version = data.updateCustomerProfileSchema.version;
|
|
56
|
-
success(`Updated customer profile schema (version ${version})`);
|
|
57
|
-
}
|
|
58
|
-
}));
|
|
59
|
-
// --- Profile subcommands ---
|
|
60
|
-
const profile = cp
|
|
61
|
-
.command('profile')
|
|
62
|
-
.description('Manage individual customer profiles');
|
|
63
|
-
// profile get
|
|
64
|
-
profile
|
|
65
|
-
.command('get <customerId>')
|
|
66
|
-
.description("Get a customer's profile data")
|
|
67
|
-
.action(withErrorHandler(globalOpts, async (customerId) => {
|
|
68
|
-
const opts = globalOpts();
|
|
69
|
-
const client = await createClient(opts);
|
|
70
|
-
const data = await client.request(GetCustomerProfileDocument, {
|
|
71
|
-
customerId,
|
|
72
|
-
});
|
|
73
|
-
if (!data.customerProfile) {
|
|
74
|
-
throw new Error(`No profile found for customer "${customerId}".`);
|
|
75
|
-
}
|
|
76
|
-
formatOutput(data.customerProfile, opts);
|
|
77
|
-
}));
|
|
78
|
-
// profile set
|
|
79
|
-
profile
|
|
80
|
-
.command('set <customerId>')
|
|
81
|
-
.description("Set a customer's profile data")
|
|
82
|
-
.option('-d, --data <json>', 'Profile data as JSON')
|
|
83
|
-
.option('-f, --file <path>', 'Read data from file')
|
|
84
|
-
.action(withErrorHandler(globalOpts, async (customerId, cmdOpts) => {
|
|
85
|
-
const opts = globalOpts();
|
|
86
|
-
const client = await createClient(opts);
|
|
87
|
-
const inputData = await parseInputData(cmdOpts);
|
|
88
|
-
// Accept either { data: {...} } or the raw data object
|
|
89
|
-
const profileData = inputData.data ?? inputData;
|
|
90
|
-
const data = await client.request(SetCustomerProfileDocument, {
|
|
91
|
-
customerId,
|
|
92
|
-
data: profileData,
|
|
93
|
-
});
|
|
94
|
-
formatOutput(data.setCustomerProfile, opts);
|
|
95
|
-
if (!(opts.json || opts.jsonl || opts.quiet)) {
|
|
96
|
-
success(`Set profile for customer ${customerId}`);
|
|
97
|
-
}
|
|
98
|
-
}));
|
|
99
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../../src/commands/customers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAatD,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,aAAa,GAC9B,IAAI,CAqJN"}
|