@eide/foir-cli 0.1.35 → 0.1.37

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.
Files changed (228) hide show
  1. package/dist/cli.js +7467 -42
  2. package/dist/config/types.d.ts +7 -6
  3. package/dist/config/types.js +6 -14
  4. package/dist/generated-CPsQ9jfu.d.ts +195 -0
  5. package/dist/lib/extension-helpers.d.ts +10 -7
  6. package/dist/lib/extension-helpers.js +15 -85
  7. package/dist/lib/hook-helpers.d.ts +9 -6
  8. package/dist/lib/hook-helpers.js +12 -105
  9. package/dist/lib/seed-helpers.d.ts +10 -8
  10. package/dist/lib/seed-helpers.js +18 -124
  11. package/dist/schema.graphql +6062 -0
  12. package/package.json +9 -8
  13. package/dist/auth/credentials.d.ts +0 -31
  14. package/dist/auth/credentials.d.ts.map +0 -1
  15. package/dist/auth/credentials.js +0 -139
  16. package/dist/cli.d.ts +0 -3
  17. package/dist/cli.d.ts.map +0 -1
  18. package/dist/codegen/fetch-customer-profile-schema.d.ts +0 -12
  19. package/dist/codegen/fetch-customer-profile-schema.d.ts.map +0 -1
  20. package/dist/codegen/fetch-customer-profile-schema.js +0 -21
  21. package/dist/codegen/fetch-models.d.ts +0 -58
  22. package/dist/codegen/fetch-models.d.ts.map +0 -1
  23. package/dist/codegen/fetch-models.js +0 -96
  24. package/dist/codegen/field-mapping.d.ts +0 -34
  25. package/dist/codegen/field-mapping.d.ts.map +0 -1
  26. package/dist/codegen/field-mapping.js +0 -250
  27. package/dist/codegen/generators/config.d.ts +0 -5
  28. package/dist/codegen/generators/config.d.ts.map +0 -1
  29. package/dist/codegen/generators/config.js +0 -82
  30. package/dist/codegen/generators/customer-profile-documents.d.ts +0 -5
  31. package/dist/codegen/generators/customer-profile-documents.d.ts.map +0 -1
  32. package/dist/codegen/generators/customer-profile-documents.js +0 -42
  33. package/dist/codegen/generators/customer-profile-hooks.d.ts +0 -5
  34. package/dist/codegen/generators/customer-profile-hooks.d.ts.map +0 -1
  35. package/dist/codegen/generators/customer-profile-hooks.js +0 -78
  36. package/dist/codegen/generators/customer-profile-loaders.d.ts +0 -5
  37. package/dist/codegen/generators/customer-profile-loaders.d.ts.map +0 -1
  38. package/dist/codegen/generators/customer-profile-loaders.js +0 -67
  39. package/dist/codegen/generators/customer-profile-operations.d.ts +0 -5
  40. package/dist/codegen/generators/customer-profile-operations.d.ts.map +0 -1
  41. package/dist/codegen/generators/customer-profile-operations.js +0 -126
  42. package/dist/codegen/generators/customer-profile-types.d.ts +0 -6
  43. package/dist/codegen/generators/customer-profile-types.d.ts.map +0 -1
  44. package/dist/codegen/generators/customer-profile-types.js +0 -45
  45. package/dist/codegen/generators/documents.d.ts +0 -12
  46. package/dist/codegen/generators/documents.d.ts.map +0 -1
  47. package/dist/codegen/generators/documents.js +0 -178
  48. package/dist/codegen/generators/field-types.d.ts +0 -5
  49. package/dist/codegen/generators/field-types.d.ts.map +0 -1
  50. package/dist/codegen/generators/field-types.js +0 -346
  51. package/dist/codegen/generators/model-index.d.ts +0 -6
  52. package/dist/codegen/generators/model-index.d.ts.map +0 -1
  53. package/dist/codegen/generators/model-index.js +0 -26
  54. package/dist/codegen/generators/model-types.d.ts +0 -12
  55. package/dist/codegen/generators/model-types.d.ts.map +0 -1
  56. package/dist/codegen/generators/model-types.js +0 -177
  57. package/dist/codegen/generators/public-schema-content.d.ts +0 -14
  58. package/dist/codegen/generators/public-schema-content.d.ts.map +0 -1
  59. package/dist/codegen/generators/public-schema-content.js +0 -22
  60. package/dist/codegen/generators/react-hooks-index.d.ts +0 -6
  61. package/dist/codegen/generators/react-hooks-index.d.ts.map +0 -1
  62. package/dist/codegen/generators/react-hooks-index.js +0 -20
  63. package/dist/codegen/generators/react-hooks.d.ts +0 -7
  64. package/dist/codegen/generators/react-hooks.d.ts.map +0 -1
  65. package/dist/codegen/generators/react-hooks.js +0 -139
  66. package/dist/codegen/generators/remix-loaders-index.d.ts +0 -6
  67. package/dist/codegen/generators/remix-loaders-index.d.ts.map +0 -1
  68. package/dist/codegen/generators/remix-loaders-index.js +0 -20
  69. package/dist/codegen/generators/remix-loaders.d.ts +0 -7
  70. package/dist/codegen/generators/remix-loaders.d.ts.map +0 -1
  71. package/dist/codegen/generators/remix-loaders.js +0 -107
  72. package/dist/codegen/generators/static-documents.d.ts +0 -14
  73. package/dist/codegen/generators/static-documents.d.ts.map +0 -1
  74. package/dist/codegen/generators/static-documents.js +0 -771
  75. package/dist/codegen/generators/swift-customer-profile.d.ts +0 -9
  76. package/dist/codegen/generators/swift-customer-profile.d.ts.map +0 -1
  77. package/dist/codegen/generators/swift-customer-profile.js +0 -152
  78. package/dist/codegen/generators/swift-field-types.d.ts +0 -5
  79. package/dist/codegen/generators/swift-field-types.d.ts.map +0 -1
  80. package/dist/codegen/generators/swift-field-types.js +0 -151
  81. package/dist/codegen/generators/swift-model-keys.d.ts +0 -6
  82. package/dist/codegen/generators/swift-model-keys.d.ts.map +0 -1
  83. package/dist/codegen/generators/swift-model-keys.js +0 -25
  84. package/dist/codegen/generators/swift-types.d.ts +0 -13
  85. package/dist/codegen/generators/swift-types.d.ts.map +0 -1
  86. package/dist/codegen/generators/swift-types.js +0 -188
  87. package/dist/codegen/generators/typed-operations-common.d.ts +0 -6
  88. package/dist/codegen/generators/typed-operations-common.d.ts.map +0 -1
  89. package/dist/codegen/generators/typed-operations-common.js +0 -84
  90. package/dist/codegen/generators/typed-operations-index.d.ts +0 -6
  91. package/dist/codegen/generators/typed-operations-index.d.ts.map +0 -1
  92. package/dist/codegen/generators/typed-operations-index.js +0 -22
  93. package/dist/codegen/generators/typed-operations.d.ts +0 -11
  94. package/dist/codegen/generators/typed-operations.d.ts.map +0 -1
  95. package/dist/codegen/generators/typed-operations.js +0 -263
  96. package/dist/codegen/swift-field-mapping.d.ts +0 -30
  97. package/dist/codegen/swift-field-mapping.d.ts.map +0 -1
  98. package/dist/codegen/swift-field-mapping.js +0 -150
  99. package/dist/codegen/write-files.d.ts +0 -15
  100. package/dist/codegen/write-files.d.ts.map +0 -1
  101. package/dist/codegen/write-files.js +0 -36
  102. package/dist/commands/api-keys.d.ts +0 -4
  103. package/dist/commands/api-keys.d.ts.map +0 -1
  104. package/dist/commands/api-keys.js +0 -129
  105. package/dist/commands/auth-config.d.ts +0 -4
  106. package/dist/commands/auth-config.d.ts.map +0 -1
  107. package/dist/commands/auth-config.js +0 -38
  108. package/dist/commands/auth-providers.d.ts +0 -4
  109. package/dist/commands/auth-providers.d.ts.map +0 -1
  110. package/dist/commands/auth-providers.js +0 -207
  111. package/dist/commands/context.d.ts +0 -4
  112. package/dist/commands/context.d.ts.map +0 -1
  113. package/dist/commands/context.js +0 -91
  114. package/dist/commands/create-extension.d.ts +0 -4
  115. package/dist/commands/create-extension.d.ts.map +0 -1
  116. package/dist/commands/create-extension.js +0 -60
  117. package/dist/commands/customer-profiles.d.ts +0 -4
  118. package/dist/commands/customer-profiles.d.ts.map +0 -1
  119. package/dist/commands/customer-profiles.js +0 -99
  120. package/dist/commands/customers.d.ts +0 -4
  121. package/dist/commands/customers.d.ts.map +0 -1
  122. package/dist/commands/customers.js +0 -126
  123. package/dist/commands/embeddings.d.ts +0 -4
  124. package/dist/commands/embeddings.d.ts.map +0 -1
  125. package/dist/commands/embeddings.js +0 -145
  126. package/dist/commands/experiments.d.ts +0 -4
  127. package/dist/commands/experiments.d.ts.map +0 -1
  128. package/dist/commands/experiments.js +0 -196
  129. package/dist/commands/extensions.d.ts +0 -4
  130. package/dist/commands/extensions.d.ts.map +0 -1
  131. package/dist/commands/extensions.js +0 -210
  132. package/dist/commands/files.d.ts +0 -4
  133. package/dist/commands/files.d.ts.map +0 -1
  134. package/dist/commands/files.js +0 -143
  135. package/dist/commands/hooks.d.ts +0 -4
  136. package/dist/commands/hooks.d.ts.map +0 -1
  137. package/dist/commands/hooks.js +0 -228
  138. package/dist/commands/locales.d.ts +0 -4
  139. package/dist/commands/locales.d.ts.map +0 -1
  140. package/dist/commands/locales.js +0 -140
  141. package/dist/commands/login.d.ts +0 -4
  142. package/dist/commands/login.d.ts.map +0 -1
  143. package/dist/commands/login.js +0 -124
  144. package/dist/commands/logout.d.ts +0 -4
  145. package/dist/commands/logout.d.ts.map +0 -1
  146. package/dist/commands/logout.js +0 -16
  147. package/dist/commands/media.d.ts +0 -4
  148. package/dist/commands/media.d.ts.map +0 -1
  149. package/dist/commands/media.js +0 -44
  150. package/dist/commands/models.d.ts +0 -4
  151. package/dist/commands/models.d.ts.map +0 -1
  152. package/dist/commands/models.js +0 -153
  153. package/dist/commands/notes.d.ts +0 -4
  154. package/dist/commands/notes.d.ts.map +0 -1
  155. package/dist/commands/notes.js +0 -132
  156. package/dist/commands/notifications.d.ts +0 -4
  157. package/dist/commands/notifications.d.ts.map +0 -1
  158. package/dist/commands/notifications.js +0 -73
  159. package/dist/commands/operations.d.ts +0 -4
  160. package/dist/commands/operations.d.ts.map +0 -1
  161. package/dist/commands/operations.js +0 -341
  162. package/dist/commands/playground.d.ts +0 -4
  163. package/dist/commands/playground.d.ts.map +0 -1
  164. package/dist/commands/playground.js +0 -270
  165. package/dist/commands/pull.d.ts +0 -4
  166. package/dist/commands/pull.d.ts.map +0 -1
  167. package/dist/commands/pull.js +0 -300
  168. package/dist/commands/records.d.ts +0 -4
  169. package/dist/commands/records.d.ts.map +0 -1
  170. package/dist/commands/records.js +0 -314
  171. package/dist/commands/register-commands.d.ts +0 -7
  172. package/dist/commands/register-commands.d.ts.map +0 -1
  173. package/dist/commands/register-commands.js +0 -259
  174. package/dist/commands/schedules.d.ts +0 -4
  175. package/dist/commands/schedules.d.ts.map +0 -1
  176. package/dist/commands/schedules.js +0 -155
  177. package/dist/commands/search.d.ts +0 -4
  178. package/dist/commands/search.d.ts.map +0 -1
  179. package/dist/commands/search.js +0 -60
  180. package/dist/commands/segments.d.ts +0 -4
  181. package/dist/commands/segments.d.ts.map +0 -1
  182. package/dist/commands/segments.js +0 -155
  183. package/dist/commands/select-project.d.ts +0 -4
  184. package/dist/commands/select-project.d.ts.map +0 -1
  185. package/dist/commands/select-project.js +0 -144
  186. package/dist/commands/settings.d.ts +0 -4
  187. package/dist/commands/settings.d.ts.map +0 -1
  188. package/dist/commands/settings.js +0 -115
  189. package/dist/commands/variant-catalog.d.ts +0 -4
  190. package/dist/commands/variant-catalog.d.ts.map +0 -1
  191. package/dist/commands/variant-catalog.js +0 -118
  192. package/dist/commands/whoami.d.ts +0 -4
  193. package/dist/commands/whoami.d.ts.map +0 -1
  194. package/dist/commands/whoami.js +0 -51
  195. package/dist/config/pull-config.d.ts +0 -33
  196. package/dist/config/pull-config.d.ts.map +0 -1
  197. package/dist/config/pull-config.js +0 -119
  198. package/dist/config/types.d.ts.map +0 -1
  199. package/dist/graphql/generated.d.ts +0 -6074
  200. package/dist/graphql/generated.d.ts.map +0 -1
  201. package/dist/graphql/generated.js +0 -355
  202. package/dist/lib/client.d.ts +0 -18
  203. package/dist/lib/client.d.ts.map +0 -1
  204. package/dist/lib/client.js +0 -64
  205. package/dist/lib/config-loader.d.ts +0 -28
  206. package/dist/lib/config-loader.d.ts.map +0 -1
  207. package/dist/lib/config-loader.js +0 -49
  208. package/dist/lib/config.d.ts +0 -12
  209. package/dist/lib/config.d.ts.map +0 -1
  210. package/dist/lib/config.js +0 -8
  211. package/dist/lib/errors.d.ts +0 -6
  212. package/dist/lib/errors.d.ts.map +0 -1
  213. package/dist/lib/errors.js +0 -76
  214. package/dist/lib/extension-helpers.d.ts.map +0 -1
  215. package/dist/lib/hook-helpers.d.ts.map +0 -1
  216. package/dist/lib/input.d.ts +0 -38
  217. package/dist/lib/input.d.ts.map +0 -1
  218. package/dist/lib/input.js +0 -108
  219. package/dist/lib/output.d.ts +0 -31
  220. package/dist/lib/output.d.ts.map +0 -1
  221. package/dist/lib/output.js +0 -107
  222. package/dist/lib/seed-helpers.d.ts.map +0 -1
  223. package/dist/scaffold/package-manager.d.ts +0 -12
  224. package/dist/scaffold/package-manager.d.ts.map +0 -1
  225. package/dist/scaffold/package-manager.js +0 -51
  226. package/dist/scaffold/scaffold.d.ts +0 -4
  227. package/dist/scaffold/scaffold.d.ts.map +0 -1
  228. package/dist/scaffold/scaffold.js +0 -462
@@ -1,9 +0,0 @@
1
- /**
2
- * Generates a Swift file for the customer profile schema with:
3
- * - Field key enum (compile-time safe field keys)
4
- * - Data struct (typed representation)
5
- * - Serialization helpers (toSyncData / fromSyncData)
6
- */
7
- import type { CodegenCustomerProfileSchema } from '../fetch-customer-profile-schema.js';
8
- export declare function generateSwiftCustomerProfileFile(schema: CodegenCustomerProfileSchema): string;
9
- //# sourceMappingURL=swift-customer-profile.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"swift-customer-profile.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/swift-customer-profile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AAOxF,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,4BAA4B,GACnC,MAAM,CAgCR"}
@@ -1,152 +0,0 @@
1
- /**
2
- * Generates a Swift file for the customer profile schema with:
3
- * - Field key enum (compile-time safe field keys)
4
- * - Data struct (typed representation)
5
- * - Serialization helpers (toSyncData / fromSyncData)
6
- */
7
- import { getSwiftFieldType, SWIFT_FIELD_TYPE_MAPPING, } from '../swift-field-mapping.js';
8
- export function generateSwiftCustomerProfileFile(schema) {
9
- const typeName = 'CustomerProfile';
10
- const fields = schema.fields ?? [];
11
- const lines = [];
12
- // Header
13
- lines.push('//');
14
- lines.push('// CustomerProfile.swift');
15
- lines.push('//');
16
- lines.push(`// Generated from customer profile schema (version ${schema.version})`);
17
- lines.push('//');
18
- lines.push('// @generated by foir \u2014 DO NOT EDIT MANUALLY');
19
- lines.push('//');
20
- lines.push('');
21
- lines.push('import Foundation');
22
- lines.push('');
23
- // 1. Field key enum
24
- lines.push(generateFieldsEnum(typeName, fields));
25
- lines.push('');
26
- // 2. Data struct
27
- lines.push(generateDataStruct(typeName, fields));
28
- lines.push('');
29
- // 3. Serialization extension
30
- lines.push(generateSerializationExtension(typeName, fields));
31
- return lines.join('\n');
32
- }
33
- function generateFieldsEnum(typeName, fields) {
34
- const lines = [];
35
- lines.push(`// MARK: - ${typeName} Field Keys`);
36
- lines.push('');
37
- lines.push(`enum ${typeName}Fields {`);
38
- for (const field of fields) {
39
- lines.push(` static let ${field.key} = "${field.key}"`);
40
- }
41
- lines.push('}');
42
- return lines.join('\n');
43
- }
44
- function generateDataStruct(typeName, fields) {
45
- const lines = [];
46
- lines.push(`// MARK: - ${typeName} Data`);
47
- lines.push('');
48
- lines.push(`struct ${typeName}Data {`);
49
- for (const field of fields) {
50
- const { type, isOptional } = getSwiftFieldType(field);
51
- const optionalSuffix = isOptional ? '?' : '';
52
- lines.push(` var ${field.key}: ${type}${optionalSuffix}`);
53
- }
54
- lines.push('}');
55
- return lines.join('\n');
56
- }
57
- function generateSerializationExtension(typeName, fields) {
58
- const lines = [];
59
- lines.push(`// MARK: - ${typeName} Serialization`);
60
- lines.push('');
61
- lines.push(`extension ${typeName}Data {`);
62
- // toSyncData()
63
- lines.push(' func toSyncData() -> [String: Any] {');
64
- const requiredFields = fields.filter((f) => {
65
- const { isOptional } = getSwiftFieldType(f);
66
- return !isOptional;
67
- });
68
- const optionalFields = fields.filter((f) => {
69
- const { isOptional } = getSwiftFieldType(f);
70
- return isOptional;
71
- });
72
- if (requiredFields.length > 0) {
73
- if (optionalFields.length === 0) {
74
- lines.push(' return [');
75
- requiredFields.forEach((f, i) => {
76
- const comma = i < requiredFields.length - 1 ? ',' : '';
77
- lines.push(` ${typeName}Fields.${f.key}: ${toSyncValueExpr(f)}${comma}`);
78
- });
79
- lines.push(' ]');
80
- }
81
- else {
82
- lines.push(' var data: [String: Any] = [');
83
- requiredFields.forEach((f, i) => {
84
- const comma = i < requiredFields.length - 1 ? ',' : '';
85
- lines.push(` ${typeName}Fields.${f.key}: ${toSyncValueExpr(f)}${comma}`);
86
- });
87
- lines.push(' ]');
88
- for (const f of optionalFields) {
89
- lines.push(` if let ${f.key} { data[${typeName}Fields.${f.key}] = ${toSyncValueExprForOptional(f)} }`);
90
- }
91
- lines.push(' return data');
92
- }
93
- }
94
- else {
95
- lines.push(' var data: [String: Any] = [:]');
96
- for (const f of optionalFields) {
97
- lines.push(` if let ${f.key} { data[${typeName}Fields.${f.key}] = ${toSyncValueExprForOptional(f)} }`);
98
- }
99
- lines.push(' return data');
100
- }
101
- lines.push(' }');
102
- lines.push('');
103
- // fromSyncData()
104
- lines.push(' static func fromSyncData(_ data: [String: Any]) -> ' +
105
- typeName +
106
- 'Data {');
107
- lines.push(` ${typeName}Data(`);
108
- fields.forEach((field, i) => {
109
- const comma = i < fields.length - 1 ? ',' : '';
110
- const { isOptional, mapping } = getSwiftFieldType(field);
111
- lines.push(` ${field.key}: ${fromSyncDataExpr(field, typeName, isOptional, mapping)}${comma}`);
112
- });
113
- lines.push(' )');
114
- lines.push(' }');
115
- lines.push('}');
116
- lines.push('');
117
- return lines.join('\n');
118
- }
119
- function toSyncValueExpr(field) {
120
- const mapping = SWIFT_FIELD_TYPE_MAPPING[field.type];
121
- if (mapping?.needsSharedType) {
122
- return `${field.key}.toSyncData()`;
123
- }
124
- return field.key;
125
- }
126
- function toSyncValueExprForOptional(field) {
127
- const mapping = SWIFT_FIELD_TYPE_MAPPING[field.type];
128
- if (mapping?.needsSharedType) {
129
- return `${field.key}.toSyncData()`;
130
- }
131
- return field.key;
132
- }
133
- function fromSyncDataExpr(field, typeName, isOptional, mapping) {
134
- const accessor = `data[${typeName}Fields.${field.key}]`;
135
- if (!mapping) {
136
- return isOptional ? `${accessor}` : `${accessor} ?? nil`;
137
- }
138
- if (mapping.needsSharedType) {
139
- const dictCast = `${accessor} as? [String: Any]`;
140
- if (isOptional) {
141
- return `(${dictCast}).map { ${mapping.type}.fromSyncData($0) }`;
142
- }
143
- return `${mapping.type}.fromSyncData(${dictCast} ?? [:])`;
144
- }
145
- if (field.type === 'json') {
146
- return isOptional ? accessor : `${accessor}`;
147
- }
148
- if (isOptional) {
149
- return `${accessor} ${mapping.castExpression}`;
150
- }
151
- return `${accessor} ${mapping.castExpression} ?? ${mapping.defaultValue}`;
152
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Generates the shared FieldTypes.swift file with platform value type structs.
3
- */
4
- export declare function generateSwiftFieldTypesFile(): string;
5
- //# sourceMappingURL=swift-field-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"swift-field-types.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/swift-field-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wBAAgB,2BAA2B,IAAI,MAAM,CAmJpD"}
@@ -1,151 +0,0 @@
1
- /**
2
- * Generates the shared FieldTypes.swift file with platform value type structs.
3
- */
4
- export function generateSwiftFieldTypesFile() {
5
- return `//
6
- // FieldTypes.swift
7
- //
8
- // Shared value types for platform sync data.
9
- //
10
- // @generated by foir \u2014 DO NOT EDIT MANUALLY
11
- //
12
-
13
- import Foundation
14
-
15
- // MARK: - Image
16
-
17
- struct ImageValue {
18
- let id: String
19
- let url: String
20
- var alt: String?
21
- var width: Int?
22
- var height: Int?
23
- var dominantColor: String?
24
- var blurhash: String?
25
-
26
- func toSyncData() -> [String: Any] {
27
- var data: [String: Any] = ["fileId": id, "source": "internal"]
28
- if let alt { data["altText"] = alt }
29
- if let width { data["width"] = width }
30
- if let height { data["height"] = height }
31
- if let dominantColor { data["dominantColor"] = dominantColor }
32
- if let blurhash { data["blurhash"] = blurhash }
33
- return data
34
- }
35
-
36
- static func fromSyncData(_ data: [String: Any]) -> ImageValue {
37
- ImageValue(
38
- id: data["fileId"] as? String ?? data["id"] as? String ?? "",
39
- url: data["url"] as? String ?? "",
40
- alt: data["altText"] as? String ?? data["alt"] as? String,
41
- width: data["width"] as? Int,
42
- height: data["height"] as? Int,
43
- dominantColor: data["dominantColor"] as? String,
44
- blurhash: data["blurhash"] as? String
45
- )
46
- }
47
- }
48
-
49
- // MARK: - Video
50
-
51
- struct VideoValue {
52
- let id: String
53
- let url: String
54
- var thumbnail: String?
55
- var duration: Double?
56
-
57
- func toSyncData() -> [String: Any] {
58
- var data: [String: Any] = ["fileId": id, "source": "internal"]
59
- if let thumbnail { data["thumbnailUrl"] = thumbnail }
60
- if let duration { data["duration"] = duration }
61
- return data
62
- }
63
-
64
- static func fromSyncData(_ data: [String: Any]) -> VideoValue {
65
- VideoValue(
66
- id: data["fileId"] as? String ?? data["id"] as? String ?? "",
67
- url: data["url"] as? String ?? "",
68
- thumbnail: data["thumbnailUrl"] as? String ?? data["thumbnail"] as? String,
69
- duration: data["duration"] as? Double
70
- )
71
- }
72
- }
73
-
74
- // MARK: - File
75
-
76
- struct FileValue {
77
- let id: String
78
- let url: String
79
- let name: String
80
- let size: Int
81
- let mimeType: String
82
-
83
- func toSyncData() -> [String: Any] {
84
- [
85
- "fileId": id,
86
- "source": "internal",
87
- "filename": name,
88
- "fileSize": size,
89
- "mimeType": mimeType,
90
- ]
91
- }
92
-
93
- static func fromSyncData(_ data: [String: Any]) -> FileValue {
94
- FileValue(
95
- id: data["fileId"] as? String ?? data["id"] as? String ?? "",
96
- url: data["url"] as? String ?? "",
97
- name: data["filename"] as? String ?? data["name"] as? String ?? "",
98
- size: data["fileSize"] as? Int ?? data["size"] as? Int ?? 0,
99
- mimeType: data["mimeType"] as? String ?? ""
100
- )
101
- }
102
- }
103
-
104
- // MARK: - Currency
105
-
106
- struct CurrencyValue {
107
- let amount: Double
108
- let currency: String
109
-
110
- func toSyncData() -> [String: Any] {
111
- ["amount": amount, "currency": currency]
112
- }
113
-
114
- static func fromSyncData(_ data: [String: Any]) -> CurrencyValue {
115
- CurrencyValue(
116
- amount: data["amount"] as? Double ?? 0,
117
- currency: data["currency"] as? String ?? ""
118
- )
119
- }
120
- }
121
-
122
- // MARK: - Link
123
-
124
- struct LinkValue {
125
- let type: String
126
- var entityModelKey: String?
127
- var entityNaturalKey: String?
128
- var url: String?
129
- var target: String?
130
-
131
- func toSyncData() -> [String: Any] {
132
- var data: [String: Any] = ["type": type]
133
- if let entityModelKey { data["entityModelKey"] = entityModelKey }
134
- if let entityNaturalKey { data["entityNaturalKey"] = entityNaturalKey }
135
- if let url { data["url"] = url }
136
- if let target { data["target"] = target }
137
- return data
138
- }
139
-
140
- static func fromSyncData(_ data: [String: Any]) -> LinkValue {
141
- LinkValue(
142
- type: data["type"] as? String ?? "",
143
- entityModelKey: data["entityModelKey"] as? String,
144
- entityNaturalKey: data["entityNaturalKey"] as? String,
145
- url: data["url"] as? String,
146
- target: data["target"] as? String
147
- )
148
- }
149
- }
150
- `;
151
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Generates ModelKeys.swift with all model key constants in one enum.
3
- */
4
- import type { CodegenModel } from '../fetch-models.js';
5
- export declare function generateSwiftModelKeys(models: CodegenModel[]): string;
6
- //# sourceMappingURL=swift-model-keys.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"swift-model-keys.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/swift-model-keys.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,CAwBrE"}
@@ -1,25 +0,0 @@
1
- /**
2
- * Generates ModelKeys.swift with all model key constants in one enum.
3
- */
4
- import { toCamelCase } from '../field-mapping.js';
5
- export function generateSwiftModelKeys(models) {
6
- const lines = [];
7
- lines.push('//');
8
- lines.push('// ModelKeys.swift');
9
- lines.push('//');
10
- lines.push('// All model key constants.');
11
- lines.push('//');
12
- lines.push('// @generated by foir \u2014 DO NOT EDIT MANUALLY');
13
- lines.push('//');
14
- lines.push('');
15
- lines.push('import Foundation');
16
- lines.push('');
17
- lines.push('enum ModelKeys {');
18
- for (const model of models) {
19
- const propName = toCamelCase(model.key);
20
- lines.push(` static let ${propName} = "${model.key}"`);
21
- }
22
- lines.push('}');
23
- lines.push('');
24
- return lines.join('\n');
25
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * Generates per-model Swift files with:
3
- * - Field key enum (compile-time safe field keys)
4
- * - Data struct (typed representation)
5
- * - Serialization helpers (toSyncData / fromSyncData)
6
- * - Model config constant
7
- */
8
- import type { CodegenModel } from '../fetch-models.js';
9
- /**
10
- * Generate a complete Swift file for a single model.
11
- */
12
- export declare function generateSwiftModelFile(model: CodegenModel): string;
13
- //# sourceMappingURL=swift-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"swift-types.d.ts","sourceRoot":"","sources":["../../../src/codegen/generators/swift-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAQvD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAkClE"}
@@ -1,188 +0,0 @@
1
- /**
2
- * Generates per-model Swift files with:
3
- * - Field key enum (compile-time safe field keys)
4
- * - Data struct (typed representation)
5
- * - Serialization helpers (toSyncData / fromSyncData)
6
- * - Model config constant
7
- */
8
- import { toPascalCase } from '../field-mapping.js';
9
- import { getSwiftFieldType, SWIFT_FIELD_TYPE_MAPPING, } from '../swift-field-mapping.js';
10
- /**
11
- * Generate a complete Swift file for a single model.
12
- */
13
- export function generateSwiftModelFile(model) {
14
- const typeName = toPascalCase(model.key);
15
- const fields = model.fields ?? [];
16
- const lines = [];
17
- // Header
18
- lines.push('//');
19
- lines.push(`// ${typeName}.swift`);
20
- lines.push('//');
21
- lines.push(`// Generated from model '${model.key}'`);
22
- lines.push('//');
23
- lines.push('// @generated by foir \u2014 DO NOT EDIT MANUALLY');
24
- lines.push('//');
25
- lines.push('');
26
- lines.push('import Foundation');
27
- lines.push('');
28
- // 1. Field key enum
29
- lines.push(generateFieldsEnum(typeName, fields));
30
- lines.push('');
31
- // 2. Data struct
32
- lines.push(generateDataStruct(typeName, fields));
33
- lines.push('');
34
- // 3. Serialization extension
35
- lines.push(generateSerializationExtension(typeName, fields));
36
- lines.push('');
37
- // 4. Config enum
38
- lines.push(generateConfigEnum(typeName, model));
39
- return lines.join('\n');
40
- }
41
- function generateFieldsEnum(typeName, fields) {
42
- const lines = [];
43
- lines.push(`// MARK: - ${typeName} Field Keys`);
44
- lines.push('');
45
- lines.push(`enum ${typeName}Fields {`);
46
- for (const field of fields) {
47
- lines.push(` static let ${field.key} = "${field.key}"`);
48
- }
49
- lines.push('}');
50
- return lines.join('\n');
51
- }
52
- function generateDataStruct(typeName, fields) {
53
- const lines = [];
54
- lines.push(`// MARK: - ${typeName} Data`);
55
- lines.push('');
56
- lines.push(`struct ${typeName}Data {`);
57
- for (const field of fields) {
58
- const { type, isOptional } = getSwiftFieldType(field);
59
- const optionalSuffix = isOptional ? '?' : '';
60
- lines.push(` var ${field.key}: ${type}${optionalSuffix}`);
61
- }
62
- lines.push('}');
63
- return lines.join('\n');
64
- }
65
- function generateSerializationExtension(typeName, fields) {
66
- const lines = [];
67
- lines.push(`// MARK: - ${typeName} Serialization`);
68
- lines.push('');
69
- lines.push(`extension ${typeName}Data {`);
70
- // toSyncData()
71
- lines.push(' func toSyncData() -> [String: Any] {');
72
- // Find the first required (non-optional) field to seed the dictionary
73
- const requiredFields = fields.filter((f) => {
74
- const { isOptional } = getSwiftFieldType(f);
75
- return !isOptional;
76
- });
77
- const optionalFields = fields.filter((f) => {
78
- const { isOptional } = getSwiftFieldType(f);
79
- return isOptional;
80
- });
81
- if (requiredFields.length > 0) {
82
- if (optionalFields.length === 0) {
83
- // All fields are required — return inline
84
- lines.push(` return [`);
85
- requiredFields.forEach((f, i) => {
86
- const comma = i < requiredFields.length - 1 ? ',' : '';
87
- lines.push(` ${typeName}Fields.${f.key}: ${toSyncValueExpr(f)}${comma}`);
88
- });
89
- lines.push(' ]');
90
- }
91
- else {
92
- lines.push(` var data: [String: Any] = [`);
93
- requiredFields.forEach((f, i) => {
94
- const comma = i < requiredFields.length - 1 ? ',' : '';
95
- lines.push(` ${typeName}Fields.${f.key}: ${toSyncValueExpr(f)}${comma}`);
96
- });
97
- lines.push(' ]');
98
- for (const f of optionalFields) {
99
- lines.push(` if let ${f.key} { data[${typeName}Fields.${f.key}] = ${toSyncValueExprForOptional(f)} }`);
100
- }
101
- lines.push(' return data');
102
- }
103
- }
104
- else {
105
- // All fields are optional
106
- lines.push(' var data: [String: Any] = [:]');
107
- for (const f of optionalFields) {
108
- lines.push(` if let ${f.key} { data[${typeName}Fields.${f.key}] = ${toSyncValueExprForOptional(f)} }`);
109
- }
110
- lines.push(' return data');
111
- }
112
- lines.push(' }');
113
- lines.push('');
114
- // fromSyncData()
115
- lines.push(' static func fromSyncData(_ data: [String: Any]) -> ' +
116
- typeName +
117
- 'Data {');
118
- lines.push(` ${typeName}Data(`);
119
- fields.forEach((field, i) => {
120
- const comma = i < fields.length - 1 ? ',' : '';
121
- const { isOptional, mapping } = getSwiftFieldType(field);
122
- lines.push(` ${field.key}: ${fromSyncDataExpr(field, typeName, isOptional, mapping)}${comma}`);
123
- });
124
- lines.push(' )');
125
- lines.push(' }');
126
- lines.push('}');
127
- return lines.join('\n');
128
- }
129
- /** Expression for a required field value in toSyncData */
130
- function toSyncValueExpr(field) {
131
- const mapping = SWIFT_FIELD_TYPE_MAPPING[field.type];
132
- if (mapping?.needsSharedType) {
133
- return `${field.key}.toSyncData()`;
134
- }
135
- return field.key;
136
- }
137
- /** Expression for an optional field value in toSyncData (inside `if let`) */
138
- function toSyncValueExprForOptional(field) {
139
- const mapping = SWIFT_FIELD_TYPE_MAPPING[field.type];
140
- if (mapping?.needsSharedType) {
141
- return `${field.key}.toSyncData()`;
142
- }
143
- return field.key;
144
- }
145
- /** Expression for reading a field from sync data dictionary */
146
- function fromSyncDataExpr(field, typeName, isOptional, mapping) {
147
- const accessor = `data[${typeName}Fields.${field.key}]`;
148
- if (!mapping) {
149
- // Unknown type
150
- return isOptional ? `${accessor}` : `${accessor} ?? nil`;
151
- }
152
- // Types with shared structs need .fromSyncData conversion
153
- if (mapping.needsSharedType) {
154
- const dictCast = `${accessor} as? [String: Any]`;
155
- if (isOptional) {
156
- return `(${dictCast}).map { ${mapping.type}.fromSyncData($0) }`;
157
- }
158
- return `${mapping.type}.fromSyncData(${dictCast} ?? [:])`;
159
- }
160
- // json → Any
161
- if (field.type === 'json') {
162
- return isOptional ? accessor : `${accessor}`;
163
- }
164
- // Simple cast types
165
- if (isOptional) {
166
- return `${accessor} ${mapping.castExpression}`;
167
- }
168
- return `${accessor} ${mapping.castExpression} ?? ${mapping.defaultValue}`;
169
- }
170
- function generateConfigEnum(typeName, model) {
171
- const lines = [];
172
- lines.push(`// MARK: - ${typeName} Config`);
173
- lines.push('');
174
- lines.push(`enum ${typeName}Config {`);
175
- const escapedName = (model.name ?? model.key).replace(/"/g, '\\"');
176
- lines.push(` static let key = "${model.key}"`);
177
- lines.push(` static let name = "${escapedName}"`);
178
- lines.push(` static let customerScoped = ${model.config.customerScoped}`);
179
- lines.push(` static let publicApi = ${model.config.publicApi}`);
180
- lines.push(` static let versioning = ${model.config.versioning}`);
181
- lines.push(` static let publishing = ${model.config.publishing}`);
182
- lines.push(` static let variants = ${model.config.variants}`);
183
- lines.push(` static let sharingEnabled = ${model.config.sharing?.enabled ?? false}`);
184
- lines.push(` static let sharingRequireAcceptance = ${model.config.sharing?.requireAcceptance ?? true}`);
185
- lines.push('}');
186
- lines.push('');
187
- return lines.join('\n');
188
- }
@@ -1,6 +0,0 @@
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(typesRelPath: string): string;
6
- //# sourceMappingURL=typed-operations-common.d.ts.map
@@ -1 +0,0 @@
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,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CA+E1E"}
@@ -1,84 +0,0 @@
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(typesRelPath) {
6
- return `/**
7
- * Shared types for typed GraphQL operations.
8
- *
9
- * @generated by foir — DO NOT EDIT MANUALLY
10
- */
11
-
12
- import type { JsonValue } from '${typesRelPath}/field-types.js';
13
-
14
- /** A record with strongly-typed data. */
15
- export interface BaseRecord<T> {
16
- id: string;
17
- modelKey: string;
18
- naturalKey: string | null;
19
- data: T;
20
- metadata: Record<string, JsonValue> | null;
21
- publishedVersionNumber: number | null;
22
- publishedAt: string | null;
23
- versionNumber: number | null;
24
- changeDescription: string | null;
25
- createdAt: string;
26
- updatedAt: string;
27
- }
28
-
29
- /** Resolved content wrapping strongly-typed data. */
30
- export interface ResolvedContent<T> {
31
- content: T;
32
- record: { id: string; modelKey: string; naturalKey: string | null };
33
- version: { id: string; versionNumber: number } | null;
34
- }
35
-
36
- /** Paginated list result. */
37
- export interface PaginatedResult<T> {
38
- items: (BaseRecord<T> & { resolved: ResolvedContent<T> | null })[];
39
- total: number;
40
- }
41
-
42
- /** Result of a createRecord mutation. */
43
- export interface CreateRecordResult<T> {
44
- record: BaseRecord<T>;
45
- }
46
-
47
- /** Result of an updateRecord mutation. */
48
- export interface UpdateRecordResult<T> {
49
- record: BaseRecord<T>;
50
- matched: boolean;
51
- }
52
-
53
- /** Result of a deleteRecord mutation. */
54
- export interface DeleteRecordResult {
55
- id: string;
56
- }
57
-
58
- /** Share resource type. */
59
- export interface ShareResult {
60
- id: string;
61
- resourceType: string;
62
- permission: string;
63
- status: string;
64
- acceptedAt: string | null;
65
- declinedAt: string | null;
66
- expiresAt: string | null;
67
- createdAt: string;
68
- revokedAt: string | null;
69
- }
70
-
71
- /** A share that includes the shared record. */
72
- export interface ShareWithRecord<T> extends ShareResult {
73
- record: BaseRecord<T>;
74
- }
75
-
76
- /** Field selection for resolved content — pick or omit specific fields. */
77
- export interface FieldSelection<T = Record<string, unknown>> {
78
- /** Include only these field keys (mutually exclusive with omit) */
79
- pick?: (keyof T & string)[];
80
- /** Exclude these field keys (mutually exclusive with omit) */
81
- omit?: (keyof T & string)[];
82
- }
83
- `;
84
- }
@@ -1,6 +0,0 @@
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
@@ -1 +0,0 @@
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"}