@eide/foir-cli 0.1.16 → 0.1.18
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 +3 -0
- package/dist/codegen/field-mapping.d.ts +1 -0
- package/dist/codegen/field-mapping.d.ts.map +1 -1
- package/dist/codegen/field-mapping.js +8 -0
- package/dist/codegen/generators/customer-profile-hooks.d.ts +5 -0
- package/dist/codegen/generators/customer-profile-hooks.d.ts.map +1 -0
- package/dist/codegen/generators/customer-profile-hooks.js +78 -0
- package/dist/codegen/generators/customer-profile-loaders.d.ts +5 -0
- package/dist/codegen/generators/customer-profile-loaders.d.ts.map +1 -0
- package/dist/codegen/generators/customer-profile-loaders.js +67 -0
- package/dist/codegen/generators/customer-profile-operations.d.ts +5 -0
- package/dist/codegen/generators/customer-profile-operations.d.ts.map +1 -0
- package/dist/codegen/generators/customer-profile-operations.js +126 -0
- package/dist/codegen/generators/documents.d.ts.map +1 -1
- package/dist/codegen/generators/documents.js +4 -0
- package/dist/codegen/generators/public-schema-content.d.ts +14 -0
- package/dist/codegen/generators/public-schema-content.d.ts.map +1 -0
- package/dist/codegen/generators/public-schema-content.js +22 -0
- package/dist/codegen/generators/react-hooks-index.d.ts +6 -0
- package/dist/codegen/generators/react-hooks-index.d.ts.map +1 -0
- package/dist/codegen/generators/react-hooks-index.js +20 -0
- package/dist/codegen/generators/react-hooks.d.ts +7 -0
- package/dist/codegen/generators/react-hooks.d.ts.map +1 -0
- package/dist/codegen/generators/react-hooks.js +139 -0
- package/dist/codegen/generators/remix-loaders-index.d.ts +6 -0
- package/dist/codegen/generators/remix-loaders-index.d.ts.map +1 -0
- package/dist/codegen/generators/remix-loaders-index.js +20 -0
- package/dist/codegen/generators/remix-loaders.d.ts +7 -0
- package/dist/codegen/generators/remix-loaders.d.ts.map +1 -0
- package/dist/codegen/generators/remix-loaders.js +107 -0
- package/dist/codegen/generators/static-documents.d.ts +14 -0
- package/dist/codegen/generators/static-documents.d.ts.map +1 -0
- package/dist/codegen/generators/static-documents.js +766 -0
- package/dist/codegen/generators/typed-operations-common.d.ts +6 -0
- package/dist/codegen/generators/typed-operations-common.d.ts.map +1 -0
- package/dist/codegen/generators/typed-operations-common.js +74 -0
- package/dist/codegen/generators/typed-operations-index.d.ts +6 -0
- package/dist/codegen/generators/typed-operations-index.d.ts.map +1 -0
- package/dist/codegen/generators/typed-operations-index.js +22 -0
- package/dist/codegen/generators/typed-operations.d.ts +11 -0
- package/dist/codegen/generators/typed-operations.d.ts.map +1 -0
- package/dist/codegen/generators/typed-operations.js +251 -0
- package/dist/commands/create-extension.d.ts +4 -0
- package/dist/commands/create-extension.d.ts.map +1 -0
- package/dist/commands/create-extension.js +60 -0
- package/dist/commands/pull.d.ts.map +1 -1
- package/dist/commands/pull.js +135 -25
- package/dist/config/pull-config.d.ts +6 -0
- package/dist/config/pull-config.d.ts.map +1 -1
- package/dist/config/pull-config.js +50 -1
- package/dist/config/types.d.ts +23 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/scaffold/package-manager.d.ts +12 -0
- package/dist/scaffold/package-manager.d.ts.map +1 -0
- package/dist/scaffold/package-manager.js +51 -0
- package/dist/scaffold/scaffold.d.ts +4 -0
- package/dist/scaffold/scaffold.d.ts.map +1 -0
- package/dist/scaffold/scaffold.js +462 -0
- package/package.json +1 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates the shared _common.ts file for typed operations.
|
|
3
|
+
* Contains generic wrapper types used by all per-model operation modules.
|
|
4
|
+
*/
|
|
5
|
+
export declare function generateTypedOperationsCommon(): string;
|
|
6
|
+
//# sourceMappingURL=typed-operations-common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-operations-common.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/typed-operations-common.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wBAAgB,6BAA6B,IAAI,MAAM,CAqEtD"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates the shared _common.ts file for typed operations.
|
|
3
|
+
* Contains generic wrapper types used by all per-model operation modules.
|
|
4
|
+
*/
|
|
5
|
+
export function generateTypedOperationsCommon() {
|
|
6
|
+
return `/**
|
|
7
|
+
* Shared types for typed GraphQL operations.
|
|
8
|
+
*
|
|
9
|
+
* @generated by foir — DO NOT EDIT MANUALLY
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** A record with strongly-typed data. */
|
|
13
|
+
export interface BaseRecord<T> {
|
|
14
|
+
id: string;
|
|
15
|
+
modelKey: string;
|
|
16
|
+
naturalKey: string | null;
|
|
17
|
+
data: T;
|
|
18
|
+
metadata: Record<string, unknown> | null;
|
|
19
|
+
publishedVersionNumber: number | null;
|
|
20
|
+
publishedAt: string | null;
|
|
21
|
+
versionNumber: number | null;
|
|
22
|
+
changeDescription: string | null;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
updatedAt: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Resolved content wrapping strongly-typed data. */
|
|
28
|
+
export interface ResolvedContent<T> {
|
|
29
|
+
content: T;
|
|
30
|
+
record: { id: string; modelKey: string; naturalKey: string | null };
|
|
31
|
+
version: { id: string; versionNumber: number } | null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Paginated list result. */
|
|
35
|
+
export interface PaginatedResult<T> {
|
|
36
|
+
items: BaseRecord<T>[];
|
|
37
|
+
total: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Result of a createRecord mutation. */
|
|
41
|
+
export interface CreateRecordResult<T> {
|
|
42
|
+
record: BaseRecord<T>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Result of an updateRecord mutation. */
|
|
46
|
+
export interface UpdateRecordResult<T> {
|
|
47
|
+
record: BaseRecord<T>;
|
|
48
|
+
matched: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Result of a deleteRecord mutation. */
|
|
52
|
+
export interface DeleteRecordResult {
|
|
53
|
+
id: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Share resource type. */
|
|
57
|
+
export interface ShareResult {
|
|
58
|
+
id: string;
|
|
59
|
+
resourceType: string;
|
|
60
|
+
permission: string;
|
|
61
|
+
status: string;
|
|
62
|
+
acceptedAt: string | null;
|
|
63
|
+
declinedAt: string | null;
|
|
64
|
+
expiresAt: string | null;
|
|
65
|
+
createdAt: string;
|
|
66
|
+
revokedAt: string | null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** A share that includes the shared record. */
|
|
70
|
+
export interface ShareWithRecord<T> extends ShareResult {
|
|
71
|
+
record: BaseRecord<T>;
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates the operations/index.ts barrel re-export file.
|
|
3
|
+
*/
|
|
4
|
+
import type { CodegenModel } from '../fetch-models.js';
|
|
5
|
+
export declare function generateTypedOperationsIndex(models: CodegenModel[], hasCustomerProfile: boolean): string;
|
|
6
|
+
//# sourceMappingURL=typed-operations-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-operations-index.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/typed-operations-index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,YAAY,EAAE,EACtB,kBAAkB,EAAE,OAAO,GAC1B,MAAM,CAsBR"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates the operations/index.ts barrel re-export file.
|
|
3
|
+
*/
|
|
4
|
+
export function generateTypedOperationsIndex(models, hasCustomerProfile) {
|
|
5
|
+
const lines = [];
|
|
6
|
+
lines.push(`/**
|
|
7
|
+
* Typed GraphQL operations.
|
|
8
|
+
*
|
|
9
|
+
* @generated by foir — DO NOT EDIT MANUALLY
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export * from './_common.js';
|
|
13
|
+
`);
|
|
14
|
+
for (const model of models) {
|
|
15
|
+
lines.push(`export * from './${model.key}.js';`);
|
|
16
|
+
}
|
|
17
|
+
if (hasCustomerProfile) {
|
|
18
|
+
lines.push(`export * from './customer-profile.js';`);
|
|
19
|
+
}
|
|
20
|
+
lines.push('');
|
|
21
|
+
return lines.join('\n');
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates per-model typed operation modules.
|
|
3
|
+
* Each module exports gql tagged templates + typed Variables/Result interfaces.
|
|
4
|
+
*/
|
|
5
|
+
import type { CodegenModel } from '../fetch-models.js';
|
|
6
|
+
export declare function generateTypedOperations(model: CodegenModel, typesRelPath: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Compute the relative import path from the operations dir to the types dir.
|
|
9
|
+
*/
|
|
10
|
+
export declare function computeTypesRelPath(opsDir: string, typesDir: string): string;
|
|
11
|
+
//# sourceMappingURL=typed-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-operations.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/typed-operations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,YAAY,EACnB,YAAY,EAAE,MAAM,GACnB,MAAM,CA4QR;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,MAAM,CAGR"}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates per-model typed operation modules.
|
|
3
|
+
* Each module exports gql tagged templates + typed Variables/Result interfaces.
|
|
4
|
+
*/
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { toPascalCase, toUpperSnakeCase } from '../field-mapping.js';
|
|
7
|
+
export function generateTypedOperations(model, typesRelPath) {
|
|
8
|
+
const typeName = toPascalCase(model.key);
|
|
9
|
+
const upperSnake = toUpperSnakeCase(model.key);
|
|
10
|
+
const pluralName = model.pluralName
|
|
11
|
+
? toPascalCase(model.pluralName.replace(/\s+/g, ''))
|
|
12
|
+
: `${typeName}s`;
|
|
13
|
+
const pluralUpperSnake = model.pluralName
|
|
14
|
+
? toUpperSnakeCase(model.pluralName.replace(/\s+/g, ''))
|
|
15
|
+
: `${upperSnake}S`;
|
|
16
|
+
const dataType = `${typeName}Data`;
|
|
17
|
+
const lines = [];
|
|
18
|
+
lines.push(`/**
|
|
19
|
+
* Typed operations for ${model.name ?? model.key}
|
|
20
|
+
*
|
|
21
|
+
* @generated by foir — DO NOT EDIT MANUALLY
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import type { ${dataType} } from '${typesRelPath}/models/${model.key}.js';
|
|
25
|
+
import type {
|
|
26
|
+
BaseRecord,
|
|
27
|
+
ResolvedContent,
|
|
28
|
+
PaginatedResult,
|
|
29
|
+
CreateRecordResult,
|
|
30
|
+
UpdateRecordResult,
|
|
31
|
+
DeleteRecordResult,${model.config.sharing?.enabled ? '\n ShareResult,\n ShareWithRecord,' : ''}
|
|
32
|
+
} from './_common.js';
|
|
33
|
+
`);
|
|
34
|
+
// Type alias
|
|
35
|
+
lines.push(`export type ${typeName}Record = BaseRecord<${dataType}>;`);
|
|
36
|
+
lines.push('');
|
|
37
|
+
// GET query
|
|
38
|
+
lines.push(`export const GET_${upperSnake} = \`
|
|
39
|
+
query Get${typeName}($id: ID!, $locale: String, $preview: Boolean) {
|
|
40
|
+
record(id: $id) {
|
|
41
|
+
id modelKey naturalKey data metadata
|
|
42
|
+
publishedVersionNumber publishedAt versionNumber changeDescription
|
|
43
|
+
createdAt updatedAt
|
|
44
|
+
resolved(locale: $locale, preview: $preview) {
|
|
45
|
+
content
|
|
46
|
+
record { id modelKey naturalKey }
|
|
47
|
+
version { id versionNumber }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
\`;`);
|
|
52
|
+
lines.push('');
|
|
53
|
+
lines.push(`export interface Get${typeName}Variables {
|
|
54
|
+
id: string;
|
|
55
|
+
locale?: string;
|
|
56
|
+
preview?: boolean;
|
|
57
|
+
}`);
|
|
58
|
+
lines.push('');
|
|
59
|
+
lines.push(`export interface Get${typeName}Result {
|
|
60
|
+
record: ${typeName}Record & {
|
|
61
|
+
resolved: ResolvedContent<${dataType}> | null;
|
|
62
|
+
} | null;
|
|
63
|
+
}`);
|
|
64
|
+
lines.push('');
|
|
65
|
+
// GET BY KEY query
|
|
66
|
+
lines.push(`export const GET_${upperSnake}_BY_KEY = \`
|
|
67
|
+
query Get${typeName}ByKey($naturalKey: String!, $locale: String, $preview: Boolean) {
|
|
68
|
+
recordByKey(modelKey: "${model.key}", naturalKey: $naturalKey) {
|
|
69
|
+
id modelKey naturalKey data metadata
|
|
70
|
+
publishedVersionNumber publishedAt versionNumber changeDescription
|
|
71
|
+
createdAt updatedAt
|
|
72
|
+
resolved(locale: $locale, preview: $preview) {
|
|
73
|
+
content
|
|
74
|
+
record { id modelKey naturalKey }
|
|
75
|
+
version { id versionNumber }
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
\`;`);
|
|
80
|
+
lines.push('');
|
|
81
|
+
lines.push(`export interface Get${typeName}ByKeyVariables {
|
|
82
|
+
naturalKey: string;
|
|
83
|
+
locale?: string;
|
|
84
|
+
preview?: boolean;
|
|
85
|
+
}`);
|
|
86
|
+
lines.push('');
|
|
87
|
+
lines.push(`export interface Get${typeName}ByKeyResult {
|
|
88
|
+
recordByKey: ${typeName}Record & {
|
|
89
|
+
resolved: ResolvedContent<${dataType}> | null;
|
|
90
|
+
} | null;
|
|
91
|
+
}`);
|
|
92
|
+
lines.push('');
|
|
93
|
+
// LIST query
|
|
94
|
+
lines.push(`export const LIST_${pluralUpperSnake} = \`
|
|
95
|
+
query List${pluralName}($limit: Int, $offset: Int, $filters: [FilterInput!], $sort: SortInput) {
|
|
96
|
+
records(modelKey: "${model.key}", limit: $limit, offset: $offset, filters: $filters, sort: $sort) {
|
|
97
|
+
items {
|
|
98
|
+
id modelKey naturalKey data metadata
|
|
99
|
+
publishedVersionNumber publishedAt versionNumber changeDescription
|
|
100
|
+
createdAt updatedAt
|
|
101
|
+
}
|
|
102
|
+
total
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
\`;`);
|
|
106
|
+
lines.push('');
|
|
107
|
+
lines.push(`export interface List${pluralName}Variables {
|
|
108
|
+
limit?: number;
|
|
109
|
+
offset?: number;
|
|
110
|
+
filters?: Array<{ field: string; operator: string; value: unknown }>;
|
|
111
|
+
sort?: { field: string; direction: 'ASC' | 'DESC' };
|
|
112
|
+
}`);
|
|
113
|
+
lines.push('');
|
|
114
|
+
lines.push(`export interface List${pluralName}Result {
|
|
115
|
+
records: PaginatedResult<${dataType}>;
|
|
116
|
+
}`);
|
|
117
|
+
lines.push('');
|
|
118
|
+
// CREATE mutation
|
|
119
|
+
lines.push(`export const CREATE_${upperSnake} = \`
|
|
120
|
+
mutation Create${typeName}($input: CreateRecordInput!) {
|
|
121
|
+
createRecord(input: $input) {
|
|
122
|
+
record {
|
|
123
|
+
id modelKey naturalKey data metadata createdAt updatedAt
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
\`;`);
|
|
128
|
+
lines.push('');
|
|
129
|
+
lines.push(`export interface Create${typeName}Variables {
|
|
130
|
+
input: {
|
|
131
|
+
modelKey: string;
|
|
132
|
+
naturalKey?: string;
|
|
133
|
+
data: Partial<${dataType}>;
|
|
134
|
+
metadata?: Record<string, unknown>;
|
|
135
|
+
};
|
|
136
|
+
}`);
|
|
137
|
+
lines.push('');
|
|
138
|
+
lines.push(`export interface Create${typeName}Result {
|
|
139
|
+
createRecord: CreateRecordResult<${dataType}>;
|
|
140
|
+
}`);
|
|
141
|
+
lines.push('');
|
|
142
|
+
// UPDATE mutation
|
|
143
|
+
lines.push(`export const UPDATE_${upperSnake} = \`
|
|
144
|
+
mutation Update${typeName}($input: UpdateRecordInput!) {
|
|
145
|
+
updateRecord(input: $input) {
|
|
146
|
+
record {
|
|
147
|
+
id modelKey naturalKey data metadata createdAt updatedAt
|
|
148
|
+
}
|
|
149
|
+
matched
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
\`;`);
|
|
153
|
+
lines.push('');
|
|
154
|
+
lines.push(`export interface Update${typeName}Variables {
|
|
155
|
+
input: {
|
|
156
|
+
id: string;
|
|
157
|
+
data?: Partial<${dataType}>;
|
|
158
|
+
metadata?: Record<string, unknown>;
|
|
159
|
+
changeDescription?: string;
|
|
160
|
+
};
|
|
161
|
+
}`);
|
|
162
|
+
lines.push('');
|
|
163
|
+
lines.push(`export interface Update${typeName}Result {
|
|
164
|
+
updateRecord: UpdateRecordResult<${dataType}>;
|
|
165
|
+
}`);
|
|
166
|
+
lines.push('');
|
|
167
|
+
// DELETE mutation
|
|
168
|
+
lines.push(`export const DELETE_${upperSnake} = \`
|
|
169
|
+
mutation Delete${typeName}($id: ID!) {
|
|
170
|
+
deleteRecord(id: $id) { id }
|
|
171
|
+
}
|
|
172
|
+
\`;`);
|
|
173
|
+
lines.push('');
|
|
174
|
+
lines.push(`export interface Delete${typeName}Variables {
|
|
175
|
+
id: string;
|
|
176
|
+
}`);
|
|
177
|
+
lines.push('');
|
|
178
|
+
lines.push(`export interface Delete${typeName}Result {
|
|
179
|
+
deleteRecord: DeleteRecordResult;
|
|
180
|
+
}`);
|
|
181
|
+
lines.push('');
|
|
182
|
+
// PUBLISH/UNPUBLISH
|
|
183
|
+
lines.push(`export const PUBLISH_${upperSnake}_VERSION = \`
|
|
184
|
+
mutation Publish${typeName}Version($versionId: ID!) {
|
|
185
|
+
publishVersion(versionId: $versionId)
|
|
186
|
+
}
|
|
187
|
+
\`;`);
|
|
188
|
+
lines.push('');
|
|
189
|
+
lines.push(`export const UNPUBLISH_${upperSnake} = \`
|
|
190
|
+
mutation Unpublish${typeName}($id: ID!) {
|
|
191
|
+
unpublishRecord(id: $id)
|
|
192
|
+
}
|
|
193
|
+
\`;`);
|
|
194
|
+
lines.push('');
|
|
195
|
+
// Sharing operations (conditional)
|
|
196
|
+
if (model.config.sharing?.enabled) {
|
|
197
|
+
lines.push(`// --- Sharing operations ---`);
|
|
198
|
+
lines.push('');
|
|
199
|
+
lines.push(`export const SHARE_${upperSnake} = \`
|
|
200
|
+
mutation Share${typeName}($recordId: ID!, $sharedWithCustomerId: ID!, $permission: SharePermission!) {
|
|
201
|
+
shareRecord(recordId: $recordId, sharedWithCustomerId: $sharedWithCustomerId, permission: $permission) {
|
|
202
|
+
id resourceType permission status acceptedAt declinedAt expiresAt createdAt revokedAt
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
\`;`);
|
|
206
|
+
lines.push('');
|
|
207
|
+
lines.push(`export interface Share${typeName}Variables {
|
|
208
|
+
recordId: string;
|
|
209
|
+
sharedWithCustomerId: string;
|
|
210
|
+
permission: 'VIEW' | 'EDIT' | 'ADMIN';
|
|
211
|
+
}`);
|
|
212
|
+
lines.push('');
|
|
213
|
+
lines.push(`export interface Share${typeName}Result {
|
|
214
|
+
shareRecord: ShareResult;
|
|
215
|
+
}`);
|
|
216
|
+
lines.push('');
|
|
217
|
+
lines.push(`export const ${upperSnake}_SHARES = \`
|
|
218
|
+
query ${typeName}Shares($resourceId: ID!, $status: ShareStatus) {
|
|
219
|
+
shares(resourceType: RECORD, resourceId: $resourceId, status: $status) {
|
|
220
|
+
id resourceType permission status acceptedAt declinedAt expiresAt createdAt revokedAt
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
\`;`);
|
|
224
|
+
lines.push('');
|
|
225
|
+
lines.push(`export const ${pluralUpperSnake}_SHARED_WITH_ME = \`
|
|
226
|
+
query ${pluralName}SharedWithMe($status: ShareStatus) {
|
|
227
|
+
sharedWithMe(resourceType: RECORD, modelKey: "${model.key}", status: $status) {
|
|
228
|
+
id resourceType permission status acceptedAt declinedAt expiresAt createdAt revokedAt
|
|
229
|
+
record {
|
|
230
|
+
id modelKey naturalKey data metadata
|
|
231
|
+
publishedVersionNumber publishedAt versionNumber changeDescription
|
|
232
|
+
createdAt updatedAt
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
\`;`);
|
|
237
|
+
lines.push('');
|
|
238
|
+
lines.push(`export interface ${pluralName}SharedWithMeResult {
|
|
239
|
+
sharedWithMe: ShareWithRecord<${dataType}>[];
|
|
240
|
+
}`);
|
|
241
|
+
lines.push('');
|
|
242
|
+
}
|
|
243
|
+
return lines.join('\n');
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Compute the relative import path from the operations dir to the types dir.
|
|
247
|
+
*/
|
|
248
|
+
export function computeTypesRelPath(opsDir, typesDir) {
|
|
249
|
+
const rel = path.relative(opsDir, typesDir).replace(/\\/g, '/');
|
|
250
|
+
return rel.startsWith('.') ? rel : `./${rel}`;
|
|
251
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,60 @@
|
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAmCtD,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,aAAa,GAC9B,IAAI,CA+TN"}
|