@slicemachine/adapter-next 0.3.10 → 0.3.11-dev-next-release.2

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 (209) hide show
  1. package/dist/hooks/documentation-read.cjs +7 -6
  2. package/dist/hooks/documentation-read.cjs.map +1 -1
  3. package/dist/hooks/documentation-read.js +7 -6
  4. package/dist/hooks/documentation-read.js.map +1 -1
  5. package/dist/hooks/project-init.cjs +51 -58
  6. package/dist/hooks/project-init.cjs.map +1 -1
  7. package/dist/hooks/project-init.js +51 -57
  8. package/dist/hooks/project-init.js.map +1 -1
  9. package/dist/hooks/slice-create.cjs +29 -44
  10. package/dist/hooks/slice-create.cjs.map +1 -1
  11. package/dist/hooks/slice-create.js +29 -26
  12. package/dist/hooks/slice-create.js.map +1 -1
  13. package/dist/lib/checkHasAppRouter.cjs +23 -2
  14. package/dist/lib/checkHasAppRouter.cjs.map +1 -1
  15. package/dist/lib/checkHasAppRouter.js +6 -2
  16. package/dist/lib/checkHasAppRouter.js.map +1 -1
  17. package/dist/lib/checkHasSrcDirectory.cjs +5 -2
  18. package/dist/lib/checkHasSrcDirectory.cjs.map +1 -1
  19. package/dist/lib/checkHasSrcDirectory.js +5 -2
  20. package/dist/lib/checkHasSrcDirectory.js.map +1 -1
  21. package/dist/lib/checkIsTypeScriptProject.cjs +2 -3
  22. package/dist/lib/checkIsTypeScriptProject.cjs.map +1 -1
  23. package/dist/lib/checkIsTypeScriptProject.js +2 -3
  24. package/dist/lib/checkIsTypeScriptProject.js.map +1 -1
  25. package/dist/lib/upsertSliceLibraryIndexFile.cjs +29 -21
  26. package/dist/lib/upsertSliceLibraryIndexFile.cjs.map +1 -1
  27. package/dist/lib/upsertSliceLibraryIndexFile.js +29 -20
  28. package/dist/lib/upsertSliceLibraryIndexFile.js.map +1 -1
  29. package/dist/plugin.cjs +178 -36
  30. package/dist/plugin.cjs.map +1 -1
  31. package/dist/plugin.js +178 -36
  32. package/dist/plugin.js.map +1 -1
  33. package/package.json +5 -7
  34. package/src/hooks/documentation-read.ts +9 -7
  35. package/src/hooks/project-init.ts +58 -69
  36. package/src/hooks/slice-create.ts +39 -31
  37. package/src/lib/checkHasAppRouter.ts +6 -6
  38. package/src/lib/checkHasSrcDirectory.ts +5 -2
  39. package/src/lib/checkIsTypeScriptProject.ts +5 -4
  40. package/src/lib/upsertSliceLibraryIndexFile.ts +53 -33
  41. package/src/plugin.ts +245 -37
  42. package/dist/hooks/customType-asset-delete.cjs +0 -31
  43. package/dist/hooks/customType-asset-delete.cjs.map +0 -1
  44. package/dist/hooks/customType-asset-delete.d.ts +0 -3
  45. package/dist/hooks/customType-asset-delete.js +0 -14
  46. package/dist/hooks/customType-asset-delete.js.map +0 -1
  47. package/dist/hooks/customType-asset-read.cjs +0 -34
  48. package/dist/hooks/customType-asset-read.cjs.map +0 -1
  49. package/dist/hooks/customType-asset-read.d.ts +0 -3
  50. package/dist/hooks/customType-asset-read.js +0 -17
  51. package/dist/hooks/customType-asset-read.js.map +0 -1
  52. package/dist/hooks/customType-asset-update.cjs +0 -34
  53. package/dist/hooks/customType-asset-update.cjs.map +0 -1
  54. package/dist/hooks/customType-asset-update.d.ts +0 -3
  55. package/dist/hooks/customType-asset-update.js +0 -16
  56. package/dist/hooks/customType-asset-update.js.map +0 -1
  57. package/dist/hooks/customType-create.cjs +0 -43
  58. package/dist/hooks/customType-create.cjs.map +0 -1
  59. package/dist/hooks/customType-create.d.ts +0 -3
  60. package/dist/hooks/customType-create.js +0 -25
  61. package/dist/hooks/customType-create.js.map +0 -1
  62. package/dist/hooks/customType-delete.cjs +0 -32
  63. package/dist/hooks/customType-delete.cjs.map +0 -1
  64. package/dist/hooks/customType-delete.d.ts +0 -3
  65. package/dist/hooks/customType-delete.js +0 -15
  66. package/dist/hooks/customType-delete.js.map +0 -1
  67. package/dist/hooks/customType-read.cjs +0 -31
  68. package/dist/hooks/customType-read.cjs.map +0 -1
  69. package/dist/hooks/customType-read.d.ts +0 -3
  70. package/dist/hooks/customType-read.js +0 -14
  71. package/dist/hooks/customType-read.js.map +0 -1
  72. package/dist/hooks/customType-rename.cjs +0 -6
  73. package/dist/hooks/customType-rename.cjs.map +0 -1
  74. package/dist/hooks/customType-rename.d.ts +0 -1
  75. package/dist/hooks/customType-rename.js +0 -6
  76. package/dist/hooks/customType-rename.js.map +0 -1
  77. package/dist/hooks/customType-update.cjs +0 -6
  78. package/dist/hooks/customType-update.cjs.map +0 -1
  79. package/dist/hooks/customType-update.d.ts +0 -1
  80. package/dist/hooks/customType-update.js +0 -6
  81. package/dist/hooks/customType-update.js.map +0 -1
  82. package/dist/hooks/customTypeLibrary-read.cjs +0 -55
  83. package/dist/hooks/customTypeLibrary-read.cjs.map +0 -1
  84. package/dist/hooks/customTypeLibrary-read.d.ts +0 -3
  85. package/dist/hooks/customTypeLibrary-read.js +0 -37
  86. package/dist/hooks/customTypeLibrary-read.js.map +0 -1
  87. package/dist/hooks/slice-asset-delete.cjs +0 -33
  88. package/dist/hooks/slice-asset-delete.cjs.map +0 -1
  89. package/dist/hooks/slice-asset-delete.d.ts +0 -3
  90. package/dist/hooks/slice-asset-delete.js +0 -16
  91. package/dist/hooks/slice-asset-delete.js.map +0 -1
  92. package/dist/hooks/slice-asset-read.cjs +0 -36
  93. package/dist/hooks/slice-asset-read.cjs.map +0 -1
  94. package/dist/hooks/slice-asset-read.d.ts +0 -3
  95. package/dist/hooks/slice-asset-read.js +0 -19
  96. package/dist/hooks/slice-asset-read.js.map +0 -1
  97. package/dist/hooks/slice-asset-update.cjs +0 -36
  98. package/dist/hooks/slice-asset-update.cjs.map +0 -1
  99. package/dist/hooks/slice-asset-update.d.ts +0 -3
  100. package/dist/hooks/slice-asset-update.js +0 -18
  101. package/dist/hooks/slice-asset-update.js.map +0 -1
  102. package/dist/hooks/slice-delete.cjs +0 -41
  103. package/dist/hooks/slice-delete.cjs.map +0 -1
  104. package/dist/hooks/slice-delete.d.ts +0 -3
  105. package/dist/hooks/slice-delete.js +0 -24
  106. package/dist/hooks/slice-delete.js.map +0 -1
  107. package/dist/hooks/slice-read.cjs +0 -62
  108. package/dist/hooks/slice-read.cjs.map +0 -1
  109. package/dist/hooks/slice-read.d.ts +0 -3
  110. package/dist/hooks/slice-read.js +0 -44
  111. package/dist/hooks/slice-read.js.map +0 -1
  112. package/dist/hooks/slice-rename.cjs +0 -51
  113. package/dist/hooks/slice-rename.cjs.map +0 -1
  114. package/dist/hooks/slice-rename.d.ts +0 -3
  115. package/dist/hooks/slice-rename.js +0 -34
  116. package/dist/hooks/slice-rename.js.map +0 -1
  117. package/dist/hooks/slice-update.cjs +0 -14
  118. package/dist/hooks/slice-update.cjs.map +0 -1
  119. package/dist/hooks/slice-update.d.ts +0 -3
  120. package/dist/hooks/slice-update.js +0 -14
  121. package/dist/hooks/slice-update.js.map +0 -1
  122. package/dist/hooks/sliceLibrary-read.cjs +0 -52
  123. package/dist/hooks/sliceLibrary-read.cjs.map +0 -1
  124. package/dist/hooks/sliceLibrary-read.d.ts +0 -3
  125. package/dist/hooks/sliceLibrary-read.js +0 -34
  126. package/dist/hooks/sliceLibrary-read.js.map +0 -1
  127. package/dist/lib/buildCustomTypeAssetPath.cjs +0 -29
  128. package/dist/lib/buildCustomTypeAssetPath.cjs.map +0 -1
  129. package/dist/lib/buildCustomTypeAssetPath.d.ts +0 -9
  130. package/dist/lib/buildCustomTypeAssetPath.js +0 -12
  131. package/dist/lib/buildCustomTypeAssetPath.js.map +0 -1
  132. package/dist/lib/buildCustomTypeDirectoryPath.cjs +0 -26
  133. package/dist/lib/buildCustomTypeDirectoryPath.cjs.map +0 -1
  134. package/dist/lib/buildCustomTypeDirectoryPath.d.ts +0 -8
  135. package/dist/lib/buildCustomTypeDirectoryPath.js +0 -9
  136. package/dist/lib/buildCustomTypeDirectoryPath.js.map +0 -1
  137. package/dist/lib/buildCustomTypeLibraryDirectoryPath.cjs +0 -7
  138. package/dist/lib/buildCustomTypeLibraryDirectoryPath.cjs.map +0 -1
  139. package/dist/lib/buildCustomTypeLibraryDirectoryPath.d.ts +0 -7
  140. package/dist/lib/buildCustomTypeLibraryDirectoryPath.js +0 -7
  141. package/dist/lib/buildCustomTypeLibraryDirectoryPath.js.map +0 -1
  142. package/dist/lib/buildSliceAssetPath.cjs +0 -34
  143. package/dist/lib/buildSliceAssetPath.cjs.map +0 -1
  144. package/dist/lib/buildSliceAssetPath.d.ts +0 -11
  145. package/dist/lib/buildSliceAssetPath.js +0 -17
  146. package/dist/lib/buildSliceAssetPath.js.map +0 -1
  147. package/dist/lib/buildSliceDirectoryPath.cjs +0 -30
  148. package/dist/lib/buildSliceDirectoryPath.cjs.map +0 -1
  149. package/dist/lib/buildSliceDirectoryPath.d.ts +0 -10
  150. package/dist/lib/buildSliceDirectoryPath.js +0 -13
  151. package/dist/lib/buildSliceDirectoryPath.js.map +0 -1
  152. package/dist/lib/buildSliceLibraryDirectoryPath.cjs +0 -7
  153. package/dist/lib/buildSliceLibraryDirectoryPath.cjs.map +0 -1
  154. package/dist/lib/buildSliceLibraryDirectoryPath.d.ts +0 -8
  155. package/dist/lib/buildSliceLibraryDirectoryPath.js +0 -7
  156. package/dist/lib/buildSliceLibraryDirectoryPath.js.map +0 -1
  157. package/dist/lib/checkPathExists.cjs +0 -30
  158. package/dist/lib/checkPathExists.cjs.map +0 -1
  159. package/dist/lib/checkPathExists.d.ts +0 -2
  160. package/dist/lib/checkPathExists.js +0 -13
  161. package/dist/lib/checkPathExists.js.map +0 -1
  162. package/dist/lib/isSharedSliceModel.cjs +0 -7
  163. package/dist/lib/isSharedSliceModel.cjs.map +0 -1
  164. package/dist/lib/isSharedSliceModel.d.ts +0 -335
  165. package/dist/lib/isSharedSliceModel.js +0 -7
  166. package/dist/lib/isSharedSliceModel.js.map +0 -1
  167. package/dist/lib/readJSONFile.cjs +0 -26
  168. package/dist/lib/readJSONFile.cjs.map +0 -1
  169. package/dist/lib/readJSONFile.d.ts +0 -1
  170. package/dist/lib/readJSONFile.js +0 -9
  171. package/dist/lib/readJSONFile.js.map +0 -1
  172. package/dist/lib/updateSliceModelFile.cjs +0 -33
  173. package/dist/lib/updateSliceModelFile.cjs.map +0 -1
  174. package/dist/lib/updateSliceModelFile.d.ts +0 -9
  175. package/dist/lib/updateSliceModelFile.js +0 -15
  176. package/dist/lib/updateSliceModelFile.js.map +0 -1
  177. package/dist/lib/upsertGlobalContentTypes.cjs +0 -56
  178. package/dist/lib/upsertGlobalContentTypes.cjs.map +0 -1
  179. package/dist/lib/upsertGlobalContentTypes.d.ts +0 -12
  180. package/dist/lib/upsertGlobalContentTypes.js +0 -38
  181. package/dist/lib/upsertGlobalContentTypes.js.map +0 -1
  182. package/src/hooks/customType-asset-delete.ts +0 -18
  183. package/src/hooks/customType-asset-read.ts +0 -22
  184. package/src/hooks/customType-asset-update.ts +0 -20
  185. package/src/hooks/customType-create.ts +0 -45
  186. package/src/hooks/customType-delete.ts +0 -21
  187. package/src/hooks/customType-read.ts +0 -24
  188. package/src/hooks/customType-rename.ts +0 -3
  189. package/src/hooks/customType-update.ts +0 -3
  190. package/src/hooks/customTypeLibrary-read.ts +0 -58
  191. package/src/hooks/slice-asset-delete.ts +0 -21
  192. package/src/hooks/slice-asset-read.ts +0 -25
  193. package/src/hooks/slice-asset-update.ts +0 -23
  194. package/src/hooks/slice-delete.ts +0 -41
  195. package/src/hooks/slice-read.ts +0 -69
  196. package/src/hooks/slice-rename.ts +0 -46
  197. package/src/hooks/slice-update.ts +0 -19
  198. package/src/hooks/sliceLibrary-read.ts +0 -48
  199. package/src/lib/buildCustomTypeAssetPath.ts +0 -24
  200. package/src/lib/buildCustomTypeDirectoryPath.ts +0 -20
  201. package/src/lib/buildCustomTypeLibraryDirectoryPath.ts +0 -13
  202. package/src/lib/buildSliceAssetPath.ts +0 -32
  203. package/src/lib/buildSliceDirectoryPath.ts +0 -26
  204. package/src/lib/buildSliceLibraryDirectoryPath.ts +0 -14
  205. package/src/lib/checkPathExists.ts +0 -12
  206. package/src/lib/isSharedSliceModel.ts +0 -14
  207. package/src/lib/readJSONFile.ts +0 -7
  208. package/src/lib/updateSliceModelFile.ts +0 -33
  209. package/src/lib/upsertGlobalContentTypes.ts +0 -63
package/src/plugin.ts CHANGED
@@ -1,30 +1,35 @@
1
1
  import { defineSliceMachinePlugin } from "@slicemachine/plugin-kit";
2
+ import {
3
+ deleteCustomTypeDirectory,
4
+ deleteCustomTypeFile,
5
+ deleteSliceDirectory,
6
+ deleteSliceFile,
7
+ readCustomTypeFile,
8
+ readCustomTypeLibrary,
9
+ readCustomTypeModel,
10
+ readSliceFile,
11
+ readSliceLibrary,
12
+ readSliceModel,
13
+ renameCustomType,
14
+ renameSlice,
15
+ upsertGlobalTypeScriptTypes,
16
+ writeCustomTypeFile,
17
+ writeCustomTypeModel,
18
+ writeSliceFile,
19
+ writeSliceModel,
20
+ } from "@slicemachine/plugin-kit/fs";
21
+
22
+ import { rejectIfNecessary } from "./lib/rejectIfNecessary";
23
+ import { upsertSliceLibraryIndexFile } from "./lib/upsertSliceLibraryIndexFile";
2
24
 
3
25
  import { name as pkgName } from "../package.json";
4
26
  import { PluginOptions } from "./types";
5
27
 
28
+ import { documentationRead } from "./hooks/documentation-read";
6
29
  import { projectInit } from "./hooks/project-init";
7
- import { customTypeAssetDelete } from "./hooks/customType-asset-delete";
8
- import { customTypeAssetRead } from "./hooks/customType-asset-read";
9
- import { customTypeAssetUpdate } from "./hooks/customType-asset-update";
10
- import { customTypeCreate } from "./hooks/customType-create";
11
- import { customTypeDelete } from "./hooks/customType-delete";
12
- import { customTypeLibraryRead } from "./hooks/customTypeLibrary-read";
13
- import { customTypeRead } from "./hooks/customType-read";
14
- import { customTypeRename } from "./hooks/customType-rename";
15
- import { customTypeUpdate } from "./hooks/customType-update";
16
- import { sliceAssetDelete } from "./hooks/slice-asset-delete";
17
- import { sliceAssetRead } from "./hooks/slice-asset-read";
18
- import { sliceAssetUpdate } from "./hooks/slice-asset-update";
19
30
  import { sliceCreate } from "./hooks/slice-create";
20
- import { sliceDelete } from "./hooks/slice-delete";
21
- import { sliceLibraryRead } from "./hooks/sliceLibrary-read";
22
- import { sliceRead } from "./hooks/slice-read";
23
- import { sliceRename } from "./hooks/slice-rename";
24
- import { sliceUpdate } from "./hooks/slice-update";
25
- import { snippetRead } from "./hooks/snippet-read";
26
- import { documentationRead } from "./hooks/documentation-read";
27
31
  import { sliceSimulatorSetupRead } from "./hooks/sliceSimulator-setup-read";
32
+ import { snippetRead } from "./hooks/snippet-read";
28
33
 
29
34
  export const plugin = defineSliceMachinePlugin<PluginOptions>({
30
35
  meta: {
@@ -35,32 +40,235 @@ export const plugin = defineSliceMachinePlugin<PluginOptions>({
35
40
  lazyLoadSlices: true,
36
41
  },
37
42
  setup({ hook }) {
43
+ ////////////////////////////////////////////////////////////////
44
+ // project:*
45
+ ////////////////////////////////////////////////////////////////
46
+
38
47
  hook("project:init", projectInit);
39
48
 
49
+ ////////////////////////////////////////////////////////////////
50
+ // slice:*
51
+ ////////////////////////////////////////////////////////////////
52
+
40
53
  hook("slice:create", sliceCreate);
41
- hook("slice:update", sliceUpdate);
42
- hook("slice:rename", sliceRename);
43
- hook("slice:delete", sliceDelete);
44
- hook("slice:read", sliceRead);
45
- hook("slice:asset:update", sliceAssetUpdate);
46
- hook("slice:asset:delete", sliceAssetDelete);
47
- hook("slice:asset:read", sliceAssetRead);
48
- hook("slice-library:read", sliceLibraryRead);
49
-
50
- hook("custom-type:create", customTypeCreate);
51
- hook("custom-type:update", customTypeUpdate);
52
- hook("custom-type:rename", customTypeRename);
53
- hook("custom-type:delete", customTypeDelete);
54
- hook("custom-type:read", customTypeRead);
55
- hook("custom-type:asset:update", customTypeAssetUpdate);
56
- hook("custom-type:asset:delete", customTypeAssetDelete);
57
- hook("custom-type:asset:read", customTypeAssetRead);
58
- hook("custom-type-library:read", customTypeLibraryRead);
54
+ hook("slice:update", async (data, context) => {
55
+ await writeSliceModel({
56
+ libraryID: data.libraryID,
57
+ model: data.model,
58
+ ...context,
59
+ });
60
+
61
+ await upsertGlobalTypeScriptTypes({
62
+ filename: context.options.generatedTypesFilePath,
63
+ format: context.options.format,
64
+ ...context,
65
+ });
66
+ });
67
+ hook("slice:rename", async (data, context) => {
68
+ await renameSlice({
69
+ libraryID: data.libraryID,
70
+ model: data.model,
71
+ format: context.options.format,
72
+ ...context,
73
+ });
74
+
75
+ rejectIfNecessary(
76
+ await Promise.allSettled([
77
+ upsertSliceLibraryIndexFile({
78
+ libraryID: data.libraryID,
79
+ ...context,
80
+ }),
81
+ upsertGlobalTypeScriptTypes({
82
+ filename: context.options.generatedTypesFilePath,
83
+ format: context.options.format,
84
+ ...context,
85
+ }),
86
+ ]),
87
+ );
88
+ });
89
+ hook("slice:delete", async (data, context) => {
90
+ await deleteSliceDirectory({
91
+ libraryID: data.libraryID,
92
+ model: data.model,
93
+ ...context,
94
+ });
95
+
96
+ rejectIfNecessary(
97
+ await Promise.allSettled([
98
+ upsertSliceLibraryIndexFile({
99
+ libraryID: data.libraryID,
100
+ ...context,
101
+ }),
102
+ upsertGlobalTypeScriptTypes({
103
+ filename: context.options.generatedTypesFilePath,
104
+ format: context.options.format,
105
+ ...context,
106
+ }),
107
+ ]),
108
+ );
109
+ });
110
+ hook("slice:read", async (data, context) => {
111
+ return await readSliceModel({
112
+ libraryID: data.libraryID,
113
+ sliceID: data.sliceID,
114
+ ...context,
115
+ });
116
+ });
117
+ hook("slice:asset:update", async (data, context) => {
118
+ await writeSliceFile({
119
+ libraryID: data.libraryID,
120
+ sliceID: data.sliceID,
121
+ filename: data.asset.id,
122
+ contents: data.asset.data,
123
+ ...context,
124
+ });
125
+ });
126
+ hook("slice:asset:delete", async (data, context) => {
127
+ await deleteSliceFile({
128
+ libraryID: data.libraryID,
129
+ sliceID: data.sliceID,
130
+ filename: data.assetID,
131
+ ...context,
132
+ });
133
+ });
134
+ hook("slice:asset:read", async (data, context) => {
135
+ const file = await readSliceFile({
136
+ libraryID: data.libraryID,
137
+ sliceID: data.sliceID,
138
+ filename: data.assetID,
139
+ ...context,
140
+ });
141
+
142
+ return {
143
+ data: file,
144
+ };
145
+ });
146
+
147
+ ////////////////////////////////////////////////////////////////
148
+ // slice-library:*
149
+ ////////////////////////////////////////////////////////////////
150
+
151
+ hook("slice-library:read", async (data, context) => {
152
+ return await readSliceLibrary({
153
+ libraryID: data.libraryID,
154
+ ...context,
155
+ });
156
+ });
157
+
158
+ ////////////////////////////////////////////////////////////////
159
+ // custom-type:*
160
+ ////////////////////////////////////////////////////////////////
161
+
162
+ hook("custom-type:create", async (data, context) => {
163
+ await writeCustomTypeModel({
164
+ model: data.model,
165
+ format: context.options.format,
166
+ ...context,
167
+ });
168
+
169
+ await upsertGlobalTypeScriptTypes({
170
+ filename: context.options.generatedTypesFilePath,
171
+ format: context.options.format,
172
+ ...context,
173
+ });
174
+ });
175
+ hook("custom-type:update", async (data, context) => {
176
+ await writeCustomTypeModel({
177
+ model: data.model,
178
+ format: context.options.format,
179
+ ...context,
180
+ });
181
+
182
+ await upsertGlobalTypeScriptTypes({
183
+ filename: context.options.generatedTypesFilePath,
184
+ format: context.options.format,
185
+ ...context,
186
+ });
187
+ });
188
+ hook("custom-type:rename", async (data, context) => {
189
+ await renameCustomType({
190
+ model: data.model,
191
+ format: context.options.format,
192
+ ...context,
193
+ });
194
+
195
+ await upsertGlobalTypeScriptTypes({
196
+ filename: context.options.generatedTypesFilePath,
197
+ format: context.options.format,
198
+ ...context,
199
+ });
200
+ });
201
+ hook("custom-type:delete", async (data, context) => {
202
+ await deleteCustomTypeDirectory({
203
+ customTypeID: data.model.id,
204
+ ...context,
205
+ });
206
+
207
+ await upsertGlobalTypeScriptTypes({
208
+ filename: context.options.generatedTypesFilePath,
209
+ format: context.options.format,
210
+ ...context,
211
+ });
212
+ });
213
+ hook("custom-type:read", async (data, context) => {
214
+ return await readCustomTypeModel({
215
+ customTypeID: data.id,
216
+ ...context,
217
+ });
218
+ });
219
+ hook("custom-type:asset:update", async (data, context) => {
220
+ await writeCustomTypeFile({
221
+ customTypeID: data.customTypeID,
222
+ filename: data.asset.id,
223
+ contents: data.asset.data,
224
+ ...context,
225
+ });
226
+ });
227
+ hook("custom-type:asset:delete", async (data, context) => {
228
+ await deleteCustomTypeFile({
229
+ customTypeID: data.customTypeID,
230
+ filename: data.assetID,
231
+ ...context,
232
+ });
233
+ });
234
+ hook("custom-type:asset:read", async (data, context) => {
235
+ const file = await readCustomTypeFile({
236
+ customTypeID: data.customTypeID,
237
+ filename: data.assetID,
238
+ ...context,
239
+ });
240
+
241
+ return {
242
+ data: file,
243
+ };
244
+ });
245
+
246
+ ////////////////////////////////////////////////////////////////
247
+ // custom-type-library:*
248
+ ////////////////////////////////////////////////////////////////
249
+
250
+ hook("custom-type-library:read", async (_data, context) => {
251
+ return await readCustomTypeLibrary({
252
+ helpers: context.helpers,
253
+ });
254
+ });
255
+
256
+ ////////////////////////////////////////////////////////////////
257
+ // snippet:*
258
+ ////////////////////////////////////////////////////////////////
59
259
 
60
260
  hook("snippet:read", snippetRead);
61
261
 
262
+ ////////////////////////////////////////////////////////////////
263
+ // documentation:*
264
+ ////////////////////////////////////////////////////////////////
265
+
62
266
  hook("documentation:read", documentationRead);
63
267
 
268
+ ////////////////////////////////////////////////////////////////
269
+ // slice-simulator:*
270
+ ////////////////////////////////////////////////////////////////
271
+
64
272
  hook("slice-simulator:setup:read", sliceSimulatorSetupRead);
65
273
  },
66
274
  });
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const fs = require("node:fs/promises");
4
- const buildCustomTypeAssetPath = require("../lib/buildCustomTypeAssetPath.cjs");
5
- function _interopNamespaceDefault(e) {
6
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
7
- if (e) {
8
- for (const k in e) {
9
- if (k !== "default") {
10
- const d = Object.getOwnPropertyDescriptor(e, k);
11
- Object.defineProperty(n, k, d.get ? d : {
12
- enumerable: true,
13
- get: () => e[k]
14
- });
15
- }
16
- }
17
- }
18
- n.default = e;
19
- return Object.freeze(n);
20
- }
21
- const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
22
- const customTypeAssetDelete = async (data, context) => {
23
- const filePath = buildCustomTypeAssetPath.buildCustomTypeAssetPath({
24
- customTypeID: data.customTypeID,
25
- assetID: data.assetID,
26
- helpers: context.helpers
27
- });
28
- await fs__namespace.rm(filePath);
29
- };
30
- exports.customTypeAssetDelete = customTypeAssetDelete;
31
- //# sourceMappingURL=customType-asset-delete.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customType-asset-delete.cjs","sources":["../../../src/hooks/customType-asset-delete.ts"],"sourcesContent":["import type { CustomTypeAssetDeleteHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildCustomTypeAssetPath } from \"../lib/buildCustomTypeAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeAssetDelete: CustomTypeAssetDeleteHook<\n\tPluginOptions\n> = async (data, context) => {\n\tconst filePath = buildCustomTypeAssetPath({\n\t\tcustomTypeID: data.customTypeID,\n\t\tassetID: data.assetID,\n\t\thelpers: context.helpers,\n\t});\n\n\tawait fs.rm(filePath);\n};\n"],"names":["buildCustomTypeAssetPath","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOa,MAAA,wBAET,OAAO,MAAM,YAAW;AAC3B,QAAM,WAAWA,yBAAAA,yBAAyB;AAAA,IACzC,cAAc,KAAK;AAAA,IACnB,SAAS,KAAK;AAAA,IACd,SAAS,QAAQ;AAAA,EAAA,CACjB;AAEK,QAAAC,cAAG,GAAG,QAAQ;AACrB;;"}
@@ -1,3 +0,0 @@
1
- import type { CustomTypeAssetDeleteHook } from "@slicemachine/plugin-kit";
2
- import type { PluginOptions } from "../types";
3
- export declare const customTypeAssetDelete: CustomTypeAssetDeleteHook<PluginOptions>;
@@ -1,14 +0,0 @@
1
- import * as fs from "node:fs/promises";
2
- import { buildCustomTypeAssetPath } from "../lib/buildCustomTypeAssetPath.js";
3
- const customTypeAssetDelete = async (data, context) => {
4
- const filePath = buildCustomTypeAssetPath({
5
- customTypeID: data.customTypeID,
6
- assetID: data.assetID,
7
- helpers: context.helpers
8
- });
9
- await fs.rm(filePath);
10
- };
11
- export {
12
- customTypeAssetDelete
13
- };
14
- //# sourceMappingURL=customType-asset-delete.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customType-asset-delete.js","sources":["../../../src/hooks/customType-asset-delete.ts"],"sourcesContent":["import type { CustomTypeAssetDeleteHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildCustomTypeAssetPath } from \"../lib/buildCustomTypeAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeAssetDelete: CustomTypeAssetDeleteHook<\n\tPluginOptions\n> = async (data, context) => {\n\tconst filePath = buildCustomTypeAssetPath({\n\t\tcustomTypeID: data.customTypeID,\n\t\tassetID: data.assetID,\n\t\thelpers: context.helpers,\n\t});\n\n\tawait fs.rm(filePath);\n};\n"],"names":[],"mappings":";;AAOa,MAAA,wBAET,OAAO,MAAM,YAAW;AAC3B,QAAM,WAAW,yBAAyB;AAAA,IACzC,cAAc,KAAK;AAAA,IACnB,SAAS,KAAK;AAAA,IACd,SAAS,QAAQ;AAAA,EAAA,CACjB;AAEK,QAAA,GAAG,GAAG,QAAQ;AACrB;"}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const fs = require("node:fs/promises");
4
- const buildCustomTypeAssetPath = require("../lib/buildCustomTypeAssetPath.cjs");
5
- function _interopNamespaceDefault(e) {
6
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
7
- if (e) {
8
- for (const k in e) {
9
- if (k !== "default") {
10
- const d = Object.getOwnPropertyDescriptor(e, k);
11
- Object.defineProperty(n, k, d.get ? d : {
12
- enumerable: true,
13
- get: () => e[k]
14
- });
15
- }
16
- }
17
- }
18
- n.default = e;
19
- return Object.freeze(n);
20
- }
21
- const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
22
- const customTypeAssetRead = async (data, context) => {
23
- const filePath = buildCustomTypeAssetPath.buildCustomTypeAssetPath({
24
- customTypeID: data.customTypeID,
25
- assetID: data.assetID,
26
- helpers: context.helpers
27
- });
28
- const assetData = await fs__namespace.readFile(filePath);
29
- return {
30
- data: assetData
31
- };
32
- };
33
- exports.customTypeAssetRead = customTypeAssetRead;
34
- //# sourceMappingURL=customType-asset-read.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customType-asset-read.cjs","sources":["../../../src/hooks/customType-asset-read.ts"],"sourcesContent":["import type { CustomTypeAssetReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildCustomTypeAssetPath } from \"../lib/buildCustomTypeAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeAssetRead: CustomTypeAssetReadHook<\n\tPluginOptions\n> = async (data, context) => {\n\tconst filePath = buildCustomTypeAssetPath({\n\t\tcustomTypeID: data.customTypeID,\n\t\tassetID: data.assetID,\n\t\thelpers: context.helpers,\n\t});\n\n\tconst assetData = await fs.readFile(filePath);\n\n\treturn {\n\t\tdata: assetData,\n\t};\n};\n"],"names":["buildCustomTypeAssetPath","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOa,MAAA,sBAET,OAAO,MAAM,YAAW;AAC3B,QAAM,WAAWA,yBAAAA,yBAAyB;AAAA,IACzC,cAAc,KAAK;AAAA,IACnB,SAAS,KAAK;AAAA,IACd,SAAS,QAAQ;AAAA,EAAA,CACjB;AAED,QAAM,YAAY,MAAMC,cAAG,SAAS,QAAQ;AAErC,SAAA;AAAA,IACN,MAAM;AAAA,EAAA;AAER;;"}
@@ -1,3 +0,0 @@
1
- import type { CustomTypeAssetReadHook } from "@slicemachine/plugin-kit";
2
- import type { PluginOptions } from "../types";
3
- export declare const customTypeAssetRead: CustomTypeAssetReadHook<PluginOptions>;
@@ -1,17 +0,0 @@
1
- import * as fs from "node:fs/promises";
2
- import { buildCustomTypeAssetPath } from "../lib/buildCustomTypeAssetPath.js";
3
- const customTypeAssetRead = async (data, context) => {
4
- const filePath = buildCustomTypeAssetPath({
5
- customTypeID: data.customTypeID,
6
- assetID: data.assetID,
7
- helpers: context.helpers
8
- });
9
- const assetData = await fs.readFile(filePath);
10
- return {
11
- data: assetData
12
- };
13
- };
14
- export {
15
- customTypeAssetRead
16
- };
17
- //# sourceMappingURL=customType-asset-read.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customType-asset-read.js","sources":["../../../src/hooks/customType-asset-read.ts"],"sourcesContent":["import type { CustomTypeAssetReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildCustomTypeAssetPath } from \"../lib/buildCustomTypeAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeAssetRead: CustomTypeAssetReadHook<\n\tPluginOptions\n> = async (data, context) => {\n\tconst filePath = buildCustomTypeAssetPath({\n\t\tcustomTypeID: data.customTypeID,\n\t\tassetID: data.assetID,\n\t\thelpers: context.helpers,\n\t});\n\n\tconst assetData = await fs.readFile(filePath);\n\n\treturn {\n\t\tdata: assetData,\n\t};\n};\n"],"names":[],"mappings":";;AAOa,MAAA,sBAET,OAAO,MAAM,YAAW;AAC3B,QAAM,WAAW,yBAAyB;AAAA,IACzC,cAAc,KAAK;AAAA,IACnB,SAAS,KAAK;AAAA,IACd,SAAS,QAAQ;AAAA,EAAA,CACjB;AAED,QAAM,YAAY,MAAM,GAAG,SAAS,QAAQ;AAErC,SAAA;AAAA,IACN,MAAM;AAAA,EAAA;AAER;"}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const fs = require("node:fs/promises");
4
- const path = require("node:path");
5
- const buildCustomTypeAssetPath = require("../lib/buildCustomTypeAssetPath.cjs");
6
- function _interopNamespaceDefault(e) {
7
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
8
- if (e) {
9
- for (const k in e) {
10
- if (k !== "default") {
11
- const d = Object.getOwnPropertyDescriptor(e, k);
12
- Object.defineProperty(n, k, d.get ? d : {
13
- enumerable: true,
14
- get: () => e[k]
15
- });
16
- }
17
- }
18
- }
19
- n.default = e;
20
- return Object.freeze(n);
21
- }
22
- const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
23
- const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
24
- const customTypeAssetUpdate = async (data, context) => {
25
- const filePath = buildCustomTypeAssetPath.buildCustomTypeAssetPath({
26
- customTypeID: data.customTypeID,
27
- assetID: data.asset.id,
28
- helpers: context.helpers
29
- });
30
- await fs__namespace.mkdir(path__namespace.dirname(filePath), { recursive: true });
31
- await fs__namespace.writeFile(filePath, data.asset.data);
32
- };
33
- exports.customTypeAssetUpdate = customTypeAssetUpdate;
34
- //# sourceMappingURL=customType-asset-update.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customType-asset-update.cjs","sources":["../../../src/hooks/customType-asset-update.ts"],"sourcesContent":["import type { CustomTypeAssetUpdateHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildCustomTypeAssetPath } from \"../lib/buildCustomTypeAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeAssetUpdate: CustomTypeAssetUpdateHook<\n\tPluginOptions\n> = async (data, context) => {\n\tconst filePath = buildCustomTypeAssetPath({\n\t\tcustomTypeID: data.customTypeID,\n\t\tassetID: data.asset.id,\n\t\thelpers: context.helpers,\n\t});\n\n\tawait fs.mkdir(path.dirname(filePath), { recursive: true });\n\tawait fs.writeFile(filePath, data.asset.data);\n};\n"],"names":["buildCustomTypeAssetPath","fs","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAQa,MAAA,wBAET,OAAO,MAAM,YAAW;AAC3B,QAAM,WAAWA,yBAAAA,yBAAyB;AAAA,IACzC,cAAc,KAAK;AAAA,IACnB,SAAS,KAAK,MAAM;AAAA,IACpB,SAAS,QAAQ;AAAA,EAAA,CACjB;AAEK,QAAAC,cAAG,MAAMC,gBAAK,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAA,CAAM;AAC1D,QAAMD,cAAG,UAAU,UAAU,KAAK,MAAM,IAAI;AAC7C;;"}
@@ -1,3 +0,0 @@
1
- import type { CustomTypeAssetUpdateHook } from "@slicemachine/plugin-kit";
2
- import type { PluginOptions } from "../types";
3
- export declare const customTypeAssetUpdate: CustomTypeAssetUpdateHook<PluginOptions>;
@@ -1,16 +0,0 @@
1
- import * as fs from "node:fs/promises";
2
- import * as path from "node:path";
3
- import { buildCustomTypeAssetPath } from "../lib/buildCustomTypeAssetPath.js";
4
- const customTypeAssetUpdate = async (data, context) => {
5
- const filePath = buildCustomTypeAssetPath({
6
- customTypeID: data.customTypeID,
7
- assetID: data.asset.id,
8
- helpers: context.helpers
9
- });
10
- await fs.mkdir(path.dirname(filePath), { recursive: true });
11
- await fs.writeFile(filePath, data.asset.data);
12
- };
13
- export {
14
- customTypeAssetUpdate
15
- };
16
- //# sourceMappingURL=customType-asset-update.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customType-asset-update.js","sources":["../../../src/hooks/customType-asset-update.ts"],"sourcesContent":["import type { CustomTypeAssetUpdateHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildCustomTypeAssetPath } from \"../lib/buildCustomTypeAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeAssetUpdate: CustomTypeAssetUpdateHook<\n\tPluginOptions\n> = async (data, context) => {\n\tconst filePath = buildCustomTypeAssetPath({\n\t\tcustomTypeID: data.customTypeID,\n\t\tassetID: data.asset.id,\n\t\thelpers: context.helpers,\n\t});\n\n\tawait fs.mkdir(path.dirname(filePath), { recursive: true });\n\tawait fs.writeFile(filePath, data.asset.data);\n};\n"],"names":[],"mappings":";;;AAQa,MAAA,wBAET,OAAO,MAAM,YAAW;AAC3B,QAAM,WAAW,yBAAyB;AAAA,IACzC,cAAc,KAAK;AAAA,IACnB,SAAS,KAAK,MAAM;AAAA,IACpB,SAAS,QAAQ;AAAA,EAAA,CACjB;AAEK,QAAA,GAAG,MAAM,KAAK,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAA,CAAM;AAC1D,QAAM,GAAG,UAAU,UAAU,KAAK,MAAM,IAAI;AAC7C;"}
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const fs = require("node:fs/promises");
4
- const path = require("node:path");
5
- const buildCustomTypeDirectoryPath = require("../lib/buildCustomTypeDirectoryPath.cjs");
6
- const upsertGlobalContentTypes = require("../lib/upsertGlobalContentTypes.cjs");
7
- function _interopNamespaceDefault(e) {
8
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
9
- if (e) {
10
- for (const k in e) {
11
- if (k !== "default") {
12
- const d = Object.getOwnPropertyDescriptor(e, k);
13
- Object.defineProperty(n, k, d.get ? d : {
14
- enumerable: true,
15
- get: () => e[k]
16
- });
17
- }
18
- }
19
- }
20
- n.default = e;
21
- return Object.freeze(n);
22
- }
23
- const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
24
- const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
25
- const createModelFile = async ({ dir, data, helpers, options }) => {
26
- const filePath = path__namespace.join(dir, "index.json");
27
- let contents = JSON.stringify(data.model);
28
- if (options.format) {
29
- contents = await helpers.format(contents, filePath);
30
- }
31
- await fs__namespace.writeFile(filePath, contents);
32
- };
33
- const customTypeCreate = async (data, context) => {
34
- const dir = buildCustomTypeDirectoryPath.buildCustomTypeDirectoryPath({
35
- customTypeID: data.model.id,
36
- helpers: context.helpers
37
- });
38
- await fs__namespace.mkdir(dir, { recursive: true });
39
- await createModelFile({ dir, data, ...context });
40
- await upsertGlobalContentTypes.upsertGlobalContentTypes(context);
41
- };
42
- exports.customTypeCreate = customTypeCreate;
43
- //# sourceMappingURL=customType-create.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customType-create.cjs","sources":["../../../src/hooks/customType-create.ts"],"sourcesContent":["import type {\n\tCustomTypeCreateHook,\n\tCustomTypeCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildCustomTypeDirectoryPath } from \"../lib/buildCustomTypeDirectoryPath\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdir: string;\n\tdata: CustomTypeCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createModelFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, \"index.json\");\n\n\tlet contents = JSON.stringify(data.model);\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath);\n\t}\n\n\tawait fs.writeFile(filePath, contents);\n};\n\nexport const customTypeCreate: CustomTypeCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst dir = buildCustomTypeDirectoryPath({\n\t\tcustomTypeID: data.model.id,\n\t\thelpers: context.helpers,\n\t});\n\n\tawait fs.mkdir(dir, { recursive: true });\n\n\tawait createModelFile({ dir, data, ...context });\n\n\tawait upsertGlobalContentTypes(context);\n};\n"],"names":["path","fs","buildCustomTypeDirectoryPath","upsertGlobalContentTypes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,kBAAkB,OAAO,EAAE,KAAK,MAAM,SAAS,cAAmB;AACvE,QAAM,WAAWA,gBAAK,KAAK,KAAK,YAAY;AAE5C,MAAI,WAAW,KAAK,UAAU,KAAK,KAAK;AAExC,MAAI,QAAQ,QAAQ;AACnB,eAAW,MAAM,QAAQ,OAAO,UAAU,QAAQ;AAAA,EAClD;AAEK,QAAAC,cAAG,UAAU,UAAU,QAAQ;AACtC;AAEa,MAAA,mBAAwD,OACpE,MACA,YACG;AACH,QAAM,MAAMC,6BAAAA,6BAA6B;AAAA,IACxC,cAAc,KAAK,MAAM;AAAA,IACzB,SAAS,QAAQ;AAAA,EAAA,CACjB;AAED,QAAMD,cAAG,MAAM,KAAK,EAAE,WAAW,MAAM;AAEvC,QAAM,gBAAgB,EAAE,KAAK,MAAM,GAAG,QAAS,CAAA;AAE/C,QAAME,yBAAAA,yBAAyB,OAAO;AACvC;;"}
@@ -1,3 +0,0 @@
1
- import type { CustomTypeCreateHook } from "@slicemachine/plugin-kit";
2
- import type { PluginOptions } from "../types";
3
- export declare const customTypeCreate: CustomTypeCreateHook<PluginOptions>;
@@ -1,25 +0,0 @@
1
- import * as fs from "node:fs/promises";
2
- import * as path from "node:path";
3
- import { buildCustomTypeDirectoryPath } from "../lib/buildCustomTypeDirectoryPath.js";
4
- import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes.js";
5
- const createModelFile = async ({ dir, data, helpers, options }) => {
6
- const filePath = path.join(dir, "index.json");
7
- let contents = JSON.stringify(data.model);
8
- if (options.format) {
9
- contents = await helpers.format(contents, filePath);
10
- }
11
- await fs.writeFile(filePath, contents);
12
- };
13
- const customTypeCreate = async (data, context) => {
14
- const dir = buildCustomTypeDirectoryPath({
15
- customTypeID: data.model.id,
16
- helpers: context.helpers
17
- });
18
- await fs.mkdir(dir, { recursive: true });
19
- await createModelFile({ dir, data, ...context });
20
- await upsertGlobalContentTypes(context);
21
- };
22
- export {
23
- customTypeCreate
24
- };
25
- //# sourceMappingURL=customType-create.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customType-create.js","sources":["../../../src/hooks/customType-create.ts"],"sourcesContent":["import type {\n\tCustomTypeCreateHook,\n\tCustomTypeCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildCustomTypeDirectoryPath } from \"../lib/buildCustomTypeDirectoryPath\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdir: string;\n\tdata: CustomTypeCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createModelFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, \"index.json\");\n\n\tlet contents = JSON.stringify(data.model);\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath);\n\t}\n\n\tawait fs.writeFile(filePath, contents);\n};\n\nexport const customTypeCreate: CustomTypeCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst dir = buildCustomTypeDirectoryPath({\n\t\tcustomTypeID: data.model.id,\n\t\thelpers: context.helpers,\n\t});\n\n\tawait fs.mkdir(dir, { recursive: true });\n\n\tawait createModelFile({ dir, data, ...context });\n\n\tawait upsertGlobalContentTypes(context);\n};\n"],"names":[],"mappings":";;;;AAkBA,MAAM,kBAAkB,OAAO,EAAE,KAAK,MAAM,SAAS,cAAmB;AACvE,QAAM,WAAW,KAAK,KAAK,KAAK,YAAY;AAE5C,MAAI,WAAW,KAAK,UAAU,KAAK,KAAK;AAExC,MAAI,QAAQ,QAAQ;AACnB,eAAW,MAAM,QAAQ,OAAO,UAAU,QAAQ;AAAA,EAClD;AAEK,QAAA,GAAG,UAAU,UAAU,QAAQ;AACtC;AAEa,MAAA,mBAAwD,OACpE,MACA,YACG;AACH,QAAM,MAAM,6BAA6B;AAAA,IACxC,cAAc,KAAK,MAAM;AAAA,IACzB,SAAS,QAAQ;AAAA,EAAA,CACjB;AAED,QAAM,GAAG,MAAM,KAAK,EAAE,WAAW,MAAM;AAEvC,QAAM,gBAAgB,EAAE,KAAK,MAAM,GAAG,QAAS,CAAA;AAE/C,QAAM,yBAAyB,OAAO;AACvC;"}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const fs = require("node:fs/promises");
4
- const buildCustomTypeDirectoryPath = require("../lib/buildCustomTypeDirectoryPath.cjs");
5
- const upsertGlobalContentTypes = require("../lib/upsertGlobalContentTypes.cjs");
6
- function _interopNamespaceDefault(e) {
7
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
8
- if (e) {
9
- for (const k in e) {
10
- if (k !== "default") {
11
- const d = Object.getOwnPropertyDescriptor(e, k);
12
- Object.defineProperty(n, k, d.get ? d : {
13
- enumerable: true,
14
- get: () => e[k]
15
- });
16
- }
17
- }
18
- }
19
- n.default = e;
20
- return Object.freeze(n);
21
- }
22
- const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
23
- const customTypeDelete = async (data, context) => {
24
- const dir = buildCustomTypeDirectoryPath.buildCustomTypeDirectoryPath({
25
- customTypeID: data.model.id,
26
- helpers: context.helpers
27
- });
28
- await fs__namespace.rm(dir, { recursive: true });
29
- await upsertGlobalContentTypes.upsertGlobalContentTypes(context);
30
- };
31
- exports.customTypeDelete = customTypeDelete;
32
- //# sourceMappingURL=customType-delete.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customType-delete.cjs","sources":["../../../src/hooks/customType-delete.ts"],"sourcesContent":["import type { CustomTypeDeleteHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildCustomTypeDirectoryPath } from \"../lib/buildCustomTypeDirectoryPath\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeDelete: CustomTypeDeleteHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst dir = buildCustomTypeDirectoryPath({\n\t\tcustomTypeID: data.model.id,\n\t\thelpers: context.helpers,\n\t});\n\n\tawait fs.rm(dir, { recursive: true });\n\n\tawait upsertGlobalContentTypes(context);\n};\n"],"names":["buildCustomTypeDirectoryPath","fs","upsertGlobalContentTypes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAQa,MAAA,mBAAwD,OACpE,MACA,YACG;AACH,QAAM,MAAMA,6BAAAA,6BAA6B;AAAA,IACxC,cAAc,KAAK,MAAM;AAAA,IACzB,SAAS,QAAQ;AAAA,EAAA,CACjB;AAED,QAAMC,cAAG,GAAG,KAAK,EAAE,WAAW,MAAM;AAEpC,QAAMC,yBAAAA,yBAAyB,OAAO;AACvC;;"}
@@ -1,3 +0,0 @@
1
- import type { CustomTypeDeleteHook } from "@slicemachine/plugin-kit";
2
- import type { PluginOptions } from "../types";
3
- export declare const customTypeDelete: CustomTypeDeleteHook<PluginOptions>;