@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
@@ -1,15 +0,0 @@
1
- import * as fs from "node:fs/promises";
2
- import { buildCustomTypeDirectoryPath } from "../lib/buildCustomTypeDirectoryPath.js";
3
- import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes.js";
4
- const customTypeDelete = async (data, context) => {
5
- const dir = buildCustomTypeDirectoryPath({
6
- customTypeID: data.model.id,
7
- helpers: context.helpers
8
- });
9
- await fs.rm(dir, { recursive: true });
10
- await upsertGlobalContentTypes(context);
11
- };
12
- export {
13
- customTypeDelete
14
- };
15
- //# sourceMappingURL=customType-delete.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customType-delete.js","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":[],"mappings":";;;AAQa,MAAA,mBAAwD,OACpE,MACA,YACG;AACH,QAAM,MAAM,6BAA6B;AAAA,IACxC,cAAc,KAAK,MAAM;AAAA,IACzB,SAAS,QAAQ;AAAA,EAAA,CACjB;AAED,QAAM,GAAG,GAAG,KAAK,EAAE,WAAW,MAAM;AAEpC,QAAM,yBAAyB,OAAO;AACvC;"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const path = require("node:path");
4
- const buildCustomTypeDirectoryPath = require("../lib/buildCustomTypeDirectoryPath.cjs");
5
- const readJSONFile = require("../lib/readJSONFile.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 path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
23
- const customTypeRead = async (data, { helpers }) => {
24
- const filePath = path__namespace.join(buildCustomTypeDirectoryPath.buildCustomTypeDirectoryPath({ customTypeID: data.id, helpers }), "index.json");
25
- const model = await readJSONFile.readJSONFile(filePath);
26
- return {
27
- model
28
- };
29
- };
30
- exports.customTypeRead = customTypeRead;
31
- //# sourceMappingURL=customType-read.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customType-read.cjs","sources":["../../../src/hooks/customType-read.ts"],"sourcesContent":["import type { CustomTypeReadHook } from \"@slicemachine/plugin-kit\";\nimport type { CustomType } from \"@prismicio/types-internal/lib/customtypes\";\nimport * as path from \"node:path\";\n\nimport { buildCustomTypeDirectoryPath } from \"../lib/buildCustomTypeDirectoryPath\";\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeRead: CustomTypeReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst filePath = path.join(\n\t\tbuildCustomTypeDirectoryPath({ customTypeID: data.id, helpers }),\n\t\t\"index.json\",\n\t);\n\n\tconst model = await readJSONFile<CustomType>(filePath);\n\n\treturn {\n\t\tmodel,\n\t};\n};\n"],"names":["path","buildCustomTypeDirectoryPath","readJSONFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AASO,MAAM,iBAAoD,OAChE,MACA,EAAE,cACC;AACG,QAAA,WAAWA,gBAAK,KACrBC,6BAA6B,6BAAA,EAAE,cAAc,KAAK,IAAI,SAAS,GAC/D,YAAY;AAGP,QAAA,QAAQ,MAAMC,0BAAyB,QAAQ;AAE9C,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;;"}
@@ -1,3 +0,0 @@
1
- import type { CustomTypeReadHook } from "@slicemachine/plugin-kit";
2
- import type { PluginOptions } from "../types";
3
- export declare const customTypeRead: CustomTypeReadHook<PluginOptions>;
@@ -1,14 +0,0 @@
1
- import * as path from "node:path";
2
- import { buildCustomTypeDirectoryPath } from "../lib/buildCustomTypeDirectoryPath.js";
3
- import { readJSONFile } from "../lib/readJSONFile.js";
4
- const customTypeRead = async (data, { helpers }) => {
5
- const filePath = path.join(buildCustomTypeDirectoryPath({ customTypeID: data.id, helpers }), "index.json");
6
- const model = await readJSONFile(filePath);
7
- return {
8
- model
9
- };
10
- };
11
- export {
12
- customTypeRead
13
- };
14
- //# sourceMappingURL=customType-read.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customType-read.js","sources":["../../../src/hooks/customType-read.ts"],"sourcesContent":["import type { CustomTypeReadHook } from \"@slicemachine/plugin-kit\";\nimport type { CustomType } from \"@prismicio/types-internal/lib/customtypes\";\nimport * as path from \"node:path\";\n\nimport { buildCustomTypeDirectoryPath } from \"../lib/buildCustomTypeDirectoryPath\";\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeRead: CustomTypeReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst filePath = path.join(\n\t\tbuildCustomTypeDirectoryPath({ customTypeID: data.id, helpers }),\n\t\t\"index.json\",\n\t);\n\n\tconst model = await readJSONFile<CustomType>(filePath);\n\n\treturn {\n\t\tmodel,\n\t};\n};\n"],"names":[],"mappings":";;;AASO,MAAM,iBAAoD,OAChE,MACA,EAAE,cACC;AACG,QAAA,WAAW,KAAK,KACrB,6BAA6B,EAAE,cAAc,KAAK,IAAI,SAAS,GAC/D,YAAY;AAGP,QAAA,QAAQ,MAAM,aAAyB,QAAQ;AAE9C,SAAA;AAAA,IACN;AAAA,EAAA;AAEF;"}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const customTypeCreate = require("./customType-create.cjs");
4
- const customTypeRename = customTypeCreate.customTypeCreate;
5
- exports.customTypeRename = customTypeRename;
6
- //# sourceMappingURL=customType-rename.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customType-rename.cjs","sources":["../../../src/hooks/customType-rename.ts"],"sourcesContent":["import { customTypeCreate } from \"./customType-create\";\n\nexport const customTypeRename = customTypeCreate;\n"],"names":["customTypeCreate"],"mappings":";;;AAEO,MAAM,mBAAmBA,iBAAAA;;"}
@@ -1 +0,0 @@
1
- export declare const customTypeRename: import("@slicemachine/plugin-kit").CustomTypeCreateHook<import("..").PluginOptions>;
@@ -1,6 +0,0 @@
1
- import { customTypeCreate } from "./customType-create.js";
2
- const customTypeRename = customTypeCreate;
3
- export {
4
- customTypeRename
5
- };
6
- //# sourceMappingURL=customType-rename.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customType-rename.js","sources":["../../../src/hooks/customType-rename.ts"],"sourcesContent":["import { customTypeCreate } from \"./customType-create\";\n\nexport const customTypeRename = customTypeCreate;\n"],"names":[],"mappings":";AAEO,MAAM,mBAAmB;"}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const customTypeCreate = require("./customType-create.cjs");
4
- const customTypeUpdate = customTypeCreate.customTypeCreate;
5
- exports.customTypeUpdate = customTypeUpdate;
6
- //# sourceMappingURL=customType-update.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customType-update.cjs","sources":["../../../src/hooks/customType-update.ts"],"sourcesContent":["import { customTypeCreate } from \"./customType-create\";\n\nexport const customTypeUpdate = customTypeCreate;\n"],"names":["customTypeCreate"],"mappings":";;;AAEO,MAAM,mBAAmBA,iBAAAA;;"}
@@ -1 +0,0 @@
1
- export declare const customTypeUpdate: import("@slicemachine/plugin-kit").CustomTypeCreateHook<import("..").PluginOptions>;
@@ -1,6 +0,0 @@
1
- import { customTypeCreate } from "./customType-create.js";
2
- const customTypeUpdate = customTypeCreate;
3
- export {
4
- customTypeUpdate
5
- };
6
- //# sourceMappingURL=customType-update.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customType-update.js","sources":["../../../src/hooks/customType-update.ts"],"sourcesContent":["import { customTypeCreate } from \"./customType-create\";\n\nexport const customTypeUpdate = customTypeCreate;\n"],"names":[],"mappings":";AAEO,MAAM,mBAAmB;"}
@@ -1,55 +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 buildCustomTypeLibraryDirectoryPath = require("../lib/buildCustomTypeLibraryDirectoryPath.cjs");
6
- const readJSONFile = require("../lib/readJSONFile.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 isCustomTypeModel = (input) => {
26
- return typeof input === "object" && input !== null && "json" in input;
27
- };
28
- const customTypeLibraryRead = async (_data, { helpers }) => {
29
- const dir = buildCustomTypeLibraryDirectoryPath.buildCustomTypeLibraryDirectoryPath({ helpers });
30
- await fs__namespace.mkdir(dir, { recursive: true });
31
- const childDirs = await fs__namespace.readdir(dir, { withFileTypes: true });
32
- const ids = [];
33
- await Promise.all(childDirs.map(async (childDir) => {
34
- if (childDir.isDirectory()) {
35
- const childDirContents = await fs__namespace.readdir(path__namespace.join(dir, childDir.name), {
36
- withFileTypes: true
37
- });
38
- const isCustomTypeDir = childDirContents.some((entry) => {
39
- return entry.isFile() && entry.name === "index.json";
40
- });
41
- if (isCustomTypeDir) {
42
- const modelPath = path__namespace.join(dir, childDir.name, "index.json");
43
- const modelContents = await readJSONFile.readJSONFile(modelPath);
44
- if (isCustomTypeModel(modelContents)) {
45
- ids.push(modelContents.id);
46
- }
47
- }
48
- }
49
- }));
50
- return {
51
- ids: ids.sort()
52
- };
53
- };
54
- exports.customTypeLibraryRead = customTypeLibraryRead;
55
- //# sourceMappingURL=customTypeLibrary-read.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customTypeLibrary-read.cjs","sources":["../../../src/hooks/customTypeLibrary-read.ts"],"sourcesContent":["import type { CustomTypeLibraryReadHook } from \"@slicemachine/plugin-kit\";\nimport type { CustomType } from \"@prismicio/types-internal/lib/customtypes\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildCustomTypeLibraryDirectoryPath } from \"../lib/buildCustomTypeLibraryDirectoryPath\";\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst isCustomTypeModel = (\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tinput: any,\n): input is CustomType => {\n\treturn typeof input === \"object\" && input !== null && \"json\" in input;\n};\n\nexport const customTypeLibraryRead: CustomTypeLibraryReadHook<\n\tPluginOptions\n> = async (_data, { helpers }) => {\n\tconst dir = buildCustomTypeLibraryDirectoryPath({ helpers });\n\n\t// Ensure the directory exists.\n\tawait fs.mkdir(dir, { recursive: true });\n\n\tconst childDirs = await fs.readdir(dir, { withFileTypes: true });\n\n\tconst ids: string[] = [];\n\tawait Promise.all(\n\t\tchildDirs.map(async (childDir) => {\n\t\t\tif (childDir.isDirectory()) {\n\t\t\t\tconst childDirContents = await fs.readdir(\n\t\t\t\t\tpath.join(dir, childDir.name),\n\t\t\t\t\t{\n\t\t\t\t\t\twithFileTypes: true,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tconst isCustomTypeDir = childDirContents.some((entry) => {\n\t\t\t\t\treturn entry.isFile() && entry.name === \"index.json\";\n\t\t\t\t});\n\n\t\t\t\tif (isCustomTypeDir) {\n\t\t\t\t\tconst modelPath = path.join(dir, childDir.name, \"index.json\");\n\n\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\tif (isCustomTypeModel(modelContents)) {\n\t\t\t\t\t\tids.push(modelContents.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t);\n\n\treturn {\n\t\tids: ids.sort(),\n\t};\n};\n"],"names":["buildCustomTypeLibraryDirectoryPath","fs","path","readJSONFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAM,oBAAoB,CAEzB,UACwB;AACxB,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;AACjE;AAEO,MAAM,wBAET,OAAO,OAAO,EAAE,cAAa;AAChC,QAAM,MAAMA,oCAAAA,oCAAoC,EAAE,QAAS,CAAA;AAG3D,QAAMC,cAAG,MAAM,KAAK,EAAE,WAAW,MAAM;AAEjC,QAAA,YAAY,MAAMA,cAAG,QAAQ,KAAK,EAAE,eAAe,MAAM;AAE/D,QAAM,MAAgB,CAAA;AACtB,QAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,QAAA,SAAS,eAAe;AACrB,YAAA,mBAAmB,MAAMA,cAAG,QACjCC,gBAAK,KAAK,KAAK,SAAS,IAAI,GAC5B;AAAA,QACC,eAAe;AAAA,MAAA,CACf;AAEF,YAAM,kBAAkB,iBAAiB,KAAK,CAAC,UAAS;AACvD,eAAO,MAAM,OAAA,KAAY,MAAM,SAAS;AAAA,MAAA,CACxC;AAED,UAAI,iBAAiB;AACpB,cAAM,YAAYA,gBAAK,KAAK,KAAK,SAAS,MAAM,YAAY;AAEtD,cAAA,gBAAgB,MAAMC,0BAAa,SAAS;AAE9C,YAAA,kBAAkB,aAAa,GAAG;AACjC,cAAA,KAAK,cAAc,EAAE;AAAA,QACzB;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAA,CAAC;AAGI,SAAA;AAAA,IACN,KAAK,IAAI,KAAM;AAAA,EAAA;AAEjB;;"}
@@ -1,3 +0,0 @@
1
- import type { CustomTypeLibraryReadHook } from "@slicemachine/plugin-kit";
2
- import type { PluginOptions } from "../types";
3
- export declare const customTypeLibraryRead: CustomTypeLibraryReadHook<PluginOptions>;
@@ -1,37 +0,0 @@
1
- import * as fs from "node:fs/promises";
2
- import * as path from "node:path";
3
- import { buildCustomTypeLibraryDirectoryPath } from "../lib/buildCustomTypeLibraryDirectoryPath.js";
4
- import { readJSONFile } from "../lib/readJSONFile.js";
5
- const isCustomTypeModel = (input) => {
6
- return typeof input === "object" && input !== null && "json" in input;
7
- };
8
- const customTypeLibraryRead = async (_data, { helpers }) => {
9
- const dir = buildCustomTypeLibraryDirectoryPath({ helpers });
10
- await fs.mkdir(dir, { recursive: true });
11
- const childDirs = await fs.readdir(dir, { withFileTypes: true });
12
- const ids = [];
13
- await Promise.all(childDirs.map(async (childDir) => {
14
- if (childDir.isDirectory()) {
15
- const childDirContents = await fs.readdir(path.join(dir, childDir.name), {
16
- withFileTypes: true
17
- });
18
- const isCustomTypeDir = childDirContents.some((entry) => {
19
- return entry.isFile() && entry.name === "index.json";
20
- });
21
- if (isCustomTypeDir) {
22
- const modelPath = path.join(dir, childDir.name, "index.json");
23
- const modelContents = await readJSONFile(modelPath);
24
- if (isCustomTypeModel(modelContents)) {
25
- ids.push(modelContents.id);
26
- }
27
- }
28
- }
29
- }));
30
- return {
31
- ids: ids.sort()
32
- };
33
- };
34
- export {
35
- customTypeLibraryRead
36
- };
37
- //# sourceMappingURL=customTypeLibrary-read.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"customTypeLibrary-read.js","sources":["../../../src/hooks/customTypeLibrary-read.ts"],"sourcesContent":["import type { CustomTypeLibraryReadHook } from \"@slicemachine/plugin-kit\";\nimport type { CustomType } from \"@prismicio/types-internal/lib/customtypes\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildCustomTypeLibraryDirectoryPath } from \"../lib/buildCustomTypeLibraryDirectoryPath\";\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst isCustomTypeModel = (\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tinput: any,\n): input is CustomType => {\n\treturn typeof input === \"object\" && input !== null && \"json\" in input;\n};\n\nexport const customTypeLibraryRead: CustomTypeLibraryReadHook<\n\tPluginOptions\n> = async (_data, { helpers }) => {\n\tconst dir = buildCustomTypeLibraryDirectoryPath({ helpers });\n\n\t// Ensure the directory exists.\n\tawait fs.mkdir(dir, { recursive: true });\n\n\tconst childDirs = await fs.readdir(dir, { withFileTypes: true });\n\n\tconst ids: string[] = [];\n\tawait Promise.all(\n\t\tchildDirs.map(async (childDir) => {\n\t\t\tif (childDir.isDirectory()) {\n\t\t\t\tconst childDirContents = await fs.readdir(\n\t\t\t\t\tpath.join(dir, childDir.name),\n\t\t\t\t\t{\n\t\t\t\t\t\twithFileTypes: true,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tconst isCustomTypeDir = childDirContents.some((entry) => {\n\t\t\t\t\treturn entry.isFile() && entry.name === \"index.json\";\n\t\t\t\t});\n\n\t\t\t\tif (isCustomTypeDir) {\n\t\t\t\t\tconst modelPath = path.join(dir, childDir.name, \"index.json\");\n\n\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\tif (isCustomTypeModel(modelContents)) {\n\t\t\t\t\t\tids.push(modelContents.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t);\n\n\treturn {\n\t\tids: ids.sort(),\n\t};\n};\n"],"names":[],"mappings":";;;;AAUA,MAAM,oBAAoB,CAEzB,UACwB;AACxB,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;AACjE;AAEO,MAAM,wBAET,OAAO,OAAO,EAAE,cAAa;AAChC,QAAM,MAAM,oCAAoC,EAAE,QAAS,CAAA;AAG3D,QAAM,GAAG,MAAM,KAAK,EAAE,WAAW,MAAM;AAEjC,QAAA,YAAY,MAAM,GAAG,QAAQ,KAAK,EAAE,eAAe,MAAM;AAE/D,QAAM,MAAgB,CAAA;AACtB,QAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,QAAA,SAAS,eAAe;AACrB,YAAA,mBAAmB,MAAM,GAAG,QACjC,KAAK,KAAK,KAAK,SAAS,IAAI,GAC5B;AAAA,QACC,eAAe;AAAA,MAAA,CACf;AAEF,YAAM,kBAAkB,iBAAiB,KAAK,CAAC,UAAS;AACvD,eAAO,MAAM,OAAA,KAAY,MAAM,SAAS;AAAA,MAAA,CACxC;AAED,UAAI,iBAAiB;AACpB,cAAM,YAAY,KAAK,KAAK,KAAK,SAAS,MAAM,YAAY;AAEtD,cAAA,gBAAgB,MAAM,aAAa,SAAS;AAE9C,YAAA,kBAAkB,aAAa,GAAG;AACjC,cAAA,KAAK,cAAc,EAAE;AAAA,QACzB;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAA,CAAC;AAGI,SAAA;AAAA,IACN,KAAK,IAAI,KAAM;AAAA,EAAA;AAEjB;"}
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const fs = require("node:fs/promises");
4
- const buildSliceAssetPath = require("../lib/buildSliceAssetPath.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 sliceAssetDelete = async (data, context) => {
23
- const filePath = await buildSliceAssetPath.buildSliceAssetPath({
24
- libraryID: data.libraryID,
25
- sliceID: data.sliceID,
26
- assetID: data.assetID,
27
- helpers: context.helpers,
28
- actions: context.actions
29
- });
30
- await fs__namespace.rm(filePath);
31
- };
32
- exports.sliceAssetDelete = sliceAssetDelete;
33
- //# sourceMappingURL=slice-asset-delete.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slice-asset-delete.cjs","sources":["../../../src/hooks/slice-asset-delete.ts"],"sourcesContent":["import type { SliceAssetDeleteHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildSliceAssetPath } from \"../lib/buildSliceAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceAssetDelete: SliceAssetDeleteHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst filePath = await buildSliceAssetPath({\n\t\tlibraryID: data.libraryID,\n\t\tsliceID: data.sliceID,\n\t\tassetID: data.assetID,\n\t\thelpers: context.helpers,\n\t\tactions: context.actions,\n\t});\n\n\tawait fs.rm(filePath);\n};\n"],"names":["buildSliceAssetPath","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOa,MAAA,mBAAwD,OACpE,MACA,YACG;AACG,QAAA,WAAW,MAAMA,wCAAoB;AAAA,IAC1C,WAAW,KAAK;AAAA,IAChB,SAAS,KAAK;AAAA,IACd,SAAS,KAAK;AAAA,IACd,SAAS,QAAQ;AAAA,IACjB,SAAS,QAAQ;AAAA,EAAA,CACjB;AAEK,QAAAC,cAAG,GAAG,QAAQ;AACrB;;"}
@@ -1,3 +0,0 @@
1
- import type { SliceAssetDeleteHook } from "@slicemachine/plugin-kit";
2
- import type { PluginOptions } from "../types";
3
- export declare const sliceAssetDelete: SliceAssetDeleteHook<PluginOptions>;
@@ -1,16 +0,0 @@
1
- import * as fs from "node:fs/promises";
2
- import { buildSliceAssetPath } from "../lib/buildSliceAssetPath.js";
3
- const sliceAssetDelete = async (data, context) => {
4
- const filePath = await buildSliceAssetPath({
5
- libraryID: data.libraryID,
6
- sliceID: data.sliceID,
7
- assetID: data.assetID,
8
- helpers: context.helpers,
9
- actions: context.actions
10
- });
11
- await fs.rm(filePath);
12
- };
13
- export {
14
- sliceAssetDelete
15
- };
16
- //# sourceMappingURL=slice-asset-delete.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slice-asset-delete.js","sources":["../../../src/hooks/slice-asset-delete.ts"],"sourcesContent":["import type { SliceAssetDeleteHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildSliceAssetPath } from \"../lib/buildSliceAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceAssetDelete: SliceAssetDeleteHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst filePath = await buildSliceAssetPath({\n\t\tlibraryID: data.libraryID,\n\t\tsliceID: data.sliceID,\n\t\tassetID: data.assetID,\n\t\thelpers: context.helpers,\n\t\tactions: context.actions,\n\t});\n\n\tawait fs.rm(filePath);\n};\n"],"names":[],"mappings":";;AAOa,MAAA,mBAAwD,OACpE,MACA,YACG;AACG,QAAA,WAAW,MAAM,oBAAoB;AAAA,IAC1C,WAAW,KAAK;AAAA,IAChB,SAAS,KAAK;AAAA,IACd,SAAS,KAAK;AAAA,IACd,SAAS,QAAQ;AAAA,IACjB,SAAS,QAAQ;AAAA,EAAA,CACjB;AAEK,QAAA,GAAG,GAAG,QAAQ;AACrB;"}
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const fs = require("node:fs/promises");
4
- const buildSliceAssetPath = require("../lib/buildSliceAssetPath.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 sliceAssetRead = async (data, context) => {
23
- const filePath = await buildSliceAssetPath.buildSliceAssetPath({
24
- libraryID: data.libraryID,
25
- sliceID: data.sliceID,
26
- assetID: data.assetID,
27
- helpers: context.helpers,
28
- actions: context.actions
29
- });
30
- const assetData = await fs__namespace.readFile(filePath);
31
- return {
32
- data: assetData
33
- };
34
- };
35
- exports.sliceAssetRead = sliceAssetRead;
36
- //# sourceMappingURL=slice-asset-read.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slice-asset-read.cjs","sources":["../../../src/hooks/slice-asset-read.ts"],"sourcesContent":["import type { SliceAssetReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildSliceAssetPath } from \"../lib/buildSliceAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceAssetRead: SliceAssetReadHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst filePath = await buildSliceAssetPath({\n\t\tlibraryID: data.libraryID,\n\t\tsliceID: data.sliceID,\n\t\tassetID: data.assetID,\n\t\thelpers: context.helpers,\n\t\tactions: context.actions,\n\t});\n\n\tconst assetData = await fs.readFile(filePath);\n\n\treturn {\n\t\tdata: assetData,\n\t};\n};\n"],"names":["buildSliceAssetPath","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOa,MAAA,iBAAoD,OAChE,MACA,YACG;AACG,QAAA,WAAW,MAAMA,wCAAoB;AAAA,IAC1C,WAAW,KAAK;AAAA,IAChB,SAAS,KAAK;AAAA,IACd,SAAS,KAAK;AAAA,IACd,SAAS,QAAQ;AAAA,IACjB,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 { SliceAssetReadHook } from "@slicemachine/plugin-kit";
2
- import type { PluginOptions } from "../types";
3
- export declare const sliceAssetRead: SliceAssetReadHook<PluginOptions>;
@@ -1,19 +0,0 @@
1
- import * as fs from "node:fs/promises";
2
- import { buildSliceAssetPath } from "../lib/buildSliceAssetPath.js";
3
- const sliceAssetRead = async (data, context) => {
4
- const filePath = await buildSliceAssetPath({
5
- libraryID: data.libraryID,
6
- sliceID: data.sliceID,
7
- assetID: data.assetID,
8
- helpers: context.helpers,
9
- actions: context.actions
10
- });
11
- const assetData = await fs.readFile(filePath);
12
- return {
13
- data: assetData
14
- };
15
- };
16
- export {
17
- sliceAssetRead
18
- };
19
- //# sourceMappingURL=slice-asset-read.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slice-asset-read.js","sources":["../../../src/hooks/slice-asset-read.ts"],"sourcesContent":["import type { SliceAssetReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildSliceAssetPath } from \"../lib/buildSliceAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceAssetRead: SliceAssetReadHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst filePath = await buildSliceAssetPath({\n\t\tlibraryID: data.libraryID,\n\t\tsliceID: data.sliceID,\n\t\tassetID: data.assetID,\n\t\thelpers: context.helpers,\n\t\tactions: context.actions,\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,iBAAoD,OAChE,MACA,YACG;AACG,QAAA,WAAW,MAAM,oBAAoB;AAAA,IAC1C,WAAW,KAAK;AAAA,IAChB,SAAS,KAAK;AAAA,IACd,SAAS,KAAK;AAAA,IACd,SAAS,QAAQ;AAAA,IACjB,SAAS,QAAQ;AAAA,EAAA,CACjB;AAED,QAAM,YAAY,MAAM,GAAG,SAAS,QAAQ;AAErC,SAAA;AAAA,IACN,MAAM;AAAA,EAAA;AAER;"}
@@ -1,36 +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 buildSliceAssetPath = require("../lib/buildSliceAssetPath.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 sliceAssetUpdate = async (data, context) => {
25
- const filePath = await buildSliceAssetPath.buildSliceAssetPath({
26
- libraryID: data.libraryID,
27
- sliceID: data.sliceID,
28
- assetID: data.asset.id,
29
- helpers: context.helpers,
30
- actions: context.actions
31
- });
32
- await fs__namespace.mkdir(path__namespace.dirname(filePath), { recursive: true });
33
- await fs__namespace.writeFile(filePath, data.asset.data);
34
- };
35
- exports.sliceAssetUpdate = sliceAssetUpdate;
36
- //# sourceMappingURL=slice-asset-update.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slice-asset-update.cjs","sources":["../../../src/hooks/slice-asset-update.ts"],"sourcesContent":["import type { SliceAssetUpdateHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildSliceAssetPath } from \"../lib/buildSliceAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceAssetUpdate: SliceAssetUpdateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst filePath = await buildSliceAssetPath({\n\t\tlibraryID: data.libraryID,\n\t\tsliceID: data.sliceID,\n\t\tassetID: data.asset.id,\n\t\thelpers: context.helpers,\n\t\tactions: context.actions,\n\t});\n\n\tawait fs.mkdir(path.dirname(filePath), { recursive: true });\n\tawait fs.writeFile(filePath, data.asset.data);\n};\n"],"names":["buildSliceAssetPath","fs","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAQa,MAAA,mBAAwD,OACpE,MACA,YACG;AACG,QAAA,WAAW,MAAMA,wCAAoB;AAAA,IAC1C,WAAW,KAAK;AAAA,IAChB,SAAS,KAAK;AAAA,IACd,SAAS,KAAK,MAAM;AAAA,IACpB,SAAS,QAAQ;AAAA,IACjB,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 { SliceAssetUpdateHook } from "@slicemachine/plugin-kit";
2
- import type { PluginOptions } from "../types";
3
- export declare const sliceAssetUpdate: SliceAssetUpdateHook<PluginOptions>;
@@ -1,18 +0,0 @@
1
- import * as fs from "node:fs/promises";
2
- import * as path from "node:path";
3
- import { buildSliceAssetPath } from "../lib/buildSliceAssetPath.js";
4
- const sliceAssetUpdate = async (data, context) => {
5
- const filePath = await buildSliceAssetPath({
6
- libraryID: data.libraryID,
7
- sliceID: data.sliceID,
8
- assetID: data.asset.id,
9
- helpers: context.helpers,
10
- actions: context.actions
11
- });
12
- await fs.mkdir(path.dirname(filePath), { recursive: true });
13
- await fs.writeFile(filePath, data.asset.data);
14
- };
15
- export {
16
- sliceAssetUpdate
17
- };
18
- //# sourceMappingURL=slice-asset-update.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slice-asset-update.js","sources":["../../../src/hooks/slice-asset-update.ts"],"sourcesContent":["import type { SliceAssetUpdateHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildSliceAssetPath } from \"../lib/buildSliceAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceAssetUpdate: SliceAssetUpdateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst filePath = await buildSliceAssetPath({\n\t\tlibraryID: data.libraryID,\n\t\tsliceID: data.sliceID,\n\t\tassetID: data.asset.id,\n\t\thelpers: context.helpers,\n\t\tactions: context.actions,\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,mBAAwD,OACpE,MACA,YACG;AACG,QAAA,WAAW,MAAM,oBAAoB;AAAA,IAC1C,WAAW,KAAK;AAAA,IAChB,SAAS,KAAK;AAAA,IACd,SAAS,KAAK,MAAM;AAAA,IACpB,SAAS,QAAQ;AAAA,IACjB,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,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const fs = require("node:fs/promises");
4
- const buildSliceDirectoryPath = require("../lib/buildSliceDirectoryPath.cjs");
5
- const rejectIfNecessary = require("../lib/rejectIfNecessary.cjs");
6
- const upsertGlobalContentTypes = require("../lib/upsertGlobalContentTypes.cjs");
7
- const upsertSliceLibraryIndexFile = require("../lib/upsertSliceLibraryIndexFile.cjs");
8
- function _interopNamespaceDefault(e) {
9
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
10
- if (e) {
11
- for (const k in e) {
12
- if (k !== "default") {
13
- const d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: () => e[k]
17
- });
18
- }
19
- }
20
- }
21
- n.default = e;
22
- return Object.freeze(n);
23
- }
24
- const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
25
- const deleteSliceDir = async ({ data, helpers }) => {
26
- const dir = buildSliceDirectoryPath.buildSliceDirectoryPath({
27
- libraryID: data.libraryID,
28
- model: data.model,
29
- helpers
30
- });
31
- await fs__namespace.rm(dir, { recursive: true });
32
- };
33
- const sliceDelete = async (data, context) => {
34
- await deleteSliceDir({ data, ...context });
35
- rejectIfNecessary.rejectIfNecessary(await Promise.allSettled([
36
- upsertGlobalContentTypes.upsertGlobalContentTypes(context),
37
- upsertSliceLibraryIndexFile.upsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context })
38
- ]));
39
- };
40
- exports.sliceDelete = sliceDelete;
41
- //# sourceMappingURL=slice-delete.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slice-delete.cjs","sources":["../../../src/hooks/slice-delete.ts"],"sourcesContent":["import type {\n\tSliceDeleteHook,\n\tSliceDeleteHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildSliceDirectoryPath } from \"../lib/buildSliceDirectoryPath\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdata: SliceDeleteHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst deleteSliceDir = async ({ data, helpers }: Args) => {\n\tconst dir = buildSliceDirectoryPath({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\thelpers,\n\t});\n\n\tawait fs.rm(dir, { recursive: true });\n};\n\nexport const sliceDelete: SliceDeleteHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tawait deleteSliceDir({ data, ...context });\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertGlobalContentTypes(context),\n\t\t\tupsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context }),\n\t\t]),\n\t);\n};\n"],"names":["buildSliceDirectoryPath","fs","rejectIfNecessary","upsertGlobalContentTypes","upsertSliceLibraryIndexFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,iBAAiB,OAAO,EAAE,MAAM,cAAmB;AACxD,QAAM,MAAMA,wBAAAA,wBAAwB;AAAA,IACnC,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ;AAAA,EAAA,CACA;AAED,QAAMC,cAAG,GAAG,KAAK,EAAE,WAAW,MAAM;AACrC;AAEa,MAAA,cAA8C,OAC1D,MACA,YACG;AACH,QAAM,eAAe,EAAE,MAAM,GAAG,QAAS,CAAA;AAGxCC,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxBC,yBAAAA,yBAAyB,OAAO;AAAA,IAChCC,wDAA4B,EAAE,WAAW,KAAK,WAAW,GAAG,SAAS;AAAA,EACrE,CAAA,CAAC;AAEJ;;"}
@@ -1,3 +0,0 @@
1
- import type { SliceDeleteHook } from "@slicemachine/plugin-kit";
2
- import type { PluginOptions } from "../types";
3
- export declare const sliceDelete: SliceDeleteHook<PluginOptions>;
@@ -1,24 +0,0 @@
1
- import * as fs from "node:fs/promises";
2
- import { buildSliceDirectoryPath } from "../lib/buildSliceDirectoryPath.js";
3
- import { rejectIfNecessary } from "../lib/rejectIfNecessary.js";
4
- import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes.js";
5
- import { upsertSliceLibraryIndexFile } from "../lib/upsertSliceLibraryIndexFile.js";
6
- const deleteSliceDir = async ({ data, helpers }) => {
7
- const dir = buildSliceDirectoryPath({
8
- libraryID: data.libraryID,
9
- model: data.model,
10
- helpers
11
- });
12
- await fs.rm(dir, { recursive: true });
13
- };
14
- const sliceDelete = async (data, context) => {
15
- await deleteSliceDir({ data, ...context });
16
- rejectIfNecessary(await Promise.allSettled([
17
- upsertGlobalContentTypes(context),
18
- upsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context })
19
- ]));
20
- };
21
- export {
22
- sliceDelete
23
- };
24
- //# sourceMappingURL=slice-delete.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slice-delete.js","sources":["../../../src/hooks/slice-delete.ts"],"sourcesContent":["import type {\n\tSliceDeleteHook,\n\tSliceDeleteHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildSliceDirectoryPath } from \"../lib/buildSliceDirectoryPath\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdata: SliceDeleteHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst deleteSliceDir = async ({ data, helpers }: Args) => {\n\tconst dir = buildSliceDirectoryPath({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\thelpers,\n\t});\n\n\tawait fs.rm(dir, { recursive: true });\n};\n\nexport const sliceDelete: SliceDeleteHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tawait deleteSliceDir({ data, ...context });\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertGlobalContentTypes(context),\n\t\t\tupsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context }),\n\t\t]),\n\t);\n};\n"],"names":[],"mappings":";;;;;AAkBA,MAAM,iBAAiB,OAAO,EAAE,MAAM,cAAmB;AACxD,QAAM,MAAM,wBAAwB;AAAA,IACnC,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ;AAAA,EAAA,CACA;AAED,QAAM,GAAG,GAAG,KAAK,EAAE,WAAW,MAAM;AACrC;AAEa,MAAA,cAA8C,OAC1D,MACA,YACG;AACH,QAAM,eAAe,EAAE,MAAM,GAAG,QAAS,CAAA;AAGxC,oBAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,yBAAyB,OAAO;AAAA,IAChC,4BAA4B,EAAE,WAAW,KAAK,WAAW,GAAG,SAAS;AAAA,EACrE,CAAA,CAAC;AAEJ;"}
@@ -1,62 +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 buildSliceLibraryDirectoryPath = require("../lib/buildSliceLibraryDirectoryPath.cjs");
6
- const isSharedSliceModel = require("../lib/isSharedSliceModel.cjs");
7
- const readJSONFile = require("../lib/readJSONFile.cjs");
8
- function _interopNamespaceDefault(e) {
9
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
10
- if (e) {
11
- for (const k in e) {
12
- if (k !== "default") {
13
- const d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: () => e[k]
17
- });
18
- }
19
- }
20
- }
21
- n.default = e;
22
- return Object.freeze(n);
23
- }
24
- const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
25
- const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
26
- const sliceRead = async (data, { helpers }) => {
27
- const libraryDir = buildSliceLibraryDirectoryPath.buildSliceLibraryDirectoryPath({
28
- libraryID: data.libraryID,
29
- helpers
30
- });
31
- await fs__namespace.mkdir(libraryDir, { recursive: true });
32
- const childDirs = await fs__namespace.readdir(libraryDir, { withFileTypes: true });
33
- const modelReadErrors = [];
34
- const [model] = (await Promise.all(childDirs.map(async (childDir) => {
35
- if (childDir.isDirectory()) {
36
- const modelPath = path__namespace.join(libraryDir, childDir.name, "model.json");
37
- try {
38
- const modelContents = await readJSONFile.readJSONFile(modelPath);
39
- if (isSharedSliceModel.isSharedSliceModel(modelContents) && modelContents.id === data.sliceID) {
40
- return modelContents;
41
- }
42
- } catch (error) {
43
- modelReadErrors.push(modelPath);
44
- }
45
- }
46
- }))).filter((model2) => Boolean(model2));
47
- if (model) {
48
- return {
49
- model
50
- };
51
- } else {
52
- if (modelReadErrors.length) {
53
- throw new Error(`Did not find a Slice model with ID "${data.sliceID}" in the "${data.libraryID}" Slice Library.
54
-
55
- Those Slice models could not be read:
56
- - ${modelReadErrors.join("\n - ")}`);
57
- }
58
- throw new Error(`Did not find a Slice model with ID "${data.sliceID}" in the "${data.libraryID}" Slice Library.`);
59
- }
60
- };
61
- exports.sliceRead = sliceRead;
62
- //# sourceMappingURL=slice-read.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slice-read.cjs","sources":["../../../src/hooks/slice-read.ts"],"sourcesContent":["import type { SliceReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildSliceLibraryDirectoryPath } from \"../lib/buildSliceLibraryDirectoryPath\";\nimport { isSharedSliceModel } from \"../lib/isSharedSliceModel\";\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceRead: SliceReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst libraryDir = buildSliceLibraryDirectoryPath({\n\t\tlibraryID: data.libraryID,\n\t\thelpers,\n\t});\n\n\t// Ensure the directory exists.\n\tawait fs.mkdir(libraryDir, { recursive: true });\n\n\tconst childDirs = await fs.readdir(libraryDir, { withFileTypes: true });\n\n\tconst modelReadErrors: string[] = [];\n\n\t// Find the first matching model.\n\tconst [model] = (\n\t\tawait Promise.all(\n\t\t\tchildDirs.map(async (childDir) => {\n\t\t\t\tif (childDir.isDirectory()) {\n\t\t\t\t\tconst modelPath = path.join(libraryDir, childDir.name, \"model.json\");\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tisSharedSliceModel(modelContents) &&\n\t\t\t\t\t\t\tmodelContents.id === data.sliceID\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn modelContents;\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tmodelReadErrors.push(modelPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}),\n\t\t)\n\t).filter((model): model is NonNullable<typeof model> => Boolean(model));\n\n\tif (model) {\n\t\treturn {\n\t\t\tmodel,\n\t\t};\n\t} else {\n\t\tif (modelReadErrors.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Did not find a Slice model with ID \"${data.sliceID}\" in the \"${\n\t\t\t\t\tdata.libraryID\n\t\t\t\t}\" Slice Library.\\n\\nThose Slice models could not be read:\\n - ${modelReadErrors.join(\n\t\t\t\t\t\"\\n - \",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t`Did not find a Slice model with ID \"${data.sliceID}\" in the \"${data.libraryID}\" Slice Library.`,\n\t\t);\n\t}\n};\n"],"names":["buildSliceLibraryDirectoryPath","fs","path","readJSONFile","isSharedSliceModel","model"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAUO,MAAM,YAA0C,OACtD,MACA,EAAE,cACC;AACH,QAAM,aAAaA,+BAAAA,+BAA+B;AAAA,IACjD,WAAW,KAAK;AAAA,IAChB;AAAA,EAAA,CACA;AAGD,QAAMC,cAAG,MAAM,YAAY,EAAE,WAAW,MAAM;AAExC,QAAA,YAAY,MAAMA,cAAG,QAAQ,YAAY,EAAE,eAAe,MAAM;AAEtE,QAAM,kBAA4B,CAAA;AAG5B,QAAA,CAAC,KAAK,KACX,MAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,QAAA,SAAS,eAAe;AAC3B,YAAM,YAAYC,gBAAK,KAAK,YAAY,SAAS,MAAM,YAAY;AAC/D,UAAA;AACG,cAAA,gBAAgB,MAAMC,0BAAa,SAAS;AAElD,YACCC,mBAAAA,mBAAmB,aAAa,KAChC,cAAc,OAAO,KAAK,SACzB;AACM,iBAAA;AAAA,QACP;AAAA,eACO;AACR,wBAAgB,KAAK,SAAS;AAAA,MAC9B;AAAA,IACD;AAAA,EAAA,CACD,CAAC,GAEF,OAAO,CAACC,WAA8C,QAAQA,MAAK,CAAC;AAEtE,MAAI,OAAO;AACH,WAAA;AAAA,MACN;AAAA,IAAA;AAAA,SAEK;AACN,QAAI,gBAAgB,QAAQ;AAC3B,YAAM,IAAI,MACT,uCAAuC,KAAK,oBAC3C,KAAK;AAAA;AAAA;AAAA,MAC4D,gBAAgB,KACjF,QAAQ,GACN;AAAA,IAEJ;AAED,UAAM,IAAI,MACT,uCAAuC,KAAK,oBAAoB,KAAK,2BAA2B;AAAA,EAEjG;AACF;;"}