@eide/foir-cli 0.1.25 → 0.1.27
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 +0 -0
- package/dist/commands/extensions.d.ts.map +1 -1
- package/dist/commands/extensions.js +7 -1
- package/dist/graphql/generated.d.ts +26 -9
- package/dist/graphql/generated.d.ts.map +1 -1
- package/dist/lib/config-loader.d.ts +28 -0
- package/dist/lib/config-loader.d.ts.map +1 -0
- package/dist/lib/config-loader.js +49 -0
- package/dist/lib/extension-helpers.d.ts +84 -0
- package/dist/lib/extension-helpers.d.ts.map +1 -0
- package/dist/lib/extension-helpers.js +89 -0
- package/dist/lib/input.d.ts +2 -0
- package/dist/lib/input.d.ts.map +1 -1
- package/dist/lib/input.js +5 -3
- package/dist/lib/seed-helpers.d.ts +122 -0
- package/dist/lib/seed-helpers.d.ts.map +1 -0
- package/dist/lib/seed-helpers.js +129 -0
- package/package.json +9 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration file loader.
|
|
3
|
+
*
|
|
4
|
+
* Supports loading TypeScript (.ts), JavaScript (.js, .mjs), and JSON (.json) config files.
|
|
5
|
+
* Uses dynamic imports for TypeScript/JavaScript and JSON.parse for JSON files.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Load a configuration file from disk.
|
|
9
|
+
*
|
|
10
|
+
* Supports:
|
|
11
|
+
* - TypeScript (.ts) - via dynamic import
|
|
12
|
+
* - JavaScript (.js, .mjs) - via dynamic import
|
|
13
|
+
* - JSON (.json) - via JSON.parse
|
|
14
|
+
*
|
|
15
|
+
* @param filePath - Path to the config file
|
|
16
|
+
* @returns The default export from the config file
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Load TypeScript config
|
|
21
|
+
* const config = await loadConfig('./install.config.ts');
|
|
22
|
+
*
|
|
23
|
+
* // Load JSON config (backward compatible)
|
|
24
|
+
* const config = await loadConfig('./install.json');
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function loadConfig<T = unknown>(filePath: string): Promise<T>;
|
|
28
|
+
//# sourceMappingURL=config-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../src/lib/config-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,UAAU,CAAC,CAAC,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAyB1E"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration file loader.
|
|
3
|
+
*
|
|
4
|
+
* Supports loading TypeScript (.ts), JavaScript (.js, .mjs), and JSON (.json) config files.
|
|
5
|
+
* Uses dynamic imports for TypeScript/JavaScript and JSON.parse for JSON files.
|
|
6
|
+
*/
|
|
7
|
+
import { readFile } from 'fs/promises';
|
|
8
|
+
import { pathToFileURL } from 'url';
|
|
9
|
+
import { resolve } from 'path';
|
|
10
|
+
/**
|
|
11
|
+
* Load a configuration file from disk.
|
|
12
|
+
*
|
|
13
|
+
* Supports:
|
|
14
|
+
* - TypeScript (.ts) - via dynamic import
|
|
15
|
+
* - JavaScript (.js, .mjs) - via dynamic import
|
|
16
|
+
* - JSON (.json) - via JSON.parse
|
|
17
|
+
*
|
|
18
|
+
* @param filePath - Path to the config file
|
|
19
|
+
* @returns The default export from the config file
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // Load TypeScript config
|
|
24
|
+
* const config = await loadConfig('./install.config.ts');
|
|
25
|
+
*
|
|
26
|
+
* // Load JSON config (backward compatible)
|
|
27
|
+
* const config = await loadConfig('./install.json');
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export async function loadConfig(filePath) {
|
|
31
|
+
const absPath = resolve(filePath);
|
|
32
|
+
// TypeScript files (requires tsx or ts-node in user's environment)
|
|
33
|
+
if (filePath.endsWith('.ts')) {
|
|
34
|
+
const configModule = await import(pathToFileURL(absPath).href);
|
|
35
|
+
return configModule.default;
|
|
36
|
+
}
|
|
37
|
+
// JavaScript files
|
|
38
|
+
if (filePath.endsWith('.js') || filePath.endsWith('.mjs')) {
|
|
39
|
+
const configModule = await import(pathToFileURL(absPath).href);
|
|
40
|
+
return configModule.default;
|
|
41
|
+
}
|
|
42
|
+
// JSON files (backward compatible)
|
|
43
|
+
if (filePath.endsWith('.json')) {
|
|
44
|
+
const content = await readFile(absPath, 'utf-8');
|
|
45
|
+
return JSON.parse(content);
|
|
46
|
+
}
|
|
47
|
+
throw new Error(`Unsupported file extension for "${filePath}". ` +
|
|
48
|
+
`Supported: .ts, .js, .mjs, .json`);
|
|
49
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extension configuration helpers.
|
|
3
|
+
*
|
|
4
|
+
* These helpers provide type-safe configuration for extension installation
|
|
5
|
+
* using types generated from the platform's GraphQL schema.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { defineExtension } from '@eide/foir-cli/extensions';
|
|
10
|
+
*
|
|
11
|
+
* export default defineExtension({
|
|
12
|
+
* key: 'my-extension',
|
|
13
|
+
* name: 'My Extension',
|
|
14
|
+
* models: [...]
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
import type { InstallExtensionInput, InstallExtensionModelInput, FieldDefinitionInput, InstallExtensionOperationInput } from '../graphql/generated.js';
|
|
19
|
+
/**
|
|
20
|
+
* Define an extension manifest with full type safety.
|
|
21
|
+
*
|
|
22
|
+
* This is a pass-through function that provides IntelliSense and
|
|
23
|
+
* compile-time validation for extension configurations.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* export default defineExtension({
|
|
28
|
+
* key: 'my-extension',
|
|
29
|
+
* name: 'My Extension',
|
|
30
|
+
* models: [{
|
|
31
|
+
* key: 'my_model',
|
|
32
|
+
* name: 'My Model',
|
|
33
|
+
* fields: [
|
|
34
|
+
* { key: 'title', type: 'text', label: 'Title', required: true }
|
|
35
|
+
* ]
|
|
36
|
+
* }]
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function defineExtension(config: InstallExtensionInput): InstallExtensionInput;
|
|
41
|
+
/**
|
|
42
|
+
* Define a model with type-safe field definitions.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const myModel = defineModel({
|
|
47
|
+
* key: 'my_model',
|
|
48
|
+
* name: 'My Model',
|
|
49
|
+
* fields: [
|
|
50
|
+
* { key: 'title', type: 'text', label: 'Title', required: true }
|
|
51
|
+
* ]
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function defineModel(model: InstallExtensionModelInput): InstallExtensionModelInput;
|
|
56
|
+
/**
|
|
57
|
+
* Define a field with type safety.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const titleField = defineField({
|
|
62
|
+
* key: 'title',
|
|
63
|
+
* type: 'text',
|
|
64
|
+
* label: 'Title',
|
|
65
|
+
* required: true
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function defineField(field: FieldDefinitionInput): FieldDefinitionInput;
|
|
70
|
+
/**
|
|
71
|
+
* Define an operation with type safety.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const myOperation = defineOperation({
|
|
76
|
+
* key: 'my-operation',
|
|
77
|
+
* name: 'My Operation',
|
|
78
|
+
* endpoint: '/operations/my-operation'
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare function defineOperation(operation: InstallExtensionOperationInput): InstallExtensionOperationInput;
|
|
83
|
+
export type { InstallExtensionInput, InstallExtensionModelInput, FieldDefinitionInput, InstallExtensionOperationInput, InstallExtensionAuthProviderInput, InstallExtensionPlacementInput, InstallExtensionCustomerProfileSchemaInput, } from '../graphql/generated.js';
|
|
84
|
+
//# sourceMappingURL=extension-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-helpers.d.ts","sourceRoot":"","sources":["../../src/lib/extension-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,0BAA0B,EAC1B,oBAAoB,EACpB,8BAA8B,EAC/B,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,qBAAqB,GAC5B,qBAAqB,CAEvB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,0BAA0B,GAChC,0BAA0B,CAE5B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,oBAAoB,GAC1B,oBAAoB,CAEtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,8BAA8B,GACxC,8BAA8B,CAEhC;AAGD,YAAY,EACV,qBAAqB,EACrB,0BAA0B,EAC1B,oBAAoB,EACpB,8BAA8B,EAC9B,iCAAiC,EACjC,8BAA8B,EAC9B,0CAA0C,GAC3C,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extension configuration helpers.
|
|
3
|
+
*
|
|
4
|
+
* These helpers provide type-safe configuration for extension installation
|
|
5
|
+
* using types generated from the platform's GraphQL schema.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { defineExtension } from '@eide/foir-cli/extensions';
|
|
10
|
+
*
|
|
11
|
+
* export default defineExtension({
|
|
12
|
+
* key: 'my-extension',
|
|
13
|
+
* name: 'My Extension',
|
|
14
|
+
* models: [...]
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Define an extension manifest with full type safety.
|
|
20
|
+
*
|
|
21
|
+
* This is a pass-through function that provides IntelliSense and
|
|
22
|
+
* compile-time validation for extension configurations.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* export default defineExtension({
|
|
27
|
+
* key: 'my-extension',
|
|
28
|
+
* name: 'My Extension',
|
|
29
|
+
* models: [{
|
|
30
|
+
* key: 'my_model',
|
|
31
|
+
* name: 'My Model',
|
|
32
|
+
* fields: [
|
|
33
|
+
* { key: 'title', type: 'text', label: 'Title', required: true }
|
|
34
|
+
* ]
|
|
35
|
+
* }]
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export function defineExtension(config) {
|
|
40
|
+
return config;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Define a model with type-safe field definitions.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const myModel = defineModel({
|
|
48
|
+
* key: 'my_model',
|
|
49
|
+
* name: 'My Model',
|
|
50
|
+
* fields: [
|
|
51
|
+
* { key: 'title', type: 'text', label: 'Title', required: true }
|
|
52
|
+
* ]
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export function defineModel(model) {
|
|
57
|
+
return model;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Define a field with type safety.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const titleField = defineField({
|
|
65
|
+
* key: 'title',
|
|
66
|
+
* type: 'text',
|
|
67
|
+
* label: 'Title',
|
|
68
|
+
* required: true
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export function defineField(field) {
|
|
73
|
+
return field;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Define an operation with type safety.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const myOperation = defineOperation({
|
|
81
|
+
* key: 'my-operation',
|
|
82
|
+
* name: 'My Operation',
|
|
83
|
+
* endpoint: '/operations/my-operation'
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export function defineOperation(operation) {
|
|
88
|
+
return operation;
|
|
89
|
+
}
|
package/dist/lib/input.d.ts
CHANGED
package/dist/lib/input.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/lib/input.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/lib/input.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAyBnC;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAM7C;AAED,UAAU,YAAY;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,EAAE,CA8B9D;AAWD,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAQjE;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAC3B,OAAO,CAAC,OAAO,CAAC,CAalB"}
|
package/dist/lib/input.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { promises as fs } from 'fs';
|
|
2
1
|
import inquirer from 'inquirer';
|
|
2
|
+
import { loadConfig } from './config-loader.js';
|
|
3
3
|
/**
|
|
4
4
|
* Parse input data from --data, --file, or stdin.
|
|
5
|
+
*
|
|
6
|
+
* Supports TypeScript (.ts), JavaScript (.js, .mjs), and JSON (.json) files.
|
|
5
7
|
*/
|
|
6
8
|
export async function parseInputData(opts) {
|
|
7
9
|
if (opts.data) {
|
|
8
10
|
return JSON.parse(opts.data);
|
|
9
11
|
}
|
|
10
12
|
if (opts.file) {
|
|
11
|
-
|
|
12
|
-
return
|
|
13
|
+
// Use config loader for TypeScript/JavaScript/JSON files
|
|
14
|
+
return await loadConfig(opts.file);
|
|
13
15
|
}
|
|
14
16
|
// Check for stdin pipe
|
|
15
17
|
if (!process.stdin.isTTY) {
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model and record seed configuration helpers.
|
|
3
|
+
*
|
|
4
|
+
* These helpers provide type-safe configuration for seeding models and records
|
|
5
|
+
* using types generated from the platform's GraphQL schema.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { defineModels, defineRecords } from '@eide/foir-cli/seed';
|
|
10
|
+
*
|
|
11
|
+
* // Define models
|
|
12
|
+
* export const models = defineModels([
|
|
13
|
+
* {
|
|
14
|
+
* key: 'my_model',
|
|
15
|
+
* name: 'My Model',
|
|
16
|
+
* fields: [...]
|
|
17
|
+
* }
|
|
18
|
+
* ]);
|
|
19
|
+
*
|
|
20
|
+
* // Define records
|
|
21
|
+
* export const records = defineRecords([
|
|
22
|
+
* {
|
|
23
|
+
* modelKey: 'my_model',
|
|
24
|
+
* naturalKey: 'my-record',
|
|
25
|
+
* data: { ... }
|
|
26
|
+
* }
|
|
27
|
+
* ]);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
import type { CreateModelInput, CreateRecordInput, FieldDefinitionInput } from '../graphql/generated.js';
|
|
31
|
+
/**
|
|
32
|
+
* Define a single model with type safety.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* export default defineModel({
|
|
37
|
+
* key: 'tilly_page',
|
|
38
|
+
* name: 'Tilly Page',
|
|
39
|
+
* fields: [
|
|
40
|
+
* { key: 'title', type: 'text', label: 'Title', required: true }
|
|
41
|
+
* ],
|
|
42
|
+
* config: {
|
|
43
|
+
* versioning: true,
|
|
44
|
+
* publishing: true
|
|
45
|
+
* }
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function defineModel(model: CreateModelInput): CreateModelInput;
|
|
50
|
+
/**
|
|
51
|
+
* Define multiple models with type safety.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* export default defineModels([
|
|
56
|
+
* {
|
|
57
|
+
* key: 'model_a',
|
|
58
|
+
* name: 'Model A',
|
|
59
|
+
* fields: [...]
|
|
60
|
+
* },
|
|
61
|
+
* {
|
|
62
|
+
* key: 'model_b',
|
|
63
|
+
* name: 'Model B',
|
|
64
|
+
* fields: [...]
|
|
65
|
+
* }
|
|
66
|
+
* ]);
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function defineModels(models: CreateModelInput[]): CreateModelInput[];
|
|
70
|
+
/**
|
|
71
|
+
* Define a single record with type safety.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* export default defineRecord({
|
|
76
|
+
* modelKey: 'tilly_page',
|
|
77
|
+
* naturalKey: 'home',
|
|
78
|
+
* data: {
|
|
79
|
+
* title: 'Home Page',
|
|
80
|
+
* blocks: [...]
|
|
81
|
+
* }
|
|
82
|
+
* });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare function defineRecord(record: CreateRecordInput): CreateRecordInput;
|
|
86
|
+
/**
|
|
87
|
+
* Define multiple records with type safety.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* export default defineRecords([
|
|
92
|
+
* {
|
|
93
|
+
* modelKey: 'tilly_page',
|
|
94
|
+
* naturalKey: 'home',
|
|
95
|
+
* data: { title: 'Home' }
|
|
96
|
+
* },
|
|
97
|
+
* {
|
|
98
|
+
* modelKey: 'tilly_page',
|
|
99
|
+
* naturalKey: 'about',
|
|
100
|
+
* data: { title: 'About' }
|
|
101
|
+
* }
|
|
102
|
+
* ]);
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare function defineRecords(records: CreateRecordInput[]): CreateRecordInput[];
|
|
106
|
+
/**
|
|
107
|
+
* Define a field with type safety.
|
|
108
|
+
* Alias of the extension helper for convenience.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const titleField = defineField({
|
|
113
|
+
* key: 'title',
|
|
114
|
+
* type: 'text',
|
|
115
|
+
* label: 'Title',
|
|
116
|
+
* required: true
|
|
117
|
+
* });
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export declare function defineField(field: FieldDefinitionInput): FieldDefinitionInput;
|
|
121
|
+
export type { CreateModelInput, CreateRecordInput, FieldDefinitionInput, } from '../graphql/generated.js';
|
|
122
|
+
//# sourceMappingURL=seed-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seed-helpers.d.ts","sourceRoot":"","sources":["../../src/lib/seed-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,CAErE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,gBAAgB,EAAE,CAE3E;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,CAEzE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,iBAAiB,EAAE,GAC3B,iBAAiB,EAAE,CAErB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,oBAAoB,GAC1B,oBAAoB,CAEtB;AAGD,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model and record seed configuration helpers.
|
|
3
|
+
*
|
|
4
|
+
* These helpers provide type-safe configuration for seeding models and records
|
|
5
|
+
* using types generated from the platform's GraphQL schema.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { defineModels, defineRecords } from '@eide/foir-cli/seed';
|
|
10
|
+
*
|
|
11
|
+
* // Define models
|
|
12
|
+
* export const models = defineModels([
|
|
13
|
+
* {
|
|
14
|
+
* key: 'my_model',
|
|
15
|
+
* name: 'My Model',
|
|
16
|
+
* fields: [...]
|
|
17
|
+
* }
|
|
18
|
+
* ]);
|
|
19
|
+
*
|
|
20
|
+
* // Define records
|
|
21
|
+
* export const records = defineRecords([
|
|
22
|
+
* {
|
|
23
|
+
* modelKey: 'my_model',
|
|
24
|
+
* naturalKey: 'my-record',
|
|
25
|
+
* data: { ... }
|
|
26
|
+
* }
|
|
27
|
+
* ]);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Define a single model with type safety.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* export default defineModel({
|
|
36
|
+
* key: 'tilly_page',
|
|
37
|
+
* name: 'Tilly Page',
|
|
38
|
+
* fields: [
|
|
39
|
+
* { key: 'title', type: 'text', label: 'Title', required: true }
|
|
40
|
+
* ],
|
|
41
|
+
* config: {
|
|
42
|
+
* versioning: true,
|
|
43
|
+
* publishing: true
|
|
44
|
+
* }
|
|
45
|
+
* });
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export function defineModel(model) {
|
|
49
|
+
return model;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Define multiple models with type safety.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* export default defineModels([
|
|
57
|
+
* {
|
|
58
|
+
* key: 'model_a',
|
|
59
|
+
* name: 'Model A',
|
|
60
|
+
* fields: [...]
|
|
61
|
+
* },
|
|
62
|
+
* {
|
|
63
|
+
* key: 'model_b',
|
|
64
|
+
* name: 'Model B',
|
|
65
|
+
* fields: [...]
|
|
66
|
+
* }
|
|
67
|
+
* ]);
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export function defineModels(models) {
|
|
71
|
+
return models;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Define a single record with type safety.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* export default defineRecord({
|
|
79
|
+
* modelKey: 'tilly_page',
|
|
80
|
+
* naturalKey: 'home',
|
|
81
|
+
* data: {
|
|
82
|
+
* title: 'Home Page',
|
|
83
|
+
* blocks: [...]
|
|
84
|
+
* }
|
|
85
|
+
* });
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export function defineRecord(record) {
|
|
89
|
+
return record;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Define multiple records with type safety.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* export default defineRecords([
|
|
97
|
+
* {
|
|
98
|
+
* modelKey: 'tilly_page',
|
|
99
|
+
* naturalKey: 'home',
|
|
100
|
+
* data: { title: 'Home' }
|
|
101
|
+
* },
|
|
102
|
+
* {
|
|
103
|
+
* modelKey: 'tilly_page',
|
|
104
|
+
* naturalKey: 'about',
|
|
105
|
+
* data: { title: 'About' }
|
|
106
|
+
* }
|
|
107
|
+
* ]);
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export function defineRecords(records) {
|
|
111
|
+
return records;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Define a field with type safety.
|
|
115
|
+
* Alias of the extension helper for convenience.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const titleField = defineField({
|
|
120
|
+
* key: 'title',
|
|
121
|
+
* type: 'text',
|
|
122
|
+
* label: 'Title',
|
|
123
|
+
* required: true
|
|
124
|
+
* });
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export function defineField(field) {
|
|
128
|
+
return field;
|
|
129
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eide/foir-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.27",
|
|
4
4
|
"description": "Universal platform CLI for EIDE — scriptable, composable resource management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -17,6 +17,14 @@
|
|
|
17
17
|
"./config": {
|
|
18
18
|
"types": "./dist/config/types.js",
|
|
19
19
|
"import": "./dist/config/types.js"
|
|
20
|
+
},
|
|
21
|
+
"./extensions": {
|
|
22
|
+
"types": "./dist/lib/extension-helpers.js",
|
|
23
|
+
"import": "./dist/lib/extension-helpers.js"
|
|
24
|
+
},
|
|
25
|
+
"./seed": {
|
|
26
|
+
"types": "./dist/lib/seed-helpers.js",
|
|
27
|
+
"import": "./dist/lib/seed-helpers.js"
|
|
20
28
|
}
|
|
21
29
|
},
|
|
22
30
|
"files": [
|