@underpeaks/generator-flutter 1.0.19

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 (277) hide show
  1. package/dist/adapters/bloc/bloc.d.ts +3 -0
  2. package/dist/adapters/bloc/bloc.d.ts.map +1 -0
  3. package/dist/adapters/bloc/bloc.js +283 -0
  4. package/dist/adapters/bloc/bloc.js.map +1 -0
  5. package/dist/adapters/provider/provider.d.ts +3 -0
  6. package/dist/adapters/provider/provider.d.ts.map +1 -0
  7. package/dist/adapters/provider/provider.js +182 -0
  8. package/dist/adapters/provider/provider.js.map +1 -0
  9. package/dist/adapters/riverpod/provider.d.ts +3 -0
  10. package/dist/adapters/riverpod/provider.d.ts.map +1 -0
  11. package/dist/adapters/riverpod/provider.js +230 -0
  12. package/dist/adapters/riverpod/provider.js.map +1 -0
  13. package/dist/generator.d.ts +3 -0
  14. package/dist/generator.d.ts.map +1 -0
  15. package/dist/generator.js +199 -0
  16. package/dist/generator.js.map +1 -0
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +6 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/integrations/algolia.d.ts +3 -0
  22. package/dist/integrations/algolia.d.ts.map +1 -0
  23. package/dist/integrations/algolia.js +51 -0
  24. package/dist/integrations/algolia.js.map +1 -0
  25. package/dist/integrations/anthropic.d.ts +3 -0
  26. package/dist/integrations/anthropic.d.ts.map +1 -0
  27. package/dist/integrations/anthropic.js +49 -0
  28. package/dist/integrations/anthropic.js.map +1 -0
  29. package/dist/integrations/aws-s3.d.ts +3 -0
  30. package/dist/integrations/aws-s3.d.ts.map +1 -0
  31. package/dist/integrations/aws-s3.js +67 -0
  32. package/dist/integrations/aws-s3.js.map +1 -0
  33. package/dist/integrations/clerk.d.ts +3 -0
  34. package/dist/integrations/clerk.d.ts.map +1 -0
  35. package/dist/integrations/clerk.js +68 -0
  36. package/dist/integrations/clerk.js.map +1 -0
  37. package/dist/integrations/cloudinary.d.ts +3 -0
  38. package/dist/integrations/cloudinary.d.ts.map +1 -0
  39. package/dist/integrations/cloudinary.js +64 -0
  40. package/dist/integrations/cloudinary.js.map +1 -0
  41. package/dist/integrations/crisp.d.ts +3 -0
  42. package/dist/integrations/crisp.d.ts.map +1 -0
  43. package/dist/integrations/crisp.js +42 -0
  44. package/dist/integrations/crisp.js.map +1 -0
  45. package/dist/integrations/firebase.d.ts +3 -0
  46. package/dist/integrations/firebase.d.ts.map +1 -0
  47. package/dist/integrations/firebase.js +78 -0
  48. package/dist/integrations/firebase.js.map +1 -0
  49. package/dist/integrations/flutterwave.d.ts +3 -0
  50. package/dist/integrations/flutterwave.d.ts.map +1 -0
  51. package/dist/integrations/flutterwave.js +58 -0
  52. package/dist/integrations/flutterwave.js.map +1 -0
  53. package/dist/integrations/gemini.d.ts +3 -0
  54. package/dist/integrations/gemini.d.ts.map +1 -0
  55. package/dist/integrations/gemini.js +49 -0
  56. package/dist/integrations/gemini.js.map +1 -0
  57. package/dist/integrations/github.d.ts +3 -0
  58. package/dist/integrations/github.d.ts.map +1 -0
  59. package/dist/integrations/github.js +58 -0
  60. package/dist/integrations/github.js.map +1 -0
  61. package/dist/integrations/hubspot.d.ts +3 -0
  62. package/dist/integrations/hubspot.d.ts.map +1 -0
  63. package/dist/integrations/hubspot.js +70 -0
  64. package/dist/integrations/hubspot.js.map +1 -0
  65. package/dist/integrations/index.d.ts +3 -0
  66. package/dist/integrations/index.d.ts.map +1 -0
  67. package/dist/integrations/index.js +63 -0
  68. package/dist/integrations/index.js.map +1 -0
  69. package/dist/integrations/lemonsqueezy.d.ts +3 -0
  70. package/dist/integrations/lemonsqueezy.d.ts.map +1 -0
  71. package/dist/integrations/lemonsqueezy.js +49 -0
  72. package/dist/integrations/lemonsqueezy.js.map +1 -0
  73. package/dist/integrations/mailchimp.d.ts +3 -0
  74. package/dist/integrations/mailchimp.d.ts.map +1 -0
  75. package/dist/integrations/mailchimp.js +49 -0
  76. package/dist/integrations/mailchimp.js.map +1 -0
  77. package/dist/integrations/openai.d.ts +3 -0
  78. package/dist/integrations/openai.d.ts.map +1 -0
  79. package/dist/integrations/openai.js +55 -0
  80. package/dist/integrations/openai.js.map +1 -0
  81. package/dist/integrations/payfast.d.ts +3 -0
  82. package/dist/integrations/payfast.d.ts.map +1 -0
  83. package/dist/integrations/payfast.js +55 -0
  84. package/dist/integrations/payfast.js.map +1 -0
  85. package/dist/integrations/pusher.d.ts +3 -0
  86. package/dist/integrations/pusher.d.ts.map +1 -0
  87. package/dist/integrations/pusher.js +64 -0
  88. package/dist/integrations/pusher.js.map +1 -0
  89. package/dist/integrations/resend.d.ts +3 -0
  90. package/dist/integrations/resend.d.ts.map +1 -0
  91. package/dist/integrations/resend.js +51 -0
  92. package/dist/integrations/resend.js.map +1 -0
  93. package/dist/integrations/sendgrid.d.ts +3 -0
  94. package/dist/integrations/sendgrid.d.ts.map +1 -0
  95. package/dist/integrations/sendgrid.js +49 -0
  96. package/dist/integrations/sendgrid.js.map +1 -0
  97. package/dist/integrations/sentry.d.ts +3 -0
  98. package/dist/integrations/sentry.d.ts.map +1 -0
  99. package/dist/integrations/sentry.js +62 -0
  100. package/dist/integrations/sentry.js.map +1 -0
  101. package/dist/integrations/slack.d.ts +3 -0
  102. package/dist/integrations/slack.d.ts.map +1 -0
  103. package/dist/integrations/slack.js +41 -0
  104. package/dist/integrations/slack.js.map +1 -0
  105. package/dist/integrations/storage.d.ts +3 -0
  106. package/dist/integrations/storage.d.ts.map +1 -0
  107. package/dist/integrations/storage.js +106 -0
  108. package/dist/integrations/storage.js.map +1 -0
  109. package/dist/integrations/stripe.d.ts +3 -0
  110. package/dist/integrations/stripe.d.ts.map +1 -0
  111. package/dist/integrations/stripe.js +78 -0
  112. package/dist/integrations/stripe.js.map +1 -0
  113. package/dist/integrations/twilio.d.ts +3 -0
  114. package/dist/integrations/twilio.d.ts.map +1 -0
  115. package/dist/integrations/twilio.js +54 -0
  116. package/dist/integrations/twilio.js.map +1 -0
  117. package/dist/integrations/uploadthing.d.ts +3 -0
  118. package/dist/integrations/uploadthing.d.ts.map +1 -0
  119. package/dist/integrations/uploadthing.js +57 -0
  120. package/dist/integrations/uploadthing.js.map +1 -0
  121. package/dist/templates/api-builder.d.ts +12 -0
  122. package/dist/templates/api-builder.d.ts.map +1 -0
  123. package/dist/templates/api-builder.js +104 -0
  124. package/dist/templates/api-builder.js.map +1 -0
  125. package/dist/templates/api-config.d.ts +3 -0
  126. package/dist/templates/api-config.d.ts.map +1 -0
  127. package/dist/templates/api-config.js +60 -0
  128. package/dist/templates/api-config.js.map +1 -0
  129. package/dist/templates/env.d.ts +3 -0
  130. package/dist/templates/env.d.ts.map +1 -0
  131. package/dist/templates/env.js +27 -0
  132. package/dist/templates/env.js.map +1 -0
  133. package/dist/templates/gitignore.d.ts +3 -0
  134. package/dist/templates/gitignore.d.ts.map +1 -0
  135. package/dist/templates/gitignore.js +61 -0
  136. package/dist/templates/gitignore.js.map +1 -0
  137. package/dist/templates/main.d.ts +3 -0
  138. package/dist/templates/main.d.ts.map +1 -0
  139. package/dist/templates/main.js +66 -0
  140. package/dist/templates/main.js.map +1 -0
  141. package/dist/templates/model.d.ts +3 -0
  142. package/dist/templates/model.d.ts.map +1 -0
  143. package/dist/templates/model.js +104 -0
  144. package/dist/templates/model.js.map +1 -0
  145. package/dist/templates/navigation.d.ts +3 -0
  146. package/dist/templates/navigation.d.ts.map +1 -0
  147. package/dist/templates/navigation.js +306 -0
  148. package/dist/templates/navigation.js.map +1 -0
  149. package/dist/templates/page-auth.d.ts +3 -0
  150. package/dist/templates/page-auth.d.ts.map +1 -0
  151. package/dist/templates/page-auth.js +523 -0
  152. package/dist/templates/page-auth.js.map +1 -0
  153. package/dist/templates/page-blog-post.d.ts +3 -0
  154. package/dist/templates/page-blog-post.d.ts.map +1 -0
  155. package/dist/templates/page-blog-post.js +118 -0
  156. package/dist/templates/page-blog-post.js.map +1 -0
  157. package/dist/templates/page-calendar.d.ts +3 -0
  158. package/dist/templates/page-calendar.d.ts.map +1 -0
  159. package/dist/templates/page-calendar.js +173 -0
  160. package/dist/templates/page-calendar.js.map +1 -0
  161. package/dist/templates/page-cart.d.ts +3 -0
  162. package/dist/templates/page-cart.d.ts.map +1 -0
  163. package/dist/templates/page-cart.js +151 -0
  164. package/dist/templates/page-cart.js.map +1 -0
  165. package/dist/templates/page-chat.d.ts +3 -0
  166. package/dist/templates/page-chat.d.ts.map +1 -0
  167. package/dist/templates/page-chat.js +158 -0
  168. package/dist/templates/page-chat.js.map +1 -0
  169. package/dist/templates/page-checkout.d.ts +3 -0
  170. package/dist/templates/page-checkout.d.ts.map +1 -0
  171. package/dist/templates/page-checkout.js +180 -0
  172. package/dist/templates/page-checkout.js.map +1 -0
  173. package/dist/templates/page-contact.d.ts +1 -0
  174. package/dist/templates/page-contact.d.ts.map +1 -0
  175. package/dist/templates/page-contact.js +143 -0
  176. package/dist/templates/page-contact.js.map +1 -0
  177. package/dist/templates/page-custom.d.ts +3 -0
  178. package/dist/templates/page-custom.d.ts.map +1 -0
  179. package/dist/templates/page-custom.js +45 -0
  180. package/dist/templates/page-custom.js.map +1 -0
  181. package/dist/templates/page-dashboard.d.ts +3 -0
  182. package/dist/templates/page-dashboard.d.ts.map +1 -0
  183. package/dist/templates/page-dashboard.js +157 -0
  184. package/dist/templates/page-dashboard.js.map +1 -0
  185. package/dist/templates/page-detail.d.ts +3 -0
  186. package/dist/templates/page-detail.d.ts.map +1 -0
  187. package/dist/templates/page-detail.js +165 -0
  188. package/dist/templates/page-detail.js.map +1 -0
  189. package/dist/templates/page-feed.d.ts +3 -0
  190. package/dist/templates/page-feed.d.ts.map +1 -0
  191. package/dist/templates/page-feed.js +168 -0
  192. package/dist/templates/page-feed.js.map +1 -0
  193. package/dist/templates/page-form.d.ts +3 -0
  194. package/dist/templates/page-form.d.ts.map +1 -0
  195. package/dist/templates/page-form.js +205 -0
  196. package/dist/templates/page-form.js.map +1 -0
  197. package/dist/templates/page-gallery.d.ts +3 -0
  198. package/dist/templates/page-gallery.d.ts.map +1 -0
  199. package/dist/templates/page-gallery.js +152 -0
  200. package/dist/templates/page-gallery.js.map +1 -0
  201. package/dist/templates/page-invoice.d.ts +3 -0
  202. package/dist/templates/page-invoice.d.ts.map +1 -0
  203. package/dist/templates/page-invoice.js +144 -0
  204. package/dist/templates/page-invoice.js.map +1 -0
  205. package/dist/templates/page-kanban.d.ts +3 -0
  206. package/dist/templates/page-kanban.d.ts.map +1 -0
  207. package/dist/templates/page-kanban.js +114 -0
  208. package/dist/templates/page-kanban.js.map +1 -0
  209. package/dist/templates/page-list.d.ts +3 -0
  210. package/dist/templates/page-list.d.ts.map +1 -0
  211. package/dist/templates/page-list.js +284 -0
  212. package/dist/templates/page-list.js.map +1 -0
  213. package/dist/templates/page-map.d.ts +3 -0
  214. package/dist/templates/page-map.d.ts.map +1 -0
  215. package/dist/templates/page-map.js +94 -0
  216. package/dist/templates/page-map.js.map +1 -0
  217. package/dist/templates/page-messages.d.ts +3 -0
  218. package/dist/templates/page-messages.d.ts.map +1 -0
  219. package/dist/templates/page-messages.js +48 -0
  220. package/dist/templates/page-messages.js.map +1 -0
  221. package/dist/templates/page-onboarding.d.ts +3 -0
  222. package/dist/templates/page-onboarding.d.ts.map +1 -0
  223. package/dist/templates/page-onboarding.js +164 -0
  224. package/dist/templates/page-onboarding.js.map +1 -0
  225. package/dist/templates/page-otp.d.ts +3 -0
  226. package/dist/templates/page-otp.d.ts.map +1 -0
  227. package/dist/templates/page-otp.js +216 -0
  228. package/dist/templates/page-otp.js.map +1 -0
  229. package/dist/templates/page-profile.d.ts +3 -0
  230. package/dist/templates/page-profile.d.ts.map +1 -0
  231. package/dist/templates/page-profile.js +159 -0
  232. package/dist/templates/page-profile.js.map +1 -0
  233. package/dist/templates/page-reset-password.d.ts +3 -0
  234. package/dist/templates/page-reset-password.d.ts.map +1 -0
  235. package/dist/templates/page-reset-password.js +168 -0
  236. package/dist/templates/page-reset-password.js.map +1 -0
  237. package/dist/templates/page-search.d.ts +3 -0
  238. package/dist/templates/page-search.d.ts.map +1 -0
  239. package/dist/templates/page-search.js +112 -0
  240. package/dist/templates/page-search.js.map +1 -0
  241. package/dist/templates/page-settings.d.ts +3 -0
  242. package/dist/templates/page-settings.d.ts.map +1 -0
  243. package/dist/templates/page-settings.js +123 -0
  244. package/dist/templates/page-settings.js.map +1 -0
  245. package/dist/templates/page-splash.d.ts +3 -0
  246. package/dist/templates/page-splash.d.ts.map +1 -0
  247. package/dist/templates/page-splash.js +93 -0
  248. package/dist/templates/page-splash.js.map +1 -0
  249. package/dist/templates/page-wallet.d.ts +3 -0
  250. package/dist/templates/page-wallet.d.ts.map +1 -0
  251. package/dist/templates/page-wallet.js +97 -0
  252. package/dist/templates/page-wallet.js.map +1 -0
  253. package/dist/templates/pubspec.d.ts +3 -0
  254. package/dist/templates/pubspec.d.ts.map +1 -0
  255. package/dist/templates/pubspec.js +72 -0
  256. package/dist/templates/pubspec.js.map +1 -0
  257. package/dist/templates/readme.d.ts +3 -0
  258. package/dist/templates/readme.d.ts.map +1 -0
  259. package/dist/templates/readme.js +111 -0
  260. package/dist/templates/readme.js.map +1 -0
  261. package/dist/templates/repository.d.ts +3 -0
  262. package/dist/templates/repository.d.ts.map +1 -0
  263. package/dist/templates/repository.js +224 -0
  264. package/dist/templates/repository.js.map +1 -0
  265. package/dist/templates/theme.d.ts +3 -0
  266. package/dist/templates/theme.d.ts.map +1 -0
  267. package/dist/templates/theme.js +163 -0
  268. package/dist/templates/theme.js.map +1 -0
  269. package/dist/templates/validators.d.ts +3 -0
  270. package/dist/templates/validators.d.ts.map +1 -0
  271. package/dist/templates/validators.js +38 -0
  272. package/dist/templates/validators.js.map +1 -0
  273. package/dist/templates/widget-card.d.ts +3 -0
  274. package/dist/templates/widget-card.d.ts.map +1 -0
  275. package/dist/templates/widget-card.js +91 -0
  276. package/dist/templates/widget-card.js.map +1 -0
  277. package/package.json +24 -0
@@ -0,0 +1,3 @@
1
+ import type { Model, GeneratedFile } from '@underpeaks/generator-core';
2
+ export declare function generateBlocFiles(model: Model): GeneratedFile[];
3
+ //# sourceMappingURL=bloc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bloc.d.ts","sourceRoot":"","sources":["../../../src/adapters/bloc/bloc.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAA6B,4BAA4B,CAAA;AAG7F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,EAAE,CAwR/D"}
@@ -0,0 +1,283 @@
1
+ "use strict";
2
+ // File: underpeaks_codegen/packages/generator-flutter/src/adapters/bloc/bloc.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.generateBlocFiles = generateBlocFiles;
5
+ const generator_core_1 = require("@underpeaks/generator-core");
6
+ function generateBlocFiles(model) {
7
+ const className = (0, generator_core_1.modelToClassName)(model.name);
8
+ const fileName = (0, generator_core_1.modelToFileName)(model.name);
9
+ const pk = (0, generator_core_1.getPrimaryKey)(model);
10
+ const pkName = pk?.name ?? 'id';
11
+ const eventFile = {
12
+ path: `lib/generated/blocs/${fileName}_event.g.dart`,
13
+ category: 'generated',
14
+ content: `// GENERATED FILE — DO NOT EDIT MANUALLY
15
+ // Generated by Underpeaks CodeGen v1.0.0
16
+ // ignore_for_file: lines_longer_than_80_chars
17
+
18
+ part of '${fileName}_bloc.g.dart';
19
+
20
+ abstract class ${className}Event {}
21
+
22
+ class Load${className}sEvent extends ${className}Event {
23
+ final Map<String, String>? filters;
24
+ Load${className}sEvent({this.filters});
25
+ }
26
+
27
+ class Refresh${className}sEvent extends ${className}Event {
28
+ final Map<String, String>? filters;
29
+ Refresh${className}sEvent({this.filters});
30
+ }
31
+
32
+ class LoadMore${className}sEvent extends ${className}Event {
33
+ final Map<String, String>? filters;
34
+ LoadMore${className}sEvent({this.filters});
35
+ }
36
+
37
+ class LoadOne${className}Event extends ${className}Event {
38
+ final String ${pkName};
39
+ LoadOne${className}Event(this.${pkName});
40
+ }
41
+
42
+ class Create${className}Event extends ${className}Event {
43
+ final ${className} item;
44
+ Create${className}Event(this.item);
45
+ }
46
+
47
+ class Update${className}Event extends ${className}Event {
48
+ final String ${pkName};
49
+ final ${className} item;
50
+ Update${className}Event(this.${pkName}, this.item);
51
+ }
52
+
53
+ class Delete${className}Event extends ${className}Event {
54
+ final String ${pkName};
55
+ Delete${className}Event(this.${pkName});
56
+ }
57
+ `,
58
+ };
59
+ const stateFile = {
60
+ path: `lib/generated/blocs/${fileName}_state.g.dart`,
61
+ category: 'generated',
62
+ content: `// GENERATED FILE — DO NOT EDIT MANUALLY
63
+ // Generated by Underpeaks CodeGen v1.0.0
64
+ // ignore_for_file: lines_longer_than_80_chars
65
+
66
+ part of '${fileName}_bloc.g.dart';
67
+
68
+ class ${className}State {
69
+ final List<${className}> items;
70
+ final ${className}? selected;
71
+ final bool loading;
72
+ final bool loadingMore;
73
+ final bool hasMore;
74
+ final int page;
75
+ final String? error;
76
+
77
+ const ${className}State({
78
+ this.items = const [],
79
+ this.selected,
80
+ this.loading = false,
81
+ this.loadingMore = false,
82
+ this.hasMore = true,
83
+ this.page = 1,
84
+ this.error,
85
+ });
86
+
87
+ ${className}State copyWith({
88
+ List<${className}>? items,
89
+ ${className}? selected,
90
+ bool? loading,
91
+ bool? loadingMore,
92
+ bool? hasMore,
93
+ int? page,
94
+ String? error,
95
+ }) {
96
+ return ${className}State(
97
+ items: items ?? this.items,
98
+ selected: selected ?? this.selected,
99
+ loading: loading ?? this.loading,
100
+ loadingMore: loadingMore ?? this.loadingMore,
101
+ hasMore: hasMore ?? this.hasMore,
102
+ page: page ?? this.page,
103
+ error: error ?? this.error,
104
+ );
105
+ }
106
+
107
+ ${className}State clearError() => ${className}State(
108
+ items: items,
109
+ selected: selected,
110
+ loading: loading,
111
+ loadingMore: loadingMore,
112
+ hasMore: hasMore,
113
+ page: page,
114
+ );
115
+ }
116
+ `,
117
+ };
118
+ const blocFile = {
119
+ path: `lib/generated/blocs/${fileName}_bloc.g.dart`,
120
+ category: 'generated',
121
+ content: `// GENERATED FILE — DO NOT EDIT MANUALLY
122
+ // Generated by Underpeaks CodeGen v1.0.0
123
+ // ignore_for_file: lines_longer_than_80_chars
124
+
125
+ import 'package:flutter_bloc/flutter_bloc.dart';
126
+ import '../models/${fileName}.g.dart';
127
+ import '../repositories/${fileName}_repository.g.dart';
128
+
129
+ part '${fileName}_event.g.dart';
130
+ part '${fileName}_state.g.dart';
131
+
132
+ class ${className}Bloc extends Bloc<${className}Event, ${className}State> {
133
+ final ${className}Repository _repository;
134
+
135
+ static const int _pageSize = 20;
136
+
137
+ ${className}Bloc(this._repository) : super(const ${className}State()) {
138
+ on<Load${className}sEvent>(_onLoad);
139
+ on<Refresh${className}sEvent>(_onRefresh);
140
+ on<LoadMore${className}sEvent>(_onLoadMore);
141
+ on<LoadOne${className}Event>(_onLoadOne);
142
+ on<Create${className}Event>(_onCreate);
143
+ on<Update${className}Event>(_onUpdate);
144
+ on<Delete${className}Event>(_onDelete);
145
+ }
146
+
147
+ Future<void> _onLoad(
148
+ Load${className}sEvent event,
149
+ Emitter<${className}State> emit,
150
+ ) async {
151
+ emit(state.copyWith(loading: true, page: 1, hasMore: true));
152
+ try {
153
+ final result = await _repository.findAll(
154
+ filters: event.filters,
155
+ page: 1,
156
+ limit: _pageSize,
157
+ );
158
+ emit(${className}State(
159
+ items: result.items,
160
+ hasMore: result.hasMore,
161
+ page: 1,
162
+ ));
163
+ } catch (e) {
164
+ emit(state.copyWith(loading: false, error: e.toString()));
165
+ }
166
+ }
167
+
168
+ Future<void> _onRefresh(
169
+ Refresh${className}sEvent event,
170
+ Emitter<${className}State> emit,
171
+ ) async {
172
+ emit(const ${className}State(loading: true));
173
+ try {
174
+ final result = await _repository.findAll(
175
+ filters: event.filters,
176
+ page: 1,
177
+ limit: _pageSize,
178
+ );
179
+ emit(${className}State(
180
+ items: result.items,
181
+ hasMore: result.hasMore,
182
+ page: 1,
183
+ ));
184
+ } catch (e) {
185
+ emit(state.copyWith(loading: false, error: e.toString()));
186
+ }
187
+ }
188
+
189
+ Future<void> _onLoadMore(
190
+ LoadMore${className}sEvent event,
191
+ Emitter<${className}State> emit,
192
+ ) async {
193
+ if (state.loadingMore || !state.hasMore) return;
194
+ emit(state.copyWith(loadingMore: true));
195
+ try {
196
+ final nextPage = state.page + 1;
197
+ final result = await _repository.findAll(
198
+ filters: event.filters,
199
+ page: nextPage,
200
+ limit: _pageSize,
201
+ );
202
+ emit(state.copyWith(
203
+ items: [...state.items, ...result.items],
204
+ hasMore: result.hasMore,
205
+ page: nextPage,
206
+ loadingMore: false,
207
+ ));
208
+ } catch (e) {
209
+ emit(state.copyWith(loadingMore: false, error: e.toString()));
210
+ }
211
+ }
212
+
213
+ Future<void> _onLoadOne(
214
+ LoadOne${className}Event event,
215
+ Emitter<${className}State> emit,
216
+ ) async {
217
+ emit(state.copyWith(loading: true));
218
+ try {
219
+ final item = await _repository.findById(event.${pkName});
220
+ emit(state.copyWith(loading: false, selected: item));
221
+ } catch (e) {
222
+ emit(state.copyWith(loading: false, error: e.toString()));
223
+ }
224
+ }
225
+
226
+ Future<void> _onCreate(
227
+ Create${className}Event event,
228
+ Emitter<${className}State> emit,
229
+ ) async {
230
+ emit(state.copyWith(loading: true));
231
+ try {
232
+ final created = await _repository.create(event.item);
233
+ emit(state.copyWith(
234
+ items: [created, ...state.items],
235
+ loading: false,
236
+ ));
237
+ } catch (e) {
238
+ emit(state.copyWith(loading: false, error: e.toString()));
239
+ }
240
+ }
241
+
242
+ Future<void> _onUpdate(
243
+ Update${className}Event event,
244
+ Emitter<${className}State> emit,
245
+ ) async {
246
+ emit(state.copyWith(loading: true));
247
+ try {
248
+ final updated = await _repository.update(event.${pkName}, event.item);
249
+ emit(state.copyWith(
250
+ items: state.items
251
+ .map((i) => i.${pkName} == event.${pkName} ? updated : i)
252
+ .toList(),
253
+ selected: updated,
254
+ loading: false,
255
+ ));
256
+ } catch (e) {
257
+ emit(state.copyWith(loading: false, error: e.toString()));
258
+ }
259
+ }
260
+
261
+ Future<void> _onDelete(
262
+ Delete${className}Event event,
263
+ Emitter<${className}State> emit,
264
+ ) async {
265
+ emit(state.copyWith(loading: true));
266
+ try {
267
+ await _repository.delete(event.${pkName});
268
+ emit(state.copyWith(
269
+ items: state.items
270
+ .where((i) => i.${pkName} != event.${pkName})
271
+ .toList(),
272
+ loading: false,
273
+ ));
274
+ } catch (e) {
275
+ emit(state.copyWith(loading: false, error: e.toString()));
276
+ }
277
+ }
278
+ }
279
+ `,
280
+ };
281
+ return [blocFile, eventFile, stateFile];
282
+ }
283
+ //# sourceMappingURL=bloc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bloc.js","sourceRoot":"","sources":["../../../src/adapters/bloc/bloc.ts"],"names":[],"mappings":";AAAA,gFAAgF;;AAKhF,8CAwRC;AA1RD,+DAA6F;AAE7F,SAAgB,iBAAiB,CAAC,KAAY;IAC5C,MAAM,SAAS,GAAG,IAAA,iCAAgB,EAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC9C,MAAM,QAAQ,GAAI,IAAA,gCAAe,EAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC7C,MAAM,EAAE,GAAU,IAAA,8BAAa,EAAC,KAAK,CAAC,CAAA;IACtC,MAAM,MAAM,GAAM,EAAE,EAAE,IAAI,IAAI,IAAI,CAAA;IAElC,MAAM,SAAS,GAAkB;QAC/B,IAAI,EAAM,uBAAuB,QAAQ,eAAe;QACxD,QAAQ,EAAE,WAAW;QACrB,OAAO,EAAE;;;;WAIF,QAAQ;;iBAEF,SAAS;;YAEd,SAAS,kBAAkB,SAAS;;QAExC,SAAS;;;eAGF,SAAS,kBAAkB,SAAS;;WAExC,SAAS;;;gBAGJ,SAAS,kBAAkB,SAAS;;YAExC,SAAS;;;eAGN,SAAS,iBAAiB,SAAS;iBACjC,MAAM;WACZ,SAAS,cAAc,MAAM;;;cAG1B,SAAS,iBAAiB,SAAS;UACvC,SAAS;UACT,SAAS;;;cAGL,SAAS,iBAAiB,SAAS;sBAC3B,MAAM;UAClB,SAAS;UACT,SAAS,cAAc,MAAM;;;cAGzB,SAAS,iBAAiB,SAAS;iBAChC,MAAM;UACb,SAAS,cAAc,MAAM;;CAEtC;KACE,CAAA;IAED,MAAM,SAAS,GAAkB;QAC/B,IAAI,EAAM,uBAAuB,QAAQ,eAAe;QACxD,QAAQ,EAAE,WAAW;QACrB,OAAO,EAAE;;;;WAIF,QAAQ;;QAEX,SAAS;eACF,SAAS;UACd,SAAS;;;;;;;UAOT,SAAS;;;;;;;;;;IAUf,SAAS;WACF,SAAS;MACd,SAAS;;;;;;;aAOF,SAAS;;;;;;;;;;;IAWlB,SAAS,yBAAyB,SAAS;;;;;;;;;CAS9C;KACE,CAAA;IAED,MAAM,QAAQ,GAAkB;QAC9B,IAAI,EAAM,uBAAuB,QAAQ,cAAc;QACvD,QAAQ,EAAE,WAAW;QACrB,OAAO,EAAE;;;;;oBAKO,QAAQ;0BACF,QAAQ;;QAE1B,QAAQ;QACR,QAAQ;;QAER,SAAS,qBAAqB,SAAS,UAAU,SAAS;UACxD,SAAS;;;;IAIf,SAAS,wCAAwC,SAAS;aACjD,SAAS;gBACN,SAAS;iBACR,SAAS;gBACV,SAAS;eACV,SAAS;eACT,SAAS;eACT,SAAS;;;;UAId,SAAS;cACL,SAAS;;;;;;;;;aASV,SAAS;;;;;;;;;;;aAWT,SAAS;cACR,SAAS;;iBAEN,SAAS;;;;;;;aAOb,SAAS;;;;;;;;;;;cAWR,SAAS;cACT,SAAS;;;;;;;;;;;;;;;;;;;;;;;aAuBV,SAAS;cACR,SAAS;;;;sDAI+B,MAAM;;;;;;;;YAQhD,SAAS;cACP,SAAS;;;;;;;;;;;;;;;YAeX,SAAS;cACP,SAAS;;;;uDAIgC,MAAM;;;4BAGjC,MAAM,aAAa,MAAM;;;;;;;;;;;YAWzC,SAAS;cACP,SAAS;;;;uCAIgB,MAAM;;;8BAGf,MAAM,aAAa,MAAM;;;;;;;;;CAStD;KACE,CAAA;IAED,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;AACzC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Model, GeneratedFile } from '@underpeaks/generator-core';
2
+ export declare function generateProviderNotifier(model: Model): GeneratedFile;
3
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/adapters/provider/provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAA6B,4BAA4B,CAAA;AAG7F,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAiLpE"}
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ // File: underpeaks_codegen/packages/generator-flutter/src/adapters/provider/provider.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.generateProviderNotifier = generateProviderNotifier;
5
+ const generator_core_1 = require("@underpeaks/generator-core");
6
+ function generateProviderNotifier(model) {
7
+ const className = (0, generator_core_1.modelToClassName)(model.name);
8
+ const fileName = (0, generator_core_1.modelToFileName)(model.name);
9
+ const pk = (0, generator_core_1.getPrimaryKey)(model);
10
+ const pkName = pk?.name ?? 'id';
11
+ const content = `// GENERATED FILE — DO NOT EDIT MANUALLY
12
+ // Generated by Underpeaks CodeGen v1.0.0
13
+ // ignore_for_file: lines_longer_than_80_chars
14
+
15
+ import 'package:flutter/foundation.dart';
16
+ import '../models/${fileName}.g.dart';
17
+ import '../repositories/${fileName}_repository.g.dart';
18
+
19
+ class ${className}Notifier extends ChangeNotifier {
20
+ final ${className}Repository _repository;
21
+
22
+ static const int _pageSize = 20;
23
+
24
+ ${className}Notifier(this._repository);
25
+
26
+ List<${className}> _items = [];
27
+ ${className}? _selected;
28
+ bool _loading = false;
29
+ bool _loadingMore = false;
30
+ bool _hasMore = true;
31
+ int _page = 1;
32
+ String? _error;
33
+
34
+ List<${className}> get items => _items;
35
+ ${className}? get selected => _selected;
36
+ bool get loading => _loading;
37
+ bool get loadingMore => _loadingMore;
38
+ bool get hasMore => _hasMore;
39
+ int get page => _page;
40
+ String? get error => _error;
41
+
42
+ Future<void> loadAll({Map<String, String>? filters}) async {
43
+ _loading = true;
44
+ _page = 1;
45
+ _hasMore = true;
46
+ _error = null;
47
+ notifyListeners();
48
+ try {
49
+ final result = await _repository.findAll(
50
+ filters: filters,
51
+ page: 1,
52
+ limit: _pageSize,
53
+ );
54
+ _items = result.items;
55
+ _hasMore = result.hasMore;
56
+ _page = 1;
57
+ } catch (e) {
58
+ _error = e.toString();
59
+ } finally {
60
+ _loading = false;
61
+ notifyListeners();
62
+ }
63
+ }
64
+
65
+ Future<void> refresh({Map<String, String>? filters}) async {
66
+ _loading = true;
67
+ _items = [];
68
+ _page = 1;
69
+ _hasMore = true;
70
+ _error = null;
71
+ notifyListeners();
72
+ try {
73
+ final result = await _repository.findAll(
74
+ filters: filters,
75
+ page: 1,
76
+ limit: _pageSize,
77
+ );
78
+ _items = result.items;
79
+ _hasMore = result.hasMore;
80
+ } catch (e) {
81
+ _error = e.toString();
82
+ } finally {
83
+ _loading = false;
84
+ notifyListeners();
85
+ }
86
+ }
87
+
88
+ Future<void> loadMore({Map<String, String>? filters}) async {
89
+ if (_loadingMore || !_hasMore) return;
90
+ _loadingMore = true;
91
+ notifyListeners();
92
+ try {
93
+ final nextPage = _page + 1;
94
+ final result = await _repository.findAll(
95
+ filters: filters,
96
+ page: nextPage,
97
+ limit: _pageSize,
98
+ );
99
+ _items = [..._items, ...result.items];
100
+ _hasMore = result.hasMore;
101
+ _page = nextPage;
102
+ } catch (e) {
103
+ _error = e.toString();
104
+ } finally {
105
+ _loadingMore = false;
106
+ notifyListeners();
107
+ }
108
+ }
109
+
110
+ Future<void> loadOne(String ${pkName}) async {
111
+ _loading = true;
112
+ _error = null;
113
+ notifyListeners();
114
+ try {
115
+ _selected = await _repository.findById(${pkName});
116
+ } catch (e) {
117
+ _error = e.toString();
118
+ } finally {
119
+ _loading = false;
120
+ notifyListeners();
121
+ }
122
+ }
123
+
124
+ Future<void> create(${className} item) async {
125
+ _loading = true;
126
+ _error = null;
127
+ notifyListeners();
128
+ try {
129
+ final created = await _repository.create(item);
130
+ _items = [created, ..._items];
131
+ } catch (e) {
132
+ _error = e.toString();
133
+ } finally {
134
+ _loading = false;
135
+ notifyListeners();
136
+ }
137
+ }
138
+
139
+ Future<void> update(String ${pkName}, ${className} item) async {
140
+ _loading = true;
141
+ _error = null;
142
+ notifyListeners();
143
+ try {
144
+ final updated = await _repository.update(${pkName}, item);
145
+ _items = _items.map((i) => i.${pkName} == ${pkName} ? updated : i).toList();
146
+ _selected = updated;
147
+ } catch (e) {
148
+ _error = e.toString();
149
+ } finally {
150
+ _loading = false;
151
+ notifyListeners();
152
+ }
153
+ }
154
+
155
+ Future<void> delete(String ${pkName}) async {
156
+ _loading = true;
157
+ _error = null;
158
+ notifyListeners();
159
+ try {
160
+ await _repository.delete(${pkName});
161
+ _items = _items.where((i) => i.${pkName} != ${pkName}).toList();
162
+ } catch (e) {
163
+ _error = e.toString();
164
+ } finally {
165
+ _loading = false;
166
+ notifyListeners();
167
+ }
168
+ }
169
+
170
+ void clearError() {
171
+ _error = null;
172
+ notifyListeners();
173
+ }
174
+ }
175
+ `;
176
+ return {
177
+ path: `lib/generated/notifiers/${fileName}_notifier.g.dart`,
178
+ content,
179
+ category: 'generated',
180
+ };
181
+ }
182
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/adapters/provider/provider.ts"],"names":[],"mappings":";AAAA,wFAAwF;;AAKxF,4DAiLC;AAnLD,+DAA6F;AAE7F,SAAgB,wBAAwB,CAAC,KAAY;IACnD,MAAM,SAAS,GAAG,IAAA,iCAAgB,EAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC9C,MAAM,QAAQ,GAAI,IAAA,gCAAe,EAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC7C,MAAM,EAAE,GAAU,IAAA,8BAAa,EAAC,KAAK,CAAC,CAAA;IACtC,MAAM,MAAM,GAAM,EAAE,EAAE,IAAI,IAAI,IAAI,CAAA;IAElC,MAAM,OAAO,GAAG;;;;;oBAKE,QAAQ;0BACF,QAAQ;;QAE1B,SAAS;UACP,SAAS;;;;IAIf,SAAS;;SAEJ,SAAS;IACd,SAAS;;;;;;;SAOJ,SAAS;IACd,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA2EmB,MAAM;;;;;+CAKS,MAAM;;;;;;;;;wBAS7B,SAAS;;;;;;;;;;;;;;;+BAeF,MAAM,KAAK,SAAS;;;;;iDAKF,MAAM;wCACf,MAAM,OAAO,MAAM;;;;;;;;;;+BAU5B,MAAM;;;;;iCAKJ,MAAM;uCACA,MAAM,OAAO,MAAM;;;;;;;;;;;;;;CAczD,CAAA;IAEC,OAAO;QACL,IAAI,EAAM,2BAA2B,QAAQ,kBAAkB;QAC/D,OAAO;QACP,QAAQ,EAAE,WAAW;KACtB,CAAA;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Model, GeneratedFile } from '@underpeaks/generator-core';
2
+ export declare function generateRiverpodProvider(model: Model): GeneratedFile;
3
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/adapters/riverpod/provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAGtE,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAiOpE"}